@charset "UTF-8";

/* ============================================================================
 * theme.css — 작가 × 작가 디자인 토큰 단일 소스
 *
 * 이 파일이 모든 색/간격/타이포/모션 토큰의 유일한 정의처입니다.
 * style.css / workspace.css / readability.css 의 :root 블록은 제거되었고
 * 기존 코드가 참조하던 토큰 이름은 아래 "호환 별칭" 섹션에서 계속 제공됩니다.
 *
 * CSP: default-src 'self' — 외부 폰트/CDN 금지. 시스템 폰트 스택만 사용합니다.
 * ========================================================================== */

:root {
  color-scheme: light;
  --workspace-max-width: 1280px;
  --workspace-gutter: clamp(16px, 2.4vw, 36px);

  /* ---- Font (시스템 폰트만) ---- */
  --font-sans: "Pretendard Variable", "Pretendard", -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Noto Sans KR", "Malgun Gothic", "Segoe UI", sans-serif;
  --font-serif-ko: "Noto Serif KR", "KoPub Batang", "AppleMyungjo", "Batang", Georgia, serif;
  --font-mono: "SFMono-Regular", Consolas, "Liberation Mono", ui-monospace, monospace;

  /* ---- Type scale ---- */
  --fs-100: .6875rem;
  --fs-200: .75rem;
  --fs-300: .875rem;
  --fs-400: 1rem;
  --fs-500: 1.125rem;
  --fs-600: 1.25rem;
  --fs-700: 1.5rem;
  --fs-800: 1.875rem;
  --fs-900: 2.25rem;

  /* ---- Korean typography ---- */
  --lh-tight: 1.3;
  --lh-ui: 1.5;
  --lh-base: 1.7;
  --lh-prose: 1.9;
  --ls-tight: -.025em;
  --ls-ui: -.012em;
  --ls-body: -.005em;
  --ls-prose: 0;
  --fw-regular: 400;
  --fw-medium: 500;
  --fw-semibold: 600;
  --fw-bold: 700;

  /* ---- Spacing (4px base) ---- */
  --space-1: .25rem;
  --space-2: .5rem;
  --space-3: .75rem;
  --space-4: 1rem;
  --space-5: 1.25rem;
  --space-6: 1.5rem;
  --space-8: 2rem;
  --space-10: 2.5rem;
  --space-12: 3rem;
  --space-16: 4rem;
  --space-20: 5rem;
  --space-24: 6rem;

  /* ---- Layout ---- */
  --sidebar-width: clamp(220px, 18vw, 280px);
  --sidebar-collapsed-width: 4rem;
  --context-width: 20rem;
  --header-height: 3.75rem;
  --measure: 34em;
  --prose-measure: var(--measure);

  /* ---- Radii ---- */
  --radius-sm: .375rem;
  --radius-md: .625rem;
  --radius-lg: .875rem;
  --radius-xl: 1.25rem;
  --radius-pill: 999px;

  /* ---- Shadow ---- */
  --shadow-1: 0 1px 2px rgb(24 25 28 / 6%);
  --shadow-2: 0 2px 8px rgb(24 25 28 / 8%);
  --shadow-3: 0 8px 24px rgb(24 25 28 / 12%);
  --shadow-4: 0 18px 48px rgb(24 25 28 / 18%);

  /* ---- Motion ---- */
  --duration-fast: 120ms;
  --duration-normal: 200ms;
  --duration-slow: 320ms;
  --ease-standard: cubic-bezier(.2, 0, 0, 1);
  --ease-emphasized: cubic-bezier(.2, 0, 0, 1.2);

  /* ---- z-index ---- */
  --z-sticky: 20;
  --z-toolbar: 30;
  --z-overlay: 80;
  --z-dialog: 90;
  --z-toast: 100;

  /* ---- Color: surfaces — 원고 종이와 흰 카드 ---- */
  --bg: #f7f7f5;
  --surface: #ffffff;
  --surface-2: #f4f4f1;
  --surface-muted: #eeedea;
  --surface-sunken: #fafaf8;
  --overlay: rgb(23 23 23 / 55%);

  /* ---- Color: text ---- */
  --ink: #171717;
  --ink-soft: #393937;
  --muted: #626260;
  --ink-inverse: #ffffff;

  /* ---- Color: lines ---- */
  --line: #dededa;
  --line-strong: #bcbcb6;

  /* ---- Color: brand — 교정 표시를 닮은 레드 ---- */
  --primary: #d9272e;
  --primary-hover: #b91f26;
  --primary-active: #a31b22;
  --primary-soft: #fcebec;
  --primary-ink: #ffffff;
  --accent: #b91f26;

  /* ---- Color: status ---- */
  --danger: #b3392f;
  --danger-hover: #962d25;
  --danger-soft: #fdeceb;
  --success: #1f7a55;
  --success-soft: #e6f5ee;
  --warning: #805000;
  --warning-soft: #fff5df;
  --info: #0969b4;
  --info-soft: #e8f2fc;

  /* ---- Color: interaction — 레드와 구분되는 파란 키보드 포커스 ---- */
  --focus: #2563eb;
  --focus-ring: rgb(37 99 235 / 25%);
  --selection: rgb(37 99 235 / 20%);

  /* 어두운/채도 높은 면 위에 올라가는 텍스트 */
  --on-dark: #ffffff;

  /* ---- Color: navigation shell — 하얀 종이 옆 여백 ---- */
  --sidebar: #ffffff;
  --sidebar-ink: #171717;
  --sidebar-muted: #626260;
  --sidebar-active: #fcebec;
  --sidebar-line: #dededa;
  --sidebar-danger: #a31b22;
  --sidebar-danger-bg: #fcebec;

  /* ======================================================================
   * 기존 파일 호환 별칭 — 절대 제거 금지.
   * style.css / workspace.css / readability.css / review-page.css /
   * admin-api-key.css 가 참조하던 이름을 그대로 유지합니다.
   * ==================================================================== */
  --paper: var(--bg);
  --white: var(--surface);
  --field-border: var(--line-strong);
  --lime: var(--primary-soft);
  --lime-dark: var(--primary-hover);
  --green: var(--primary);
  --teal-soft: var(--primary-soft);
  --radius: var(--radius-lg);
  --shadow: var(--shadow-2);

  /* ---- 본문 읽기 설정 기본값 (JS 가 data-* 로 토글) ---- */
  --reading-size: 1.0625rem;
  --reading-face: var(--font-sans);
}

