/* Paper Calendar の表示スタイル。 */

:root {
  color-scheme: light;
  font-family: "Hiragino Kaku Gothic ProN", "Yu Gothic", sans-serif;
  color: #35312e;
  background: #e8e3d9;
}

* {
  box-sizing: border-box;
}

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  padding: 24px 16px;
}

button,
input {
  font: inherit;
}

#app {
  width: min(100%, 1440px);
  margin: 0 auto;
  padding: 20px;
  background: #fffdf8;
  border: 1px solid #d7d0c4;
  box-shadow: 0 5px 18px rgb(67 55 40 / 12%);
}

.app-message,
.login-form {
  width: min(100%, 360px);
  margin: 40px auto;
  padding: 24px;
  color: #4b4540;
  background: #fffefa;
  border: 1px solid #d7d0c4;
  box-shadow: 0 5px 18px rgb(67 55 40 / 8%);
}

.configuration-message {
  width: min(100%, 560px);
}

.login-form {
  display: grid;
  gap: 12px;
}

.login-form h1,
.configuration-message h1 {
  margin: 0;
  font-size: 1.4rem;
}

.login-description,
.login-error {
  min-height: 1.3em;
  margin: 0;
  font-size: 0.85rem;
}

.login-error {
  color: #b94c47;
}

.login-form label {
  display: grid;
  gap: 5px;
  font-size: 0.85rem;
}

.login-form input {
  width: 100%;
  padding: 7px 8px;
  color: #35312e;
  background: #fffefa;
  border: 1px solid #cfc6b8;
  border-radius: 3px;
}

.login-form button {
  min-height: 34px;
  color: #4b4540;
  background: #f7f3eb;
  border: 1px solid #cfc6b8;
  border-radius: 3px;
  cursor: pointer;
}

.sync-status {
  align-self: center;
  color: #81786d;
  font-size: 0.72rem;
  white-space: nowrap;
}

.sync-status.is-saving,
.sync-status.is-loading {
  color: #5d7a96;
}

.sync-status.is-error,
.sync-status.is-conflict {
  color: #b94c47;
}

.app-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 230px;
  align-items: start;
  gap: 16px;
}

.calendar-panel {
  min-width: 0;
}

.todo-panel {
  display: flex;
  flex-direction: column;
  min-width: 0;
  padding: 14px;
  background: #fffefa;
  border: 1px solid #d7d0c4;
  box-shadow: 0 2px 8px rgb(67 55 40 / 7%);
}

.todo-title {
  margin: 0 0 10px;
  color: #4b4540;
  font-size: 0.92rem;
  font-weight: 600;
}

.todo-list {
  display: flex;
  flex: 1;
  flex-direction: column;
  min-height: 0;
  margin: 0;
  padding-left: 1.15em;
  overflow-y: auto;
  color: #4b4540;
  font-size: 0.82rem;
}

.todo-item {
  padding: 4px 0;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.todo-empty {
  padding: 4px 0;
  color: #938a7d;
  list-style: none;
}

.calendar-header {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 12px;
  margin-bottom: 18px;
}

.calendar-navigation {
  display: flex;
  gap: 6px;
}

.calendar-title {
  margin: 0;
  font-size: clamp(1.25rem, 4vw, 1.6rem);
  font-weight: 600;
  letter-spacing: 0.06em;
  text-align: center;
}

.calendar-button {
  min-width: 34px;
  min-height: 32px;
  padding: 3px 9px;
  color: #4b4540;
  background: #f7f3eb;
  border: 1px solid #cfc6b8;
  border-radius: 3px;
  cursor: pointer;
}

.calendar-button:hover {
  background: #ece5d9;
}

.calendar-button:disabled {
  color: #aaa296;
  background: #f3f0e9;
  cursor: not-allowed;
  opacity: 0.75;
}

.calendar-button:focus-visible {
  outline: 3px solid #5999d2;
  outline-offset: 2px;
}

.calendar-header > .calendar-button {
  justify-self: end;
}

.calendar-actions {
  display: flex;
  justify-self: end;
  gap: 6px;
}

.calendar {
  overflow-x: auto;
}

.weekday-row,
.calendar-surface {
  min-width: 960px;
}

.weekday-row,
.day-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
}

.weekday {
  padding: 0 0 7px;
  color: #69625a;
  font-size: 0.78rem;
  font-weight: 600;
  text-align: center;
}

.weekday-5 {
  color: #3677ad;
}

.weekday-6 {
  color: #bf4d48;
}

.calendar-surface {
  position: relative;
}

.day-grid {
  position: relative;
  border-top: 1px solid #d8d0c4;
  border-left: 1px solid #d8d0c4;
}

.day-cell {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  min-height: 0;
  padding: 7px 8px;
  color: #35312e;
  background: #fffdf8;
  border-right: 1px solid #d8d0c4;
  border-bottom: 1px solid #d8d0c4;
  font-size: 0.88rem;
  cursor: text;
}

