/* 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: minmax(0, 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: flex;
      flex-wrap: wrap;
      justify-content: flex-end;
      gap: 8px;
      min-width: 0;
    }

    .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;
      /* Never let a single long chip (e.g. a verbose template summary) push
         past the viewport — truncate instead of clipping the row off-screen. */
      max-width: 100%;
      overflow: hidden;
      text-overflow: ellipsis;
    }

    /* 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);
    }

    /* ---------------------------------------------------------------------
       Single-page 4-step accordion (접기형 setup). Replaces the 2-screen
       wizard; reuses the same render hooks. The desktop wizard pinned the
       page to a fixed-height master-detail grid — the accordion instead
       stacks vertically and lets the page scroll.
       --------------------------------------------------------------------- */
    main.accordion {
      display: grid;
      gap: 12px;
      grid-auto-rows: min-content;
      align-content: start;
      overflow: visible;
    }

    .page:has(main.accordion) {
      height: auto;
      min-height: 100vh;
      overflow: visible;
    }

    .acc {
      border: 1px solid var(--line);
      border-radius: 14px;
      background: var(--panel);
      overflow: hidden;
    }

    .acc[open] {
      box-shadow: 0 10px 30px rgba(23, 32, 43, .08);
    }

    .acc__summary {
      display: flex;
      align-items: center;
      gap: 12px;
      padding: 16px 18px;
      cursor: pointer;
      list-style: none;
      font-size: 17px;
      font-weight: 950;
    }

    .acc__summary::-webkit-details-marker { display: none; }

    .acc__num {
      display: grid;
      place-items: center;
      width: 26px;
      height: 26px;
      flex: none;
      border-radius: 50%;
      background: var(--soft);
      color: var(--muted);
      font-size: 14px;
      font-weight: 950;
    }

    .acc[open] .acc__num { background: var(--blue); color: #fff; }

    .acc__title { flex: none; }

    .acc__pick {
      flex: 1;
      min-width: 0;
      text-align: right;
      color: var(--muted);
      font-size: 13px;
      font-weight: 800;
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
    }

    .acc__chevron {
      flex: none;
      color: var(--muted);
      transition: transform .15s;
    }

    .acc[open] .acc__chevron { transform: rotate(180deg); }

    .acc__body {
      display: grid;
      gap: 14px;
      padding: 0 18px 18px;
    }

    .acc__head-actions {
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 12px;
      flex-wrap: wrap;
    }

    .acc__advance {
      display: flex;
      justify-content: flex-end;
      padding-top: 12px;
      border-top: 1px solid var(--line);
    }

    /* Category list: one full-width item per row (no jagged wrap), and the
       per-day selected-count badge is hidden — it isn't useful here. */
    .acc .lesson-screen__day {
      flex-direction: column;
      flex-wrap: nowrap;
      overflow: visible;
      gap: 8px;
    }

    .acc .day-item {
      width: 100%;
    }

    .acc .day-item__badge {
      display: none;
    }

    /* §④ inline sentence list (filtered preview). */
    .filter-sentence-list {
      display: grid;
      gap: 12px;
      max-height: 420px;
      overflow-y: auto;
    }

    .fsl__summary {
      margin: 0;
      color: var(--muted);
      font-size: 13px;
      font-weight: 850;
    }

    .fsl__summary--empty {
      color: var(--red);
    }

    .fsl__excluded {
      color: var(--muted);
      font-weight: 700;
    }

    .fsl__group {
      display: grid;
      gap: 6px;
    }

    .fsl__group-head {
      display: flex;
      align-items: center;
      gap: 6px;
      font-size: 13px;
      font-weight: 900;
      color: var(--ink);
    }

    .fsl__group-n {
      color: var(--muted);
      font-weight: 800;
      font-size: 12px;
    }

    .fsl__list {
      list-style: none;
      margin: 0;
      padding: 0;
      display: grid;
      gap: 6px;
    }

    .fsl__row {
      display: flex;
      align-items: flex-start;
      gap: 10px;
      padding: 8px 10px;
      border: 1px solid var(--line);
      border-radius: 8px;
      background: var(--soft);
    }

    .fsl__row.is-deselected {
      opacity: 0.5;
    }

    .fsl__check {
      flex: none;
      display: flex;
      align-items: center;
      padding-top: 2px;
      cursor: pointer;
    }

    .fsl__check input {
      width: 18px;
      height: 18px;
      accent-color: var(--blue);
      cursor: pointer;
    }

    .fsl__row .fsl__text {
      flex: 1;
    }

    .fsl__text {
      display: grid;
      gap: 2px;
      min-width: 0;
    }

    .fsl__text strong {
      font-size: 14px;
      font-weight: 800;
      color: var(--ink);
    }

    .fsl__text span {
      font-size: 13px;
      color: var(--muted);
      font-weight: 700;
    }

    .fsl__meta {
      display: flex;
      flex-wrap: wrap;
      gap: 4px;
      flex: none;
      justify-content: flex-end;
    }

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

    .fsl__tag--d1 { color: #1f8a44; border-color: #b6e2c4; }
    .fsl__tag--d2 { color: #a8730a; border-color: #f0d9a8; }
    .fsl__tag--d3 { color: #b3331f; border-color: #f0c0b6; }

    /* ---------------------------------------------------------------------
       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 {
        flex-direction: column;
        align-items: stretch;
      }

      .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;
      }
    }

    /* ---------------------------------------------------------------------
       Tier 1 — sentence meta filter (button + modal + chips).
       --------------------------------------------------------------------- */
    .filter-open-btn {
      display: inline-flex;
      align-items: center;
      gap: 8px;
      padding: 10px 14px;
      border: 1.5px solid var(--line);
      border-radius: 10px;
      background: var(--panel);
      color: var(--ink);
      font-size: 13px;
      font-weight: 800;
      cursor: pointer;
    }
    .filter-open-btn:hover { border-color: var(--blue); }
    .filter-open-btn.is-active {
      border-color: var(--blue);
      color: var(--blue);
      background: var(--selected);
    }
    .filter-open-btn__badge {
      min-width: 18px;
      padding: 0 6px;
      border-radius: 999px;
      background: var(--blue);
      color: #fff;
      font-size: 11px;
      font-weight: 800;
      text-align: center;
    }

    .filter-scrim {
      position: fixed;
      inset: 0;
      background: rgba(20, 30, 45, 0.5);
      display: grid;
      place-items: center;
      padding: 24px;
      z-index: 60;
    }
    .filter-scrim[hidden] { display: none; }

    .filter-modal {
      width: min(560px, 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.22);
    }
    .filter-modal__head {
      padding: 18px 20px 12px;
      border-bottom: 1px solid var(--line);
      display: flex;
      align-items: flex-start;
      justify-content: space-between;
      gap: 12px;
    }
    .filter-modal__head h3 { margin: 0; font-size: 18px; font-weight: 900; }
    .filter-modal__sub { margin: 3px 0 0; font-size: 12px; color: var(--muted); font-weight: 600; }
    .filter-modal__close {
      border: 0;
      background: transparent;
      font-size: 20px;
      line-height: 1;
      cursor: pointer;
      color: var(--muted);
    }
    .filter-modal__body { padding: 16px 20px; overflow: auto; }

    .filter-group { margin-bottom: 16px; }
    .filter-group:last-child { margin-bottom: 0; }
    .filter-group[hidden] { display: none; }
    .filter-group__label {
      font-size: 12px;
      font-weight: 850;
      color: var(--muted);
      margin-bottom: 8px;
      display: flex;
      align-items: center;
      gap: 6px;
    }
    .filter-group__tag {
      font-size: 10px;
      background: #fff3df;
      color: #855e1a;
      border: 1px solid var(--warning-border);
      border-radius: 5px;
      padding: 1px 6px;
    }
    .filter-group__chips { display: flex; flex-wrap: wrap; gap: 8px; }

    .filter-chip {
      display: inline-flex;
      align-items: center;
      gap: 7px;
      border: 1.5px solid var(--line);
      background: var(--panel);
      color: var(--ink);
      border-radius: 999px;
      padding: 8px 14px;
      font-size: 13px;
      font-weight: 800;
      cursor: pointer;
    }
    .filter-chip:hover:not(.is-disabled) { border-color: var(--blue); }
    .filter-chip.is-active {
      background: var(--selected);
      border-color: var(--blue);
      color: var(--blue);
    }
    .filter-chip.is-disabled { opacity: 0.45; cursor: not-allowed; }
    .filter-chip__n { font-size: 11px; color: var(--muted); font-weight: 800; }
    .filter-chip.is-active .filter-chip__n { color: var(--blue); }
    .filter-chip__dot { width: 8px; height: 8px; border-radius: 50%; }
    .filter-chip__dot--d1 { background: var(--green); }
    .filter-chip__dot--d2 { background: #c98a1a; }
    .filter-chip__dot--d3 { background: var(--red); }

    .filter-modal__foot {
      padding: 14px 20px;
      border-top: 1px solid var(--line);
      background: var(--soft);
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 12px;
    }
    .filter-modal__count { font-size: 13px; font-weight: 800; color: var(--muted); }
    .filter-modal__count b { color: var(--ink); font-size: 16px; }
    .filter-modal__excluded { color: var(--muted); font-weight: 700; }
    .filter-modal__actions { display: flex; gap: 8px; }

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