:root {
  color-scheme: light;
  --page: #fffafb;
  --surface: rgba(255, 255, 255, 0.24);
  --surface-soft: rgba(255, 250, 252, 0.34);
  --text: rgba(0, 0, 0, 0.95);
  --muted: #615d59;
  --muted-light: #a39e98;
  --border: rgba(0, 0, 0, 0.1);
  --border-strong: rgba(0, 0, 0, 0.16);
  --blue: #c94f78;
  --blue-active: #a83d62;
  --blue-soft: rgba(255, 238, 244, 0.9);
  --focus: #b9426b;
  --teal: #2f8f79;
  --green-soft: rgba(233, 249, 241, 0.88);
  --rose-border: rgba(201, 79, 120, 0.2);
  --shadow-card: rgba(120, 76, 88, 0.08) 0 14px 34px,
    rgba(80, 54, 64, 0.05) 0 4px 14px,
    rgba(0, 0, 0, 0.03) 0 1px 3px;
  --shadow-deep: rgba(0, 0, 0, 0.01) 0 1px 3px,
    rgba(0, 0, 0, 0.02) 0 3px 7px,
    rgba(0, 0, 0, 0.02) 0 7px 15px,
    rgba(0, 0, 0, 0.04) 0 14px 28px,
    rgba(0, 0, 0, 0.05) 0 23px 52px;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  min-height: 100%;
}

body {
  min-height: 100%;
  margin: 0;
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  font-feature-settings: "lnum", "locl";
  letter-spacing: 0;
  color: var(--text);
  background-color: var(--page);
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.46), rgba(255, 250, 252, 0.68)),
    url("./assets/letter-flowers.jpg");
  background-position: center;
  background-size: cover;
  background-attachment: fixed;
  overflow-x: hidden;
}

button,
input,
textarea {
  font: inherit;
  letter-spacing: 0;
}

button {
  cursor: pointer;
}

.app-shell {
  width: min(1200px, calc(100% - 32px));
  margin: 0 auto;
  padding: 24px 0 48px;
}

.timeline-band,
.calendar-panel,
.letter-panel {
  margin-top: 16px;
  padding: 24px;
  background: var(--surface);
  border: 1px solid var(--rose-border);
  border-radius: 8px;
  box-shadow: var(--shadow-card);
  backdrop-filter: blur(8px);
}

.timeline-band {
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.34), rgba(255, 244, 248, 0.2)),
    var(--surface);
}

.calendar-panel {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.36), rgba(247, 255, 251, 0.2)),
    var(--surface);
}

.letter-panel {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.38), rgba(255, 248, 251, 0.24)),
    var(--surface);
}

.timeline-band {
  margin-top: 0;
}

.section-title {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 16px;
}

.timeline-heading {
  display: grid;
  gap: 10px;
}

.timeline-heading > span,
.panel-heading h2,
.dialog-heading h2,
.letter-panel h2 {
  margin: 0;
  color: var(--text);
  font-weight: 700;
  line-height: 1.23;
  overflow-wrap: anywhere;
}

.timeline-heading > span {
  font-size: 1.38rem;
}

.panel-heading h2,
.dialog-heading h2,
.letter-panel h2 {
  font-size: 1.38rem;
}

.panel-heading p,
.dialog-heading p,
.letter-date {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 500;
  line-height: 1.43;
}

.section-title > span:last-child {
  flex: 0 0 auto;
  margin-top: 2px;
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 500;
}

.quick-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.quick-stats span,
.timeline-item .count {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 4px 8px;
  color: var(--focus);
  background: var(--blue-soft);
  border: 1px solid var(--rose-border);
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 600;
  line-height: 1.33;
}

.timeline {
  display: flex;
  gap: 8px;
  min-height: 100px;
  overflow-x: auto;
  padding: 1px 1px 4px;
  scrollbar-color: var(--muted-light) transparent;
}

.timeline-item {
  flex: 0 0 148px;
  display: grid;
  gap: 8px;
  min-height: 96px;
  padding: 12px;
  text-align: left;
  color: var(--text);
  background: rgba(255, 255, 255, 0.82);
  border: 1px solid var(--rose-border);
  border-radius: 8px;
  box-shadow: none;
}

.timeline-item[aria-current="true"] {
  color: #ffffff;
  background: var(--blue);
  border-color: var(--blue);
}

.timeline-item:disabled {
  cursor: default;
  color: var(--muted-light);
  background: var(--surface-soft);
  border-color: var(--border);
  opacity: 0.75;
}

.timeline-item[aria-current="true"] .count {
  color: var(--blue);
  background: #ffffff;
  border-color: rgba(255, 255, 255, 0.72);
}

.timeline-item .year {
  color: inherit;
  font-size: 0.75rem;
  font-weight: 500;
  line-height: 1.33;
  opacity: 0.8;
}