/* ---------------------------------------------------------------------------
 * 다크 테마
 * 1) 시스템 다크 + 사용자가 라이트를 명시하지 않은 경우
 * 2) 수동 지정 :root[data-theme="dark"]
 * 두 경우 모두 같은 팔레트를 적용합니다.
 * ------------------------------------------------------------------------ */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;

    --bg: #151416;
    --surface: #211f21;
    --surface-2: #292629;
    --surface-muted: #332d2f;
    --surface-sunken: #1b191b;
    --overlay: rgb(0 0 0 / 68%);

    --ink: #f5f2f2;
    --ink-soft: #ded5d6;
    --muted: #bcb0b2;
    --ink-inverse: #151416;

    --line: #40393b;
    --line-strong: #665b5d;

    --primary: #e26067;
    --primary-hover: #f0757b;
    --primary-active: #d9575f;
    --primary-soft: #3d2226;
    --primary-ink: #21191a;
    --accent: #f0757b;

    --danger: #f08a7e;
    --danger-hover: #f7a094;
    --danger-soft: #3a1f1c;
    --success: #6fcda2;
    --success-soft: #143024;
    --warning: #e8b964;
    --warning-soft: #332714;
    --info: #7cc0f0;
    --info-soft: #14283a;

    --focus: #8bb2ff;
    --focus-ring: rgb(139 178 255 / 30%);
    --selection: rgb(139 178 255 / 28%);

    --sidebar: #1b191b;
    --sidebar-ink: #f5f2f2;
    --sidebar-muted: #bcb0b2;
    --sidebar-active: #39272a;
    --sidebar-line: #40393b;
    --sidebar-danger: #ffb5b5;
    --sidebar-danger-bg: #542c36;

    --shadow-1: 0 1px 2px rgb(0 0 0 / 40%);
    --shadow-2: 0 2px 10px rgb(0 0 0 / 48%);
    --shadow-3: 0 10px 28px rgb(0 0 0 / 56%);
    --shadow-4: 0 20px 54px rgb(0 0 0 / 64%);
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;

  --bg: #151416;
  --surface: #211f21;
  --surface-2: #292629;
  --surface-muted: #332d2f;
  --surface-sunken: #1b191b;
  --overlay: rgb(0 0 0 / 68%);

  --ink: #f5f2f2;
  --ink-soft: #ded5d6;
  --muted: #bcb0b2;
  --ink-inverse: #151416;

  --line: #40393b;
  --line-strong: #665b5d;

  --primary: #e26067;
  --primary-hover: #f0757b;
  --primary-active: #d9575f;
  --primary-soft: #3d2226;
  --primary-ink: #21191a;
  --accent: #f0757b;

  --danger: #f08a7e;
  --danger-hover: #f7a094;
  --danger-soft: #3a1f1c;
  --success: #6fcda2;
  --success-soft: #143024;
  --warning: #e8b964;
  --warning-soft: #332714;
  --info: #7cc0f0;
  --info-soft: #14283a;

  --focus: #8bb2ff;
  --focus-ring: rgb(139 178 255 / 30%);
  --selection: rgb(139 178 255 / 28%);

  --sidebar: #1b191b;
  --sidebar-ink: #f5f2f2;
  --sidebar-muted: #bcb0b2;
  --sidebar-active: #39272a;
  --sidebar-line: #40393b;
  --sidebar-danger: #ffb5b5;
  --sidebar-danger-bg: #542c36;

  --shadow-1: 0 1px 2px rgb(0 0 0 / 40%);
  --shadow-2: 0 2px 10px rgb(0 0 0 / 48%);
  --shadow-3: 0 10px 28px rgb(0 0 0 / 56%);
  --shadow-4: 0 20px 54px rgb(0 0 0 / 64%);
}

