/* Component CSS lives next to its view (public/components/<Name>/styles.css)
   and is pulled in here so index.html only needs to load one stylesheet. */
@import "../components/CardItem/styles.css";
@import "../components/DayItem/styles.css";
@import "../components/LessonCard/styles.css";
@import "../components/TemplateCard/styles.css";
@import "../components/BuilderRow/styles.css";
@import "../components/LessonDetailModal/styles.css";

:root {
      color-scheme: light;
      --ink: #17202b;
      --muted: #667085;
      --line: #d5dde7;
      --bg: #edf2f7;
      --panel: #ffffff;
      --soft: #f7f9fc;
      --green: #238765;
      --blue: #3464a2;
      --red: #a94336;
      --selected: #e8f0fb;
      --track: #dbe3ee;
      --warning-bg: #fff5e2;
      --warning-border: #f1c27d;
      --warning-ink: #855e1a;
    }

    * { box-sizing: border-box; }

    body {
      margin: 0;
      font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
      color: var(--ink);
      background: var(--bg);
      letter-spacing: 0;
    }

    button, input, select {
      font: inherit;
    }

    /* Phase 4 blueprint §4: vertical viewport cascade. */
    .page {
      min-height: 100vh;
      min-height: 100svh;
      display: grid;
      grid-template-rows: auto auto auto 1fr;
    }

    header {
      display: grid;
      grid-template-columns: 1fr auto;
      gap: 18px;
      align-items: center;
      padding: 18px 24px 12px;
      background: rgba(255, 255, 255, .88);
      border-bottom: 1px solid var(--line);
    }

    .title strong {
      display: block;
      font-size: clamp(22px, 2.4vw, 34px);
      line-height: 1.08;
      font-weight: 950;
    }

    .title span {
      display: block;
      margin-top: 6px;
      color: var(--muted);
      font-size: 14px;
      font-weight: 750;
    }

    .summary {
      display: grid;
      grid-template-columns: repeat(3, auto);
      gap: 8px;
    }

    .chip {
      padding: 8px 11px;
      border: 1px solid var(--line);
      border-radius: 999px;
      background: var(--panel);
      color: var(--muted);
      font-size: 13px;
      font-weight: 900;
      white-space: nowrap;
    }

    /* Phase 4 blueprint §7 / §8: page-level warning strip replaces footer
       warning slot. Hidden until populated. */
    .page-banner {
      display: none;
      padding: 10px 24px;
      border-bottom: 1px solid var(--line);
      font-size: 13px;
      font-weight: 850;
    }

    .page-banner:not([hidden]) {
      display: block;
    }

    .page-banner--warning {
      background: var(--warning-bg);
      border-bottom-color: var(--warning-border);
      color: var(--warning-ink);
    }

    .progress-wrap {
      padding: 12px 24px 0;
      background: rgba(255, 255, 255, .88);
    }

    .progress-head {
      display: grid;
      grid-template-columns: 1fr 1fr;
      gap: 14px;
      max-width: 1280px;
      margin: 0 auto 8px;
    }

    .progress-step {
      display: grid;
      grid-template-columns: auto 1fr;
      gap: 10px;
      align-items: center;
      color: var(--muted);
      font-weight: 900;
    }

    .progress-step.active {
      color: var(--ink);
    }

    .step-dot {
      display: grid;
      place-items: center;
      width: 28px;
      height: 28px;
      border-radius: 50%;
      background: var(--track);
      color: var(--muted);
      font-size: 13px;
      font-weight: 950;
    }

    .progress-step.active .step-dot {
      background: var(--green);
      color: #fff;
    }

    .progress {
      max-width: 1280px;
      height: 10px;
      margin: 0 auto;
      overflow: hidden;
      border-radius: 999px;
      background: var(--track);
    }

    .progress-fill {
      width: 50%;
      height: 100%;
      background: var(--green);
      transition: width .22s ease;
    }

    main {
      position: relative;
      width: min(1280px, 100%);
      margin: 0 auto;
      padding: 18px 24px 24px;
      min-height: 0;
      display: grid;
    }

    .screen {
      display: none;
      gap: 16px;
      min-height: 0;
    }

    .screen.active {
      display: grid;
    }

    .template-picker-screen {
      position: absolute;
      inset: 0;
      z-index: 40;
      place-items: center;
      padding: 18px;
      background: rgba(23, 32, 43, .42);
    }

    .template-picker-screen:not(.active) {
      display: none;
    }

    .template-picker-screen .section {
      width: min(900px, 100%);
      max-height: min(820px, calc(100vh - 36px));
      overflow: auto;
      box-shadow: 0 24px 64px rgba(23, 32, 43, .24);
    }

    .section {
      display: grid;
      gap: 16px;
      padding: 18px;
      border: 1px solid var(--line);
      border-radius: 14px;
      background: var(--panel);
      min-height: 0;
    }

    .section-head {
      display: grid;
      grid-template-columns: 1fr auto;
      gap: 14px;
      align-items: center;
    }

    h1, h2, h3, p {
      margin: 0;
    }

    h2 {
      font-size: 20px;
      line-height: 1.2;
      font-weight: 950;
    }

    h3 {
      font-size: 16px;
      line-height: 1.2;
      font-weight: 900;
    }

    .hint {
      color: var(--muted);
      font-size: 13px;
      line-height: 1.45;
      font-weight: 750;
    }








    .ghost-btn {
      min-height: 40px;
      border: 1px solid var(--line);
      border-radius: 10px;
      padding: 0 14px;
      background: var(--panel);
      color: var(--blue);
      cursor: pointer;
      font-weight: 900;
    }

    .options-control {
      display: flex;
      gap: 12px;
      flex-wrap: wrap;
    }

    /* userqa #7: option toggle 시각을 carddeck 의 deck-option 과 통일.
       carddeck 의 `deck-option__switch` 와 동일한 iOS-style toggle. */
    .option-toggle {
      display: flex;
      align-items: center;
      gap: 10px;
      padding: 10px 12px;
      border: 1px solid var(--line);
      border-radius: 10px;
      background: var(--soft);
      cursor: pointer;
      user-select: none;
    }

    .option-toggle__label {
      flex: 1;
      font-size: 13px;
      font-weight: 800;
      color: var(--ink);
    }

    .option-switch {
      position: relative;
      width: 42px;
      height: 24px;
      flex: none;
      background: var(--line);
      border-radius: 999px;
      transition: background 0.14s;
      border: none;
      cursor: pointer;
      padding: 0;
    }

    .option-switch::after {
      content: "";
      position: absolute;
      top: 3px;
      left: 3px;
      width: 18px;
      height: 18px;
      background: #fff;
      border-radius: 50%;
      transition: transform 0.14s;
      box-shadow: 0 1px 3px rgba(0,0,0,0.25);
    }

    .option-switch[aria-checked="true"] { background: var(--blue); }
    .option-switch[aria-checked="true"]::after { transform: translateX(18px); }

    /* ---------------------------------------------------------------------
       Phase 4 blueprint §4-5: Master-Detail lesson screen.
       Default CSS is the fallback (vertical stack, horizontal day row).
       Primary layout is applied inside the media query below.
       --------------------------------------------------------------------- */

    .lesson-screen {
      display: grid;
      gap: 14px;
      min-height: 0;
    }

    .lesson-screen__day {
      display: flex;
      flex-direction: row;
      gap: 8px;
      overflow-x: auto;
      padding: 2px;
    }

    .lesson-screen__detail {
      display: grid;
      gap: 12px;
      min-height: 0;
      align-content: start;
    }

    .lesson-screen__action {
      display: grid;
      gap: 10px;
      grid-template-columns: minmax(0, 1fr) auto;
      align-items: center;
      padding-top: 6px;
      border-top: 1px solid var(--line);
    }











    .lesson-detail-head {
      display: grid;
      gap: 4px;
    }

    .lesson-detail-head__title-row {
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 10px;
    }

    .lesson-detail-summary {
      color: var(--muted);
      font-size: 12px;
      font-weight: 800;
    }













    .action-summary {
      display: grid;
      gap: 4px;
      min-width: 0;
    }

    .action-summary__text {
      color: var(--muted);
      font-size: 13px;
      font-weight: 850;
      overflow-wrap: anywhere;
    }

    .action-inline-error {
      color: var(--red);
      font-size: 13px;
      font-weight: 900;
    }

    .action-buttons {
      display: grid;
      grid-auto-flow: column;
      gap: 10px;
    }

    .btn-primary {
      min-height: 44px;
      min-width: 140px;
      border: 1px solid var(--green);
      border-radius: 10px;
      padding: 0 18px;
      background: var(--green);
      color: #fff;
      cursor: pointer;
      font-size: 15px;
      font-weight: 950;
    }

    .btn-secondary {
      min-height: 44px;
      border: 1px solid var(--line);
      border-radius: 10px;
      padding: 0 16px;
      background: var(--panel);
      color: var(--ink);
      cursor: pointer;
      font-size: 14px;
      font-weight: 900;
    }

    .btn-secondary--compact {
      min-height: 36px;
      padding: 0 12px;
      font-size: 13px;
    }

    .template-action-row {
      display: grid;
      grid-template-columns: minmax(0, 1fr) auto;
      align-items: center;
      gap: 10px;
      padding-top: 6px;
      border-top: 1px solid var(--line);
    }

    /* ---------------------------------------------------------------------
       Modal styles (unchanged from Phase 3).
       --------------------------------------------------------------------- */

    .modal-backdrop {
      position: fixed;
      inset: 0;
      display: none;
      place-items: center;
      padding: 18px;
      background: rgba(23, 32, 43, .42);
      z-index: 10;
    }

    .modal-backdrop.open {
      display: grid;
    }

    .modal {
      width: min(760px, 100%);
      max-height: min(820px, calc(100vh - 36px));
      overflow: auto;
      display: grid;
      gap: 16px;
      padding: 22px;
      border: 1px solid var(--line);
      border-radius: 14px;
      background: var(--panel);
      box-shadow: 0 24px 64px rgba(23, 32, 43, .24);
    }

    .modal-head {
      display: grid;
      grid-template-columns: 1fr auto;
      gap: 12px;
      align-items: start;
    }

    .modal-head strong {
      display: block;
      font-size: 22px;
      line-height: 1.2;
      font-weight: 950;
    }

    .modal-head span {
      display: block;
      margin-top: 4px;
      color: var(--muted);
      font-size: 13px;
      font-weight: 750;
    }

    .field {
      display: grid;
      gap: 7px;
    }

    label {
      color: var(--muted);
      font-size: 12px;
      font-weight: 950;
    }

    input[type="text"], select {
      min-height: 44px;
      width: 100%;
      border: 1px solid var(--line);
      border-radius: 9px;
      padding: 0 12px;
      background: var(--panel);
      color: var(--ink);
      font-weight: 850;
    }

    .modal-grid {
      display: grid;
      grid-template-columns: repeat(2, minmax(0, 1fr));
      gap: 12px;
    }





    .modal-actions {
      display: grid;
      grid-template-columns: 1fr auto auto;
      gap: 10px;
      align-items: center;
    }

    .primary-action {
      min-height: 44px;
      border: 1px solid var(--green);
      border-radius: 9px;
      padding: 0 15px;
      background: var(--green);
      color: #fff;
      cursor: pointer;
      font-weight: 950;
    }

    /* ---------------------------------------------------------------------
       Phase 4 blueprint §4: primary layout override for desktop / tablet
       landscape. 1024x600+ must show the lesson selection without body
       scroll. min-height: 0 lets the inner grid shrink correctly.
       --------------------------------------------------------------------- */
    @media (min-width: 1024px) and (min-height: 600px) {
      .page {
        height: 100vh;
        height: 100svh;
        overflow: hidden;
      }

      main {
        overflow: hidden;
      }

      .lesson-screen {
        grid-template-columns: 260px minmax(0, 1fr);
        grid-template-rows: minmax(0, 1fr) auto;
        gap: 14px;
        height: 100%;
        overflow: hidden;
      }

      .lesson-screen__day {
        grid-column: 1;
        grid-row: 1 / span 2;
        flex-direction: column;
        flex-wrap: nowrap;
        overflow-x: visible;
        overflow-y: auto;
        gap: 6px;
        padding: 4px;
      }

      .lesson-screen__detail {
        grid-column: 2;
        grid-row: 1;
        grid-template-rows: auto auto minmax(0, 1fr);
        overflow: hidden;
      }

      .lesson-grid {
        min-height: 0;
        overflow-y: auto;
        align-content: start;
        padding-right: 2px;
      }

      .lesson-screen__action {
        grid-column: 2;
        grid-row: 2;
        border-top: 1px solid var(--line);
      }

    }

    /* Narrow viewports keep the existing single-column collapse for the
       template list / modal grid / action buttons. */
    @media (max-width: 720px) {
      .summary {
        grid-template-columns: 1fr;
      }

      .template-list, .modal-grid, .builder-row, .modal-actions {
        grid-template-columns: 1fr;
      }

      main {
        padding: 14px;
      }

      .action-buttons {
        grid-auto-flow: row;
      }

      .lesson-screen__action {
        grid-template-columns: 1fr;
      }

      .btn-primary, .btn-secondary {
        width: 100%;
        min-width: 0;
      }

      .template-action-row {
        grid-template-columns: 1fr;
      }
    }

    /* ---------------------------------------------------------------------
       Phase 1 (prototyping3) — Lesson detail modal + lesson-card detail
       trigger. The trigger lives inside the existing lesson-card button,
       so callers can either toggle the lesson (card body) or open the
       modal (the small "전체보기 →" affordance).
       --------------------------------------------------------------------- */






































    @media (max-width: 640px) {

    }

    /* userqa: 카드덱에 담기 모달. 기존엔 CSS 가 0 건이라 hidden 해제 시
       페이지 하단에 일반 block 으로 흘러나왔음. 시각은 lesson-detail-scrim
       패턴 그대로 차용한 fixed overlay. */
    .deck-add-scrim {
      position: fixed;
      inset: 0;
      background: rgba(20, 30, 45, 0.5);
      display: grid;
      place-items: center;
      padding: 24px;
      z-index: 70;
    }

    .deck-add-scrim[hidden] {
      display: none;
    }

    .deck-add-modal {
      width: min(520px, 96vw);
      max-height: 88vh;
      background: var(--panel);
      border-radius: 16px;
      display: flex;
      flex-direction: column;
      overflow: hidden;
      box-shadow: 0 20px 60px rgba(0, 0, 0, 0.18);
    }

    .deck-add-modal__head {
      padding: 18px 20px 14px;
      border-bottom: 1px solid var(--line);
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 12px;
    }

    .deck-add-modal__head h3 {
      margin: 0;
      font-size: 16px;
      font-weight: 900;
      color: var(--ink);
    }

    .deck-add-modal__close {
      border: none;
      background: transparent;
      color: var(--muted);
      font-size: 18px;
      width: 32px;
      height: 32px;
      border-radius: 8px;
      cursor: pointer;
    }
    .deck-add-modal__close:hover { background: var(--soft); color: var(--ink); }

    .deck-add-modal__modes {
      display: flex;
      gap: 8px;
      padding: 12px 20px 0;
    }

    .deck-add-modal__mode {
      flex: 1;
      padding: 8px 12px;
      border: 1px solid var(--line);
      background: var(--soft);
      color: var(--muted);
      border-radius: 10px;
      font-size: 13px;
      font-weight: 800;
      cursor: pointer;
    }
    .deck-add-modal__mode[aria-pressed="true"] {
      background: var(--blue);
      color: #fff;
      border-color: var(--blue);
    }

    .deck-add-modal__seed-note {
      margin: 12px 20px 0;
      padding: 8px 12px;
      background: #eef4ff;
      color: var(--blue);
      border-radius: 8px;
      font-size: 12px;
      font-weight: 700;
    }
    .deck-add-modal__seed-note[hidden] { display: none; }

    .deck-add-modal__body {
      flex: 1;
      overflow-y: auto;
      padding: 16px 20px;
      display: flex;
      flex-direction: column;
      gap: 12px;
    }

    .deck-add-modal__deck-list {
      display: flex;
      flex-direction: column;
      gap: 6px;
    }

    .deck-add__radio {
      display: flex;
      align-items: center;
      gap: 10px;
      padding: 10px 12px;
      border: 1px solid var(--line);
      border-radius: 10px;
      background: var(--soft);
      cursor: pointer;
      font-size: 13px;
      font-weight: 700;
    }
    .deck-add__radio:hover { border-color: var(--blue); }
    .deck-add__radio input { cursor: pointer; }

    .deck-add__empty {
      padding: 16px;
      text-align: center;
      color: var(--muted);
      font-size: 12px;
      font-weight: 700;
    }

    .deck-add-modal__new-name-label {
      display: flex;
      flex-direction: column;
      gap: 6px;
      font-size: 12px;
      font-weight: 800;
      color: var(--muted);
    }
    .deck-add-modal__new-name {
      padding: 10px 12px;
      border: 1px solid var(--line);
      border-radius: 10px;
      font-size: 14px;
      font-weight: 700;
      color: var(--ink);
      background: var(--panel);
    }
    .deck-add-modal__new-name:focus {
      outline: none;
      border-color: var(--blue);
      background: var(--soft);
    }
    .deck-add-modal__new-name[hidden] { display: none; }

    .deck-add-modal__new-name-hint {
      font-size: 11px;
      color: var(--muted);
      font-weight: 700;
    }
    .deck-add-modal__new-name-hint[hidden] { display: none; }

    .deck-add-modal__preview {
      margin: 0 20px;
      padding: 8px 12px;
      background: var(--soft);
      border-radius: 8px;
      font-size: 12px;
      color: var(--muted);
      font-weight: 700;
    }

    .deck-add-modal__error {
      margin: 0 20px;
      padding: 8px 12px;
      background: #fee2e2;
      color: var(--danger);
      border-radius: 8px;
      font-size: 12px;
      font-weight: 800;
    }
    .deck-add-modal__error[hidden] { display: none; }

    .deck-add-modal__foot {
      padding: 14px 18px;
      border-top: 1px solid var(--line);
      display: flex;
      justify-content: flex-end;
      gap: 8px;
    }

    @media (max-width: 640px) {
      .deck-add-scrim { padding: 0; }
      .deck-add-modal {
        width: 100vw;
        max-height: 100vh;
        height: 100vh;
        border-radius: 0;
      }
    }