.timeline-item .month {
  color: inherit;
  font-size: 1.38rem;
  font-weight: 700;
  line-height: 1.27;
}

.workspace-grid {
  display: grid;
  grid-template-columns: minmax(360px, 0.92fr) minmax(360px, 1.08fr);
  gap: 16px;
  align-items: stretch;
}

.panel-heading,
.dialog-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.icon-button {
  display: inline-grid;
  place-items: center;
  flex: 0 0 auto;
  width: 36px;
  height: 36px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid var(--rose-border);
  border-radius: 4px;
  font-size: 1.2rem;
  font-weight: 600;
}

.icon-button:disabled {
  cursor: default;
  color: var(--muted-light);
  background: rgba(0, 0, 0, 0.03);
}

.weekdays,
.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 6px;
}

.weekdays {
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 600;
  line-height: 1.33;
  text-align: center;
}

.calendar-grid {
  min-width: 0;
  min-height: 474px;
}

.day-button {
  position: relative;
  display: grid;
  align-content: space-between;
  min-width: 0;
  min-height: 74px;
  padding: 8px;
  text-align: left;
  color: var(--text);
  background: rgba(255, 255, 255, 0.74);
  border: 1px solid rgba(201, 79, 120, 0.16);
  border-radius: 6px;
}

.day-button.is-muted {
  color: var(--muted-light);
  background: rgba(255, 255, 255, 0.42);
}

.day-button.is-muted:disabled {
  cursor: default;
}

.day-button.is-selected {
  color: #ffffff;
  background: var(--blue);
  border-color: var(--blue);
}

.day-button.is-today::after {
  content: "";
  position: absolute;
  inset: 5px;
  border: 1px solid var(--focus);
  border-radius: 4px;
  pointer-events: none;
}

.day-number {
  font-size: 0.88rem;
  font-weight: 600;
  line-height: 1.43;
}

.letter-dot {
  width: 8px;
  height: 8px;
  border-radius: 100%;
  background: var(--teal);
}

.day-button.is-selected .letter-dot {
  background: #ffffff;
}

.letter-panel {
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-height: 460px;
}

.letter-mobile-bar {
  display: none;
}

.mobile-letter-nav {
  display: none;
}

.letter-paper {
  flex: 1;
  min-height: 340px;
  padding: 28px;
  color: #292827;
  background-color: #ffffff;
  background-image: repeating-linear-gradient(
    to bottom,
    transparent 0,
    transparent 1.94rem,
    rgba(201, 79, 120, 0.08) 1.94rem,
    rgba(201, 79, 120, 0.08) 2rem
  );
  background-origin: content-box;
  background-clip: padding-box;
  border: 1px solid rgba(201, 79, 120, 0.18);
  border-radius: 8px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.95);
}

.letter-date {
  margin: 0;
  color: var(--focus);
  font-weight: 600;
  line-height: 2rem;
}

.letter-paper h2 {
  margin: 0;
  line-height: 2rem;
}

.letter-body {
  margin: 0;
  color: #2e2b29;
  font-family: "Nanum Myeongjo", "Noto Serif KR", Georgia, "Times New Roman", serif;
  font-size: 1.06rem;
  font-weight: 400;
  line-height: 2rem;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.comments-panel {
  display: grid;
  gap: 12px;
  padding-top: 16px;
  border-top: 1px solid rgba(201, 79, 120, 0.16);
}

.comment-list {
  display: grid;
  gap: 10px;
}

.comment-item {
  display: grid;
  gap: 6px;
  padding: 10px 0 10px 12px;
  border-left: 2px solid rgba(201, 79, 120, 0.24);
}

.comment-item p,
.comment-empty {
  margin: 0;
  color: var(--muted);
  font-size: 0.94rem;
  line-height: 1.65;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.comment-item time {
  color: var(--muted-light);
  font-size: 0.75rem;
  line-height: 1.33;
}

.comment-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}

.comment-form input {
  width: 100%;
  min-width: 0;
  min-height: 38px;
  padding: 8px 10px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid rgba(201, 79, 120, 0.2);
  border-radius: 4px;
  line-height: 1.5;
}

.letter-actions,
.dialog-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.primary-button,
.ghost-button {
  min-height: 38px;
  padding: 8px 16px;
  border-radius: 4px;
  font-size: 0.94rem;
  font-weight: 600;
  line-height: 1.33;
}

.primary-button {
  color: #ffffff;
  background: var(--blue);
  border: 1px solid transparent;
}

.ghost-button {
  color: var(--text);
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid var(--rose-border);
}

.primary-button:disabled,
.ghost-button:disabled {
  cursor: default;
  color: var(--muted-light);
  background: rgba(255, 255, 255, 0.48);
  border-color: rgba(0, 0, 0, 0.08);
}

.editor-dialog {
  width: min(620px, calc(100% - 28px));
  padding: 0;
  border: 0;
  border-radius: 8px;
  box-shadow: var(--shadow-deep);
}

.editor-dialog::backdrop {
  background: rgba(0, 0, 0, 0.38);
}

.editor-form {
  display: grid;
  gap: 16px;
  padding: 24px;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.editor-form label {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 600;
  line-height: 1.43;
}

.editor-form input,
.editor-form textarea {
  width: 100%;
  min-width: 0;
  padding: 8px;
  color: var(--text);
  background: var(--surface);
  border: 1px solid #dddddd;
  border-radius: 4px;
}

.editor-form input::placeholder,
.editor-form textarea::placeholder {
  color: var(--muted-light);
}

.editor-form textarea {
  resize: vertical;
  line-height: 1.5;
}

.timeline-item:hover,
.day-button:hover,
.icon-button:hover,
.ghost-button:hover {
  background: var(--surface-soft);
}

.timeline-item[aria-current="true"]:hover,
.day-button.is-selected:hover,
.primary-button:hover {
  background: var(--blue-active);
}

.timeline-item:disabled:hover,
.timeline-item[aria-current="true"]:disabled:hover,
.ghost-button:disabled:hover,
.primary-button:disabled:hover,
.icon-button:disabled:hover {
  background: rgba(0, 0, 0, 0.03);
}

.day-button.is-muted:disabled:hover {
  background: rgba(255, 255, 255, 0.42);
}

.day-button:focus-visible,
.timeline-item:focus-visible,
.primary-button:focus-visible,
.ghost-button:focus-visible,
.icon-button:focus-visible,
.comment-form input:focus-visible,
.editor-form input:focus-visible,
.editor-form textarea:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

.primary-button:active,
.ghost-button:active,
.icon-button:active,
.day-button:active,
.timeline-item:active {
  transform: scale(0.98);
}

@media (max-width: 860px) {
  .workspace-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 700px) {
  body {
    background-attachment: scroll;
  }

  body.is-letter-open {
    overflow: hidden;
  }

  body.is-letter-open::after {
    content: "";
    position: fixed;
    inset: 0;
    z-index: 10;
    background: rgba(40, 31, 34, 0.26);
  }

  .workspace-grid {
    display: block;
  }

  .letter-panel {
    position: fixed;
    inset: 7vh 0 0;
    z-index: 20;
    margin: 0;
    min-height: 0;
    max-height: 93vh;
    overflow-y: auto;
    padding: 16px 16px 24px;
    border-right: 0;
    border-bottom: 0;
    border-left: 0;
    border-radius: 8px 8px 0 0;
    box-shadow: rgba(62, 39, 48, 0.18) 0 -18px 42px;
    transform: translateY(108%);
    transition: transform 260ms ease;
  }

  body.is-letter-open .letter-panel {
    transform: translateY(0);
  }

  .letter-mobile-bar {
    position: sticky;
    top: -16px;
    z-index: 2;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin: -16px -16px 0;
    padding: 12px 16px;
    background: rgba(255, 255, 255, 0.9);
    border-bottom: 1px solid rgba(201, 79, 120, 0.16);
    backdrop-filter: blur(12px);
  }

  .letter-mobile-bar span {
    color: var(--text);
    font-weight: 700;
    line-height: 1.4;
  }

  .mobile-letter-nav {
    position: sticky;
    bottom: -24px;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin: auto -16px -24px;
    padding: 12px 16px max(12px, env(safe-area-inset-bottom));
    background: rgba(255, 255, 255, 0.88);
    border-top: 1px solid rgba(201, 79, 120, 0.16);
    backdrop-filter: blur(12px);
  }

  .mobile-letter-nav .ghost-button {
    min-height: 46px;
  }

  .calendar-panel {
    min-height: calc(100vh - 188px);
  }

  .calendar-grid {
    min-height: 0;
  }

  .day-button {
    min-height: 52px;
  }
}

@media (max-width: 560px) {
  .app-shell {
    width: min(100% - 20px, 1200px);
    padding: 10px 0 32px;
  }

  .timeline-band,
  .calendar-panel,
  .editor-form {
    padding: 16px;
  }

  .section-title {
    display: grid;
  }

  .timeline-item {
    flex-basis: 132px;
  }

  .calendar-panel {
    margin-top: 12px;
  }

  .day-button {
    min-height: 56px;
    padding: 6px;
  }

  .letter-paper {
    min-height: 300px;
    padding: 20px;
  }

  .panel-heading h2,
  .dialog-heading h2,
  .letter-panel h2,
  .timeline-heading > span {
    font-size: 1.24rem;
  }
}