/* 라이트 강제 지정 (시스템이 다크여도 라이트 유지) */
:root[data-theme="light"] { color-scheme: light; }

/* ---------------------------------------------------------------------------
 * 본문 읽기 설정 — JS 가 <html> 에 data-reading-size / data-reading-face 를 지정
 * ------------------------------------------------------------------------ */
:root[data-reading-size="small"]  { --reading-size: .9375rem; }
:root[data-reading-size="normal"] { --reading-size: 1.0625rem; }
:root[data-reading-size="large"]  { --reading-size: 1.25rem; }
:root[data-reading-size="xlarge"] { --reading-size: 1.4375rem; }
:root[data-reading-face="sans"]   { --reading-face: var(--font-sans); }
:root[data-reading-face="serif"]  { --reading-face: var(--font-serif-ko); }

::selection { background: var(--selection); color: var(--ink); }

/* 통일된 포커스 링 */
:is(a, button, summary, input, textarea, select, [tabindex]):focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 3px;
  border-radius: var(--radius-sm);
}

/* ---------------------------------------------------------------------------
 * 공용 컴포넌트 프리미티브
 *
 * @layer 로 감싸 두었기 때문에 레이어가 없는 기존 CSS(style.css, readability.css
 * 등)가 항상 우선합니다. 즉 이 블록은 "바닥값"이며 기존 화면을 덮어쓰지 않습니다.
 * 새 컴포넌트(.progress-bar, .skeleton, .segmented, .btn.is-loading …)는 기존
 * 정의가 없으므로 이 값이 그대로 적용됩니다.
 * ------------------------------------------------------------------------ */