.day-number {
  flex: none;
}

.day-cell.is-saturday .day-number,
.day-cell.is-sunday .day-number,
.day-cell.is-holiday .day-number {
  font-weight: 700;
}

.day-cell.is-outside-month {
  color: #b9b1a6;
  background: #faf7f1;
}

.day-cell.is-saturday {
  color: #3677ad;
}

.day-cell.is-sunday,
.day-cell.is-holiday {
  color: #bf4d48;
}

.day-cell.is-today::after {
  position: absolute;
  inset: 3px;
  border: 2px solid #3f8ed0;
  border-radius: 2px;
  content: "";
  pointer-events: none;
}

.event-list {
  display: flex;
  flex-direction: column;
  width: 100%;
  gap: 3px;
  margin-top: calc(5px + var(--range-space, 0px));
}

/* 1日予定 */
.event-item {
  position: relative;
  display: flex;
  align-items: flex-start;
  gap: 4px;
  min-width: 0;
  color: #4b4540;
  font-size: 0.78rem;
  line-height: 1.35;
}

.event-content {
  display: flex;
  flex: 1;
  align-items: flex-start;
  min-width: 0;
  gap: 4px;
  cursor: grab;
}

.event-content:active {
  cursor: grabbing;
}

.event-checkbox {
  flex: none;
  width: 14px;
  height: 14px;
  margin: 1px 0 0;
  accent-color: #65865b;
  cursor: pointer;
}

.event-title {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* 1日予定はセル内で全文を折り返す。期間バーのタイトルは従来どおり1行のまま。 */
.event-item .event-title {
  flex: 1;
  min-width: 0;
  overflow: visible;
  text-overflow: clip;
  white-space: normal;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.event-item.is-completed .event-title,
.range-bar.is-completed .event-title {
  color: #8a8379;
  text-decoration: line-through;
}

.resize-handle {
  flex: none;
  margin-left: auto;
  color: #827a70;
  cursor: ew-resize;
  opacity: 0.45;
  user-select: none;
}

.event-item:hover .resize-handle,
.range-bar:hover .resize-handle {
  opacity: 1;
}

.event-item.is-dragging,
.range-bar.is-dragging {
  opacity: 0.35;
}

.event-item.drag-over-before::before,
.event-item.drag-over-after::after {
  position: absolute;
  right: 0;
  left: 0;
  height: 2px;
  background: #3f8ed0;
  content: "";
}

.event-item.drag-over-before::before {
  top: -3px;
}

.event-item.drag-over-after::after {
  bottom: -3px;
}

.event-input {
  width: 100%;
  min-width: 0;
  padding: 2px 3px;
  color: #35312e;
  background: #fffefa;
  border: 1px solid #8ba9bf;
  border-radius: 2px;
  font-size: 0.78rem;
  outline: none;
}

.event-input:focus {
  border-color: #3f8ed0;
  box-shadow: 0 0 0 1px #3f8ed0;
}

/* 期間予定: 日付セルから独立した、週単位の帯レイヤー。 */
.range-layer {
  position: absolute;
  inset: 0;
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  pointer-events: none;
}

.range-bar {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  min-width: 0;
  height: 19px;
  margin-top: calc(27px + var(--range-lane) * 24px);
  padding: 1px 5px;
  color: #4b4538;
  background: var(--range-color, #eadf8c);
  border-radius: 0;
  font-size: 0.75rem;
  line-height: 1.2;
  pointer-events: auto;
}

.range-bar.is-range-start {
  margin-left: 3px;
  border-radius: 4px 0 0 4px;
}

.range-bar.is-range-end {
  margin-right: 3px;
  border-radius: 0 4px 4px 0;
  padding-right: 22px;
}

.range-bar.is-range-start.is-range-end {
  border-radius: 4px;
}

.range-bar .event-content {
  overflow: hidden;
}

.range-bar .event-title {
  min-width: 0;
}

.range-bar .event-checkbox {
  margin-top: 0;
}

.range-bar .resize-handle {
  position: absolute;
  top: 50%;
  right: 4px;
  margin: 0;
  transform: translateY(-50%);
}

.day-cell.is-move-target {
  background: #f1f7fb;
}

.day-cell.is-resize-target {
  background: #f6f5e8;
  box-shadow: inset 0 0 0 2px #65865b;
}

@media (max-width: 480px) {
  body {
    padding: 12px 8px;
  }

  #app {
    padding: 14px 10px;
  }

  .calendar-header {
    gap: 6px;
  }

  .app-layout {
    grid-template-columns: minmax(960px, 1fr) 210px;
  }

  .calendar-button {
    min-width: 30px;
    padding-inline: 7px;
  }

  .day-cell {
    padding: 5px;
  }
}
