/* 크라우니 계정 · 그램과 같은 기본 꼴 — 색은 --g-* 토큰만(hex 는 토큰 선언 블록 안에서만).
 * 순서: crowny-design.css → _style.css → skin.css → village.css. _style.css 는 건드리지 않고 아래 재매핑으로 색·반경·글꼴을 그램과 맞춘다.
 * 값 출처: /Users/ef/crowny-gram/public/gram.css (:root·다크 선언 그대로). 스킨 키: localStorage 'gram.skin' (skin.js) */

/* 1. 토큰 — 그램과 같은 값 (중앙 토큰이 있으면 따르고 없으면 대체값) */
:root {
  --g-bg: var(--bg, #ffffff);
  --g-s1: var(--surface-1, #f6f5f1);
  --g-s2: var(--surface-2, #ecebe5);
  --g-text: var(--text, #1d1d1f);
  --g-text2: var(--text2, #5f5f66);
  --g-line: var(--crowny-line, #dcdad2);
  --g-gold: var(--gold, #b8860b);
  --g-on-gold: #ffffff;
  --g-gold-strong: #8a6200;
  --g-fs-xs: .8125rem;
  --g-focus: var(--g-gold);
  --g-me: #f1e3b8;
  --g-me-text: #2a2208;
  --g-done: #2e9e5b;
  --g-err: #c2410c;
  --g-r: var(--crowny-radius, 14px);
  --g-font: var(--crowny-sans, system-ui, -apple-system, "Apple SD Gothic Neo", sans-serif);
  --g-mono: ui-monospace, SFMono-Regular, Menlo, monospace;
}
@media (prefers-color-scheme: dark) {
  :root {
    --g-bg: var(--bg, #121214);
    --g-s1: var(--surface-1, #1c1c20);
    --g-s2: var(--surface-2, #26262b);
    --g-text: var(--text, #f0efe9);
    --g-text2: var(--text2, #a4a4ac);
    --g-line: var(--crowny-line, #34343a);
    --g-gold: var(--gold, #d9a82e);
    --g-gold-strong: var(--g-gold);
    --g-on-gold: #17130a;
    --g-me: #5a4710;
    --g-me-text: #fbf3d8;
    --g-done: #4cc884;
    --g-err: #fb923c;
  }
}

/* 2. id 기존 토큰(_style.css) → --g-* 재매핑. 같은 명시도라 뒤에 오는 이 파일이 이긴다 */
:root {
  --크림아이보리: var(--g-bg);
  --크림종이: var(--g-s1);
  --크림상단: var(--g-s2);
  --다크초콜릿: var(--g-on-gold);
  --초콜릿사이드바: var(--g-s2);
  --잉크: var(--g-text);
  --잉크제목: var(--g-text);
  --잉크보조: var(--g-text2);
  --잉크희미: var(--g-text2);
  --골드: var(--g-gold-strong);
  --골드밝음: var(--g-gold);
  --골드버튼: var(--g-gold-strong);
  --골드배경: var(--g-me);
  --골드테두리: var(--g-line);
  --골드그라데: linear-gradient(var(--g-gold-strong), var(--g-gold-strong));
  --라이브그린: var(--g-done);
  --경고적갈: var(--g-err);
  --테두리: var(--g-line);
  --구분선: var(--g-line);
  --글꼴: var(--g-font);
  --글꼴세리프: var(--g-font);
  --그림자: 0 1px 0 var(--g-line);
  --반경: var(--g-r);
}

/* 3. 틀 — 머리띠는 main 위, 본문은 가운데. 페이지의 max-width(카드 420 · 관리자 1080 · 매트릭스 1200)는 그대로 */
html, body { overflow-x: hidden; }
body[data-crowny] { display: flex; flex-direction: column; align-items: stretch; justify-content: flex-start; padding: 0; background: var(--g-bg); color: var(--g-text); font-size: 16px; -webkit-text-size-adjust: 100%; }
body[data-crowny] > main { width: calc(100% - 32px); margin-left: auto; margin-right: auto; margin-bottom: 2rem; }
body[data-crowny] > .bar ~ main { margin-top: 1.25rem; }
[hidden] { display: none !important; }
a { color: var(--g-gold-strong); }
:focus-visible { outline: 2px solid var(--g-focus); outline-offset: 2px; }

/* 4. 머리띠 — 그램 header.bar */
.bar { display: flex; align-items: center; gap: 4px; min-height: 56px; padding: env(safe-area-inset-top) 8px 0 16px; border-bottom: 1px solid var(--g-line); background: var(--g-s1); flex: none; }
.bar h1, .bar .bar-title { font-family: var(--g-font); font-size: 18px; font-weight: 600; letter-spacing: 0; color: var(--g-text); flex: 1; min-width: 0; margin: 0; padding: 6px 0; display: flex; align-items: center; gap: 8px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar .크라우니-왕관 { flex: none; background: linear-gradient(135deg, var(--g-gold), var(--g-gold-strong)); }
.bar-acts { display: flex; align-items: center; gap: 6px; flex: none; }
.bar-acts a, .bar-acts button { display: inline-flex; align-items: center; justify-content: center; width: auto; min-height: 44px; padding: 8px 14px; border: 1px solid var(--g-line); border-radius: var(--g-r); background: transparent; color: var(--g-text); font: inherit; font-size: 14px; font-weight: 600; text-decoration: none; cursor: pointer; white-space: nowrap; }
.icon-btn { display: inline-flex; align-items: center; justify-content: center; width: 44px; height: 44px; flex: none; border: 0; border-radius: 50%; background: transparent; color: var(--g-text); font-size: 20px; line-height: 1; cursor: pointer; }
.icon-btn:active { background: var(--g-s2); }
.icon-btn[aria-pressed="true"] { background: var(--g-s2); }

/* 5. 구역 탭 — 그램 nav.zones / .zone (선택 = aria-selected 또는 aria-current) */
.zones { display: flex; flex: none; overflow-x: auto; margin-bottom: 0; border-bottom: 1px solid var(--g-line); background: var(--g-s1); }
.zone { position: relative; flex: 1 0 auto; display: flex; align-items: center; justify-content: center; min-height: 44px; padding: 0 14px; border: 0; border-bottom: 2px solid transparent; background: transparent; color: var(--g-text2); font-size: 15px; font-weight: 600; text-decoration: none; white-space: nowrap; cursor: pointer; }
.zone[aria-selected="true"], .zone[aria-current="page"] { color: var(--g-gold-strong); border-bottom-color: var(--g-gold); }

/* 6. 그램 .btn · .card · .chip (선택자 이름 그대로) */
.btn { display: inline-flex; align-items: center; justify-content: center; min-height: 46px; padding: 10px 20px; border: 1px solid var(--g-gold-strong); border-radius: var(--g-r); background: var(--g-gold-strong); color: var(--g-on-gold); font-weight: 600; text-decoration: none; cursor: pointer; }
.btn.ghost { background: transparent; color: var(--g-gold-strong); }
.btn[disabled] { opacity: .45; cursor: default; }
.card { background: var(--g-s1); border: 1px solid var(--g-line); border-radius: var(--g-r); padding: 16px; }
.chip { display: inline-flex; align-items: center; min-height: 32px; padding: 4px 12px; border: 1px solid var(--g-line); border-radius: 999px; background: var(--g-s2); color: var(--g-text); font-size: 14px; }

/* 7. id 컴포넌트를 그램 꼴로 */
.버튼-골드 { min-height: 46px; border: 1px solid var(--g-gold-strong); border-radius: var(--g-r); background: var(--g-gold-strong); color: var(--g-on-gold); box-shadow: none; }
.버튼-골드:hover { transform: none; }
.버튼-보조 { min-height: 46px; border: 1px solid var(--g-gold-strong); border-radius: var(--g-r); background: transparent; color: var(--g-gold-strong); }
.미니, .작게 { display: inline-flex; align-items: center; justify-content: center; min-height: 44px; }
.입력, .셀입력 { min-height: 48px; border: 1px solid var(--g-line); border-radius: var(--g-r); background: var(--g-bg); color: var(--g-text); }
.셀입력 { min-height: 44px; }
.입력:focus, .셀입력:focus { outline: 0; border-color: var(--g-focus); box-shadow: 0 0 0 2px var(--g-focus); }
.카드, .띠, .칸, .여정띠, .절, .목차, .지표 { background: var(--g-s1); border: 1px solid var(--g-line); border-radius: var(--g-r); box-shadow: none; }
.칩 { min-height: 32px; border: 1px solid var(--g-line); background: var(--g-s2); color: var(--g-text); }
.알림.오류 { background: var(--g-s1); border: 2px solid var(--g-err); color: var(--g-text); }
.알림.성공 { background: var(--g-s1); border: 2px solid var(--g-done); color: var(--g-text); }
.탭 { min-height: 44px; border-color: var(--g-line); color: var(--g-text); }
.탭.활성 { background: var(--g-gold-strong); border-color: var(--g-gold-strong); color: var(--g-on-gold); }
.탭줄 button { min-height: 44px; }
.상태골드, .여정칸.끝 .표, .절 ol.띠 li::before { color: var(--g-on-gold); }
.표감 table th, th { background: var(--g-s2); }
.큰글자단추 { min-height: 44px; border-color: var(--g-line); background: var(--g-s1); color: var(--g-text); box-shadow: none; }

/* 관제 보강: 390px 머리띠 — 단추가 3개여도 제목이 잘리지 않게 단추를 작게 */
@media (max-width:430px){ .bar .bar-acts .버튼-보조, .bar .bar-acts .작게, .bar .bar-acts button, .bar .bar-acts a{padding:.4rem .55rem;font-size:.78rem} .bar .bar-title{font-size:.95rem;white-space:nowrap} }