@layer wxw-primitives {

  /* ---- Button ---- */
  .btn {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    min-height: 2.375rem;
    padding: var(--space-2) var(--space-4);
    border: 1px solid var(--line-strong);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--ink-soft);
    font-size: var(--fs-300);
    font-weight: var(--fw-semibold);
    line-height: var(--lh-ui);
    letter-spacing: var(--ls-ui);
    text-decoration: none;
    white-space: nowrap;
    cursor: pointer;
    transition: background var(--duration-fast) var(--ease-standard),
                border-color var(--duration-fast) var(--ease-standard),
                color var(--duration-fast) var(--ease-standard);
  }
  .btn:hover:not(:disabled) { background: var(--surface-2); border-color: var(--line-strong); color: var(--ink); }
  .btn.primary { background: var(--primary); border-color: var(--primary); color: var(--primary-ink); }
  .btn.primary:hover:not(:disabled) { background: var(--primary-hover); border-color: var(--primary-hover); color: var(--primary-ink); }
  .btn.accent { background: var(--primary-soft); border-color: var(--primary); color: var(--primary); }
  .btn.ghost { background: transparent; border-color: transparent; color: var(--primary); }
  .btn.ghost:hover:not(:disabled) { background: var(--primary-soft); }
  .btn.danger { background: var(--surface); border-color: var(--danger); color: var(--danger); }
  .btn.danger:hover:not(:disabled) { background: var(--danger-soft); border-color: var(--danger-hover); color: var(--danger-hover); }
  .btn.small { min-height: 2rem; padding: var(--space-1) var(--space-3); font-size: var(--fs-200); }
  .btn:disabled, .btn[aria-disabled="true"] { opacity: .55; cursor: not-allowed; }

  /* 로딩 상태: 라벨을 숨기고 내부 스피너를 노출 */
  .btn.is-loading { color: transparent !important; pointer-events: none; }
  .btn.is-loading::after {
    content: '';
    position: absolute;
    inset: 50% auto auto 50%;
    width: 1em;
    height: 1em;
    margin: -.5em 0 0 -.5em;
    border: 2px solid currentcolor;
    border-top-color: transparent;
    border-radius: 50%;
    opacity: .85;
    color: var(--ink-soft);
    animation: wxw-spin .7s linear infinite;
  }
  .btn.primary.is-loading::after { color: var(--primary-ink); }

  /* ---- Surface containers ---- */
  .panel, .card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-1);
  }

  /* ---- Badges ---- */
  .pill, .tag, .chip {
    display: inline-flex;
    align-items: center;
    gap: var(--space-1);
    padding: var(--space-1) var(--space-2);
    border-radius: var(--radius-sm);
    background: var(--surface-muted);
    color: var(--ink-soft);
    font-size: var(--fs-200);
    line-height: var(--lh-ui);
    max-width: 100%;
    overflow-wrap: anywhere;
  }
  .chip { border-radius: var(--radius-pill); }

  /* ---- Field ----
   * 주의: .field 계열은 레이어 밖("레이어 승격 블록")에 정의되어 있습니다.
   * style.css 의 `input,textarea,select{border:…;padding:…;border-radius:…}` 가
   * 레이어 없는 규칙이라, 레이어 안에 두면 단축 border 가 border-color 를 이겨서
   * .field.has-error 의 빨간 테두리가 렌더링되지 않았습니다. 아래로 내려갔습니다. */

  /* ---- Dialog ---- */
  .dialog-backdrop { position: fixed; inset: 0; z-index: var(--z-overlay); display: flex; align-items: center; justify-content: center; padding: var(--space-6); background: var(--overlay); }
  .dialog {
    position: relative;
    z-index: var(--z-dialog);
    max-height: calc(100vh - var(--space-12));
    overflow: auto;
    border: 1px solid var(--line);
    border-radius: var(--radius-xl);
    background: var(--surface);
    color: var(--ink);
    box-shadow: var(--shadow-4);
  }

  /* ---- Toast ---- */
  .toast-container { position: fixed; right: var(--space-6); bottom: var(--space-6); z-index: var(--z-toast); display: flex; flex-direction: column; gap: var(--space-2); max-width: 26rem; }
  .toast {
    padding: var(--space-3) var(--space-5);
    border-radius: var(--radius-md);
    background: var(--sidebar);
    color: var(--sidebar-ink);
    font-size: var(--fs-300);
    line-height: var(--lh-base);
    box-shadow: var(--shadow-3);
    overflow-wrap: anywhere;
  }

  /* ---- Empty state ---- */
  .empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: var(--space-3);
    padding: var(--space-10) var(--space-6);
    border: 1px dashed var(--line-strong);
    border-radius: var(--radius-lg);
    background: var(--surface-sunken);
    color: var(--ink-soft);
    text-align: center;
  }
  .empty-state p { max-width: 28rem; color: var(--muted); line-height: var(--lh-prose); }

  /* ---- Spinner ---- */
  .spinner {
    display: inline-block;
    flex-shrink: 0;
    width: 1.125rem;
    height: 1.125rem;
    border: 2px solid var(--line-strong);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: wxw-spin .8s linear infinite;
  }

  /* ---- Skeleton ---- */
  .skeleton {
    border-radius: var(--radius-sm);
    background: linear-gradient(90deg, var(--surface-2) 25%, var(--surface-muted) 37%, var(--surface-2) 63%);
    background-size: 400% 100%;
    animation: wxw-shimmer 1.4s ease infinite;
    color: transparent;
    pointer-events: none;
    user-select: none;
  }

  /* ---- Progress bar (AI 생성 진행 표시) ---- */
  .progress-bar {
    position: relative;
    overflow: hidden;
    width: 100%;
    height: .375rem;
    border-radius: var(--radius-pill);
    background: var(--surface-muted);
  }
  .progress-bar > .progress-bar-value,
  .progress-bar > span {
    display: block;
    height: 100%;
    width: var(--progress, 0%);
    border-radius: inherit;
    background: var(--primary);
    transition: width var(--duration-normal) var(--ease-standard);
  }
  .progress-bar.is-indeterminate > .progress-bar-value,
  .progress-bar.is-indeterminate > span,
  .progress-bar.is-indeterminate::after {
    position: absolute;
    inset: 0 auto 0 0;
    width: 40%;
    border-radius: inherit;
    background: var(--primary);
    animation: wxw-indeterminate 1.2s var(--ease-standard) infinite;
  }
  .progress-bar.is-indeterminate::after { content: ''; }
  .progress-bar.is-indeterminate:has(> span)::after,
  .progress-bar.is-indeterminate:has(> .progress-bar-value)::after { content: none; }

  /* ---- Segmented control / tabs ----
   * 주의: .segmented 계열도 레이어 밖("레이어 승격 블록")에 정의되어 있습니다.
   * style.css 의 레이어 없는 `button{color:inherit}` / `a{color:inherit}` 가
   * 레이어 안의 color 를 항상 이겨서, 활성 항목이 --primary 배경 위에 --ink 글자가
   * 되는 대비 2.1~2.3:1 상태였습니다. 아래로 내려갔습니다. */
}

/* ===========================================================================
 * 레이어 승격 블록 (@layer 밖)
 *
 * 왜 필요한가
 *   CSS 캐스케이드에서 "레이어에 속한 선언"은 명시도와 무관하게 **항상**
 *   "레이어에 속하지 않은 선언"에게 집니다. style.css 는 레이어가 없고
 *   `button{color:inherit}` · `a{color:inherit}` ·
 *   `input,textarea,select{border:1px solid var(--line);padding:10px 12px;border-radius:8px}`
 *   같은 넓은 요소 선택자를 갖고 있습니다.
 *   그래서 위 @layer 안의 .segmented / .field 선언 중 color · border-color ·
 *   padding · border-radius 가 통째로 사문화됐습니다.
 *
 * 무엇을 꺼냈고 무엇을 남겼는가
 *   꺼냄 : .segmented, .field  — 이 두 컴포넌트는 theme.css 이외의 어떤 CSS
 *          파일에도 정의가 없고, 사용처도 신규 UI(author-style-panel.js,
 *          image-album.js, client.js readingDialog) 뿐이라 기존 화면 회귀가 없습니다.
 *   남김 : .btn .card .panel .pill .tag .dialog .toast .empty-state .spinner
 *          .skeleton .progress-bar — style.css / workspace.css / readability.css 가
 *          레이어 없이 소유하고 있어서, 레이어가 "바닥값" 역할을 계속 해야 합니다.
 *          (점검 결과 이들은 넓은 요소 선택자에 색이 가로채이지 않습니다.
 *           .btn 은 readability.css 가 color 를 모두 지정해 주고 있습니다.)
 *   예외 : .chip 만 어떤 파일에도 color 지정이 없어 <button class="chip"> 이
 *          `button{color:inherit}` 에 가로채였으므로 함께 승격합니다.
 *
 * 명시도 설계
 *   여기 규칙은 요소 선택자(0,0,1)를 이기되 뒤따르는 파일의
 *   `input:focus` · `input[readonly]` · `input:disabled`(0,1,1) 와는 동률로 두어
 *   theme.css 가 먼저 실리는 순서 때문에 뒤 파일이 이기도록 했습니다.
 *   → 포커스 링·읽기전용·비활성 표현이 그대로 보존됩니다. !important 는 쓰지 않습니다.
 * ========================================================================= */

/* ---- Segmented control / tabs ---- */
.segmented {
  display: inline-flex;
  flex-wrap: wrap;
  gap: var(--space-1);
  max-width: 100%;
  padding: var(--space-1);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface-2);
}
/* (0,1,1) — style.css `button{color:inherit}` (0,0,1) 을 이깁니다. */
.segmented > button, .segmented > a {
  border: 0;
  border-radius: var(--radius-sm);
  padding: var(--space-2) var(--space-3);
  background: transparent;
  color: var(--ink-soft);
  font: inherit;
  font-size: var(--fs-300);
  font-weight: var(--fw-semibold);
  line-height: var(--lh-ui);
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
}
/* 활성 항목은 hover 로 덮이면 안 되므로 비활성만 hover 합니다. */
.segmented > button:not(.is-active):not([aria-pressed="true"]):not([aria-selected="true"]):hover,
.segmented > a:not(.is-active):not([aria-pressed="true"]):not([aria-selected="true"]):hover {
  background: var(--surface);
  color: var(--ink);
}
/* (0,2,0) — 배경 --primary 와 글자 --primary-ink 가 함께 적용됩니다. (라이트 4.91:1 / 다크 5.01:1) */
.segmented > .is-active,
.segmented > [aria-pressed="true"],
.segmented > [aria-selected="true"] {
  background: var(--primary);
  color: var(--primary-ink);
}
.segmented > .is-active:hover,
.segmented > [aria-pressed="true"]:hover,
.segmented > [aria-selected="true"]:hover {
  background: var(--primary-hover);
  color: var(--primary-ink);
}
.segmented > button:disabled, .segmented > [aria-disabled="true"] { opacity: .55; cursor: not-allowed; }
/* .field 는 display:grid 라 자식이 늘어납니다. inline-flex 의도대로 내용만큼만 차지하게. */
.field > .segmented { justify-self: start; }

/* ---- Field ---- */
.field { display: grid; gap: var(--space-2); margin-bottom: var(--space-4); }
.field > label, .field > .field-label { color: var(--ink); font-size: var(--fs-300); font-weight: var(--fw-semibold); }
/* (0,1,1) — style.css 의 `input,textarea,select`(0,0,1) 단축 border/padding 을 이깁니다. */
.field input, .field textarea, .field select {
  width: 100%;
  min-width: 0;
  padding: var(--space-3);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  line-height: var(--lh-base);
}
/* range / checkbox / radio 는 입력 상자가 아니므로 상자 표현을 되돌립니다. */
.field input[type="range"] {
  height: 1.5rem;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: none;
  accent-color: var(--primary);
  cursor: pointer;
}
.field input[type="checkbox"], .field input[type="radio"] {
  width: auto;
  padding: 0;
  accent-color: var(--primary);
}
.field .hint, .field small { color: var(--muted); font-size: var(--fs-200); line-height: var(--lh-base); }
/* (0,2,1) — `input:focus{border-color:var(--focus)}`(0,1,1) 보다 높아, 포커스 중에도 오류 테두리가 유지됩니다. */
.field.has-error input, .field.has-error textarea, .field.has-error select {
  border-color: var(--danger);
  background: var(--danger-soft);
}
.field.has-error input:focus, .field.has-error textarea:focus, .field.has-error select:focus {
  border-color: var(--danger);
  box-shadow: 0 0 0 3px rgb(179 57 47 / 24%);
}
.field.has-error .hint, .field .error-text { color: var(--danger); }

/* ---- Chip (다른 파일에 color 정의가 없어 <button class="chip"> 이
 *      `button{color:inherit}` 에 가로채였음) ---- */
.chip { color: var(--ink-soft); background: var(--surface-muted); }
/* UA 기본 `2px outset` 테두리 제거는 버튼/링크 칩에만. <span class="chip"> 은
 * 박스 크기가 변하면 기존 화면(집필 화면의 .writing-next-warning)이 2px 밀리므로 제외합니다. */
button.chip, a.chip { border: 1px solid transparent; }

/* ===========================================================================
 * CSS 정의가 없던 신규 클래스 3종
 * ========================================================================= */

/* 작가 스타일 패널 호스트 — client.js projectSettings() 가 만드는 빈 <section>.
 * 안쪽 .author-style-panel(.panel) 은 writing.css 가 그리므로 여기서는 자리와 여백만. */
.author-style-panel-host {
  display: block;
  margin-top: var(--space-6);
}
.author-style-panel-host:empty {
  min-height: 6rem;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius-lg);
  background: var(--surface-sunken);
}
.author-style-panel-host > .author-style-panel { margin: 0; }

/* 슬라이더 행 — <div class="field style-range"><label>라벨 <output>값</output></label><input type=range></div> */
.style-range { gap: var(--space-1); }
.style-range > label {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-3);
}
.style-range output {
  flex: none;
  color: var(--primary);
  font-size: var(--fs-200);
  font-weight: var(--fw-semibold);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
/* 트랙·썸 색은 accent-color 로 토큰을 따릅니다(라이트/다크 자동 전환).
 * appearance:none 없이 동작하므로 브라우저별 썸 크기 회귀 위험이 없습니다. */
.style-range input[type="range"] {
  width: 100%;
  height: 1.5rem;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: none;
  accent-color: var(--primary);
  cursor: pointer;
}
.style-range input[type="range"]:disabled { accent-color: var(--line-strong); cursor: not-allowed; }

/* API 키 안내 배너 — index.html 의 <div id="key-hint" class="warning key-hint" hidden> */
#key-hint {
  display: flex;
  align-items: flex-start;
  gap: var(--space-2);
  margin: var(--space-3) var(--space-6) 0;
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--warning);
  border-radius: var(--radius-md);
  background: var(--warning-soft);
  color: var(--warning);
  font-size: var(--fs-300);
  font-weight: var(--fw-medium);
  line-height: var(--lh-base);
  overflow-wrap: anywhere;
}
#key-hint::before {
  content: '!';
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.25rem;
  height: 1.25rem;
  border-radius: var(--radius-pill);
  background: var(--warning);
  color: var(--warning-soft);
  font-size: var(--fs-200);
  font-weight: var(--fw-bold);
  line-height: 1;
}
/* [hidden] 을 반드시 이기도록 (1,1,0) */
#key-hint[hidden] { display: none; }
@media (max-width: 760px) { #key-hint { margin: var(--space-3) var(--space-4) 0; } }

@keyframes wxw-spin { to { transform: rotate(360deg); } }
@keyframes wxw-shimmer { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }
@keyframes wxw-indeterminate {
  0%   { transform: translateX(-100%); }
  100% { transform: translateX(250%); }
}

/* ---------------------------------------------------------------------------
 * 모션 민감 사용자
 * ------------------------------------------------------------------------ */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
    scroll-behavior: auto !important;
  }
  .spinner, .btn.is-loading::after { animation-duration: 1.2s !important; animation-iteration-count: infinite !important; }
}
