:root {
  --bg: #f1f2f0;
  --surface: #ffffff;
  --ink: #16202b;
  --muted: #5c6773;
  --line: #d9dde1;
  --line-soft: #e8ebed;
  --accent: #0c6b5f;
  --accent-soft: #ddf1ec;
  --kraft: #b8895a;
  --slate: #3c4a5a;
  --amber: #8a5a00;
  --amber-soft: #fbf1d6;
  --danger: #b3261e;
  --danger-soft: #fbe4e2;
  --radius: 6px;
  --font: "Pretendard", "Apple SD Gothic Neo", "Noto Sans KR", "Malgun Gothic", "Segoe UI", system-ui, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12171c; --surface: #1b222a; --ink: #e8edf1; --muted: #9aa6b2; --line: #2f3944; --line-soft: #252e37;
    --accent: #3fb8a5; --accent-soft: #15332f; --kraft: #d0a273; --slate: #7f93a8;
    --amber: #f0c33c; --amber-soft: #3a2f10; --danger: #ff8a80; --danger-soft: #3d1b19;
  }
}
* { box-sizing: border-box; }
html { color-scheme: light dark; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 14px/1.5 var(--font); -webkit-font-smoothing: antialiased; }
h1, h2, h3 { margin: 0; line-height: 1.3; }
h1 { font-size: 20px; font-weight: 700; letter-spacing: -0.01em; }
h2 { font-size: 15px; font-weight: 700; }
h3 { font-size: 14px; font-weight: 600; }
a { color: var(--accent); }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.num { font-variant-numeric: tabular-nums; }
.grow { flex: 1; min-width: 0; }
.row { display: flex; align-items: center; gap: 8px; }
.wrap { flex-wrap: wrap; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.hidden { display: none !important; }

/* 상단 바 */
.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 24px; height: 52px; padding: 0 20px; background: var(--surface); border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 15px; color: var(--ink); text-decoration: none; }
.brand svg { width: 22px; height: 22px; }
.nav { display: flex; gap: 4px; }
.nav a { white-space: nowrap; padding: 6px 12px; border-radius: var(--radius); color: var(--muted); text-decoration: none; font-weight: 600; }
.nav a:hover { background: var(--line-soft); }
.nav a[aria-current="page"] { color: var(--ink); background: var(--line-soft); }
.page { max-width: 1280px; margin: 0 auto; padding: 20px; }

/* 버튼·입력 */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 34px; padding: 0 14px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); cursor: pointer; font-weight: 600; white-space: nowrap; }
.btn:hover:not(:disabled) { background: var(--line-soft); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover:not(:disabled) { filter: brightness(1.08); background: var(--accent); }
.btn.danger { color: var(--danger); }
.btn.small { height: 28px; padding: 0 10px; font-size: 12px; }
.btn.ghost { border-color: transparent; background: transparent; }
.field { display: flex; flex-direction: column; gap: 4px; }
.field > label, .field > .label { font-weight: 600; font-size: 13px; }
.hint { font-size: 12px; color: var(--muted); }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=search], select, textarea {
  width: 100%; height: 34px; padding: 0 10px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface);
}
textarea { height: auto; min-height: 68px; padding: 8px 10px; resize: vertical; }
input:disabled, textarea:disabled, select:disabled { background: var(--line-soft); color: var(--muted); }
input[type=checkbox] { width: 16px; height: 16px; accent-color: var(--accent); }
.suffix { position: relative; }
.suffix input { padding-right: 36px; }
.suffix span { position: absolute; right: 10px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }

/* 패널 */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.panel > header { display: flex; align-items: center; gap: 8px; padding: 12px 16px; border-bottom: 1px solid var(--line-soft); }
.panel > .body { padding: 16px; }
.notice { padding: 10px 14px; border-radius: var(--radius); background: var(--amber-soft); color: var(--amber); font-weight: 500; }
.notice.error { background: var(--danger-soft); color: var(--danger); }
.chip { display: inline-flex; align-items: center; height: 22px; padding: 0 8px; border-radius: 11px; font-size: 12px; font-weight: 600; background: var(--line-soft); color: var(--muted); }
.chip.editing { background: var(--amber-soft); color: var(--amber); }
.chip.ready { background: var(--accent-soft); color: var(--accent); }
.chip.beta { background: var(--amber-soft); color: var(--amber); }

/* 로그인 */
.auth { max-width: 380px; margin: 12vh auto 0; padding: 0 20px; }
.auth .panel { padding: 24px; }
.tabs { display: flex; gap: 0; border-bottom: 1px solid var(--line); margin-bottom: 16px; }
.tabs button { flex: 1; padding: 8px; background: none; border: 0; border-bottom: 2px solid transparent; cursor: pointer; font-weight: 600; color: var(--muted); }
.tabs button[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--accent); }

/* 목록 */
.toolbar { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; flex-wrap: wrap; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.seg button { height: 34px; padding: 0 14px; border: 0; background: var(--surface); cursor: pointer; font-weight: 600; color: var(--muted); }
.seg button + button { border-left: 1px solid var(--line); }
.seg button[aria-pressed="true"] { background: var(--ink); color: var(--surface); }
table.list { width: 100%; border-collapse: collapse; }
.tablewrap { overflow: visible; }
.list th { text-align: left; font-size: 12px; font-weight: 600; color: var(--muted); padding: 8px 10px; border-bottom: 1px solid var(--line); background: var(--surface); position: sticky; top: 52px; z-index: 5; white-space: nowrap; }
.list td { padding: 8px 10px; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
.list tr.item { cursor: pointer; }
.list tr.item:hover td { background: color-mix(in srgb, var(--accent) 5%, var(--surface)); }
.list td.r, .list th.r { text-align: right; }
.thumb { width: 52px; height: 52px; border-radius: 4px; object-fit: cover; background: var(--line-soft); display: block; }
.title-cell { max-width: 420px; }
.title-cell .kr { font-weight: 600; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.title-cell .cn { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.empty { text-align: center; padding: 56px 20px; }
.empty h2 { font-size: 17px; margin-bottom: 6px; }

/* 상세 */
.detail { display: grid; grid-template-columns: minmax(380px, 460px) 1fr; gap: 16px; align-items: start; }
@media (max-width: 960px) { .detail { grid-template-columns: minmax(0, 1fr); } }
.cols2 { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 12px; }
.cols2 > * { min-width: 0; }
.sticky-col { position: sticky; top: 68px; }
.bar { display: flex; height: 26px; border-radius: 4px; overflow: hidden; background: var(--line-soft); }
.bar > div { min-width: 2px; }
.legend { display: flex; flex-wrap: wrap; gap: 4px 16px; margin-top: 8px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 6px; }
.sell { font-size: 26px; font-weight: 700; letter-spacing: -0.02em; }
.results { border: 1px solid var(--line); border-radius: var(--radius); max-height: 200px; overflow: auto; background: var(--surface); }
.results button { display: block; width: 100%; text-align: left; padding: 7px 10px; border: 0; background: none; cursor: pointer; border-bottom: 1px solid var(--line-soft); }
.results button:hover { background: var(--accent-soft); }
.imgs { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.imgcard { border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; background: var(--surface); display: flex; flex-direction: column; }
.imgcard .pic { position: relative; aspect-ratio: 1; background: repeating-conic-gradient(var(--line-soft) 0% 25%, var(--surface) 0% 50%) 0 0 / 14px 14px; display: flex; align-items: center; justify-content: center; overflow: hidden; }
.imgcard img { width: 100%; height: 100%; object-fit: contain; display: block; }
.imgcard .badge { position: absolute; left: 6px; top: 6px; }
.imgcard .acts { display: flex; gap: 2px; padding: 4px; border-top: 1px solid var(--line-soft); }
.imgcard .acts .btn { flex: 1; padding: 0 4px; }
.dropzone { border: 1.5px dashed var(--line); border-radius: var(--radius); padding: 14px; text-align: center; color: var(--muted); }
.dropzone.over { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
pre.payload { margin: 0; padding: 12px; max-height: 320px; overflow: auto; background: var(--bg); border-radius: var(--radius); font: 12px/1.5 ui-monospace, Menlo, Consolas, monospace; white-space: pre-wrap; word-break: break-all; }

/* 모달·토스트 */
.overlay { position: fixed; inset: 0; z-index: 50; background: rgba(10, 16, 22, 0.55); display: flex; align-items: center; justify-content: center; padding: 20px; }
.modal { width: min(520px, 100%); max-height: 90vh; overflow: auto; background: var(--surface); border-radius: 8px; border: 1px solid var(--line); }
.modal > header { padding: 14px 18px; border-bottom: 1px solid var(--line-soft); font-weight: 700; }
.modal > .body { padding: 18px; }
.modal > footer { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 18px; border-top: 1px solid var(--line-soft); }
#toasts { position: fixed; right: 16px; bottom: 16px; z-index: 80; display: flex; flex-direction: column; gap: 8px; }
.toast { padding: 10px 14px; border-radius: var(--radius); background: var(--ink); color: var(--surface); max-width: 360px; box-shadow: 0 6px 20px rgba(0, 0, 0, 0.25); }
.toast.error { background: var(--danger); color: #fff; }

/* 이미지 번역 에디터 */
.editor { position: fixed; inset: 0; z-index: 60; background: var(--bg); display: grid; grid-template-rows: auto 1fr; }
.editor-bar { display: flex; align-items: center; gap: 8px; padding: 8px 14px; background: var(--surface); border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.editor-main { display: grid; grid-template-columns: 1fr 340px; min-height: 0; }
@media (max-width: 860px) { .editor-main { grid-template-columns: 1fr; grid-template-rows: 1fr 40%; } }
.stage { overflow: auto; padding: 16px; background: #2b333b; display: flex; justify-content: center; align-items: flex-start; }
.stage canvas { display: block; background: #fff; touch-action: none; box-shadow: 0 2px 16px rgba(0, 0, 0, 0.4); }
.regions { overflow: auto; background: var(--surface); border-left: 1px solid var(--line); }
.region { padding: 10px 12px; border-bottom: 1px solid var(--line-soft); display: grid; gap: 6px; }
.region.sel { background: var(--accent-soft); }
.region .cn { font-size: 12px; color: var(--muted); }
.region textarea { min-height: 52px; }
.colors { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); }
.colors input[type=color] { width: 28px; height: 24px; padding: 0; border: 1px solid var(--line); border-radius: 4px; background: none; }
.progress { height: 4px; background: var(--line-soft); }
.progress > div { height: 100%; background: var(--accent); width: 0; transition: width 0.2s; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

/* 좁은 화면: 표만 가로로 스크롤하고 머리글은 표 안에서 고정 (위 .list th 보다 뒤에 있어야 덮어쓴다) */
@media (max-width: 900px) {
  .tablewrap { overflow-x: auto; }
  .list th { top: 0; }
  .page { padding: 12px; }
  .topbar { gap: 12px; padding: 0 12px; }
  .toolbar > h1 { flex: 1 0 100%; white-space: normal !important; }
}

/* 공유 자료실 */
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 14px; }
.gcard { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; cursor: pointer; display: flex; flex-direction: column; }
.gcard:hover { border-color: var(--accent); }
.gthumb { position: relative; aspect-ratio: 1 / 1; background: var(--line-soft); display: flex; align-items: center; justify-content: center; }
.gthumb img { width: 100%; height: 100%; object-fit: cover; }
.gcheck { position: absolute; top: 8px; left: 8px; display: flex; padding: 6px; border-radius: var(--radius); background: color-mix(in srgb, var(--surface) 88%, transparent); }
.gbody { padding: 10px 12px 12px; display: flex; flex-direction: column; gap: 6px; }
.gbody .kr { font-weight: 600; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.gbody .cn { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.big { font-size: 22px; font-weight: 700; line-height: 1.2; }
button.chip.pick { border: 0; cursor: pointer; font-family: inherit; }
button.chip.pick:hover { background: var(--line); }
button.chip.pick.on { background: var(--accent); color: #fff; }
@media (max-width: 640px) { .gallery { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; } }

/* 업로드 검토 */
.urow { display: grid; grid-template-columns: auto 84px minmax(0, 1fr) auto; gap: 12px; align-items: start; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px; }
.uthumb { width: 84px; height: 84px; border-radius: var(--radius); background: var(--line-soft); display: flex; align-items: center; justify-content: center; overflow: hidden; }
.uthumb img { width: 100%; height: 100%; object-fit: cover; }
.ucheck { padding-top: 4px; }
.uprice { display: flex; flex-direction: column; gap: 6px; align-items: flex-end; min-width: 150px; }
.urow .cn { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.urow .ok { color: var(--accent); }
.urow .bad { color: var(--danger); }
@media (max-width: 760px) {
  .urow { grid-template-columns: auto 64px minmax(0, 1fr); }
  .uthumb { width: 64px; height: 64px; }
  .uprice { grid-column: 1 / -1; flex-direction: row; flex-wrap: wrap; align-items: center; justify-content: space-between; min-width: 0; }
}

/* 좁은 화면 상단 바: 로고만 남기고 메뉴를 한 줄에 맞춘다 */
@media (max-width: 640px) {
  .topbar { gap: 6px; padding: 0 8px; }
  .brand { font-size: 0; gap: 0; }
  .topbar > span.muted { display: none; }
  .nav { gap: 0; min-width: 0; overflow-x: auto; }
  .nav a { padding: 6px 8px; font-size: 13px; }
  .panel > header { flex-wrap: wrap; }
}

/* 메인 페이지 통계 */
.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 12px; }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; min-width: 0; }
.kpi-label { color: var(--muted); font-size: 13px; }
.kpi-value { font-size: 28px; font-weight: 700; color: var(--accent); font-variant-numeric: tabular-nums; line-height: 1.2; }
.kpi-sub { color: var(--muted); font-size: 12px; margin-top: 2px; }
.stack > .panel + .panel { margin-top: 0; }
.stats td, .stats th { white-space: nowrap; }
.meter { height: 8px; background: var(--line-soft); border-radius: 4px; overflow: hidden; min-width: 60px; }
.meter > span { display: block; height: 100%; background: var(--accent); border-radius: 4px; }
.daily { display: grid; grid-template-columns: repeat(14, minmax(0, 1fr)); gap: 6px; height: 160px; align-items: end; }
.daycol { display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; min-width: 0; gap: 2px; }
.daybar { width: 100%; max-width: 28px; background: var(--accent-soft); border: 1px solid var(--accent); border-radius: 3px 3px 0 0; box-sizing: border-box; }
.daybar.today { background: var(--accent); }
.daynum { font-size: 11px; color: var(--muted); height: 14px; }
.daylbl { font-size: 10px; color: var(--muted); }
@media (max-width: 720px) { .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); } .kpi-value { font-size: 24px; } .daylbl { font-size: 9px; } }
.statwrap { overflow-x: auto; }
.toolbar { flex-wrap: wrap; }
.stats th { position: static; }
progress { accent-color: var(--accent); }
.optgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 6px 12px; }
.opts tr.optsel td { background: var(--accent-soft); }
.opts td { vertical-align: top; }
.lightbox { position: fixed; inset: 0; z-index: 200; background: rgba(10, 14, 18, .92); display: flex; flex-direction: column; }
.lb-bar { display: flex; align-items: center; gap: 10px; padding: 10px 14px; color: #fff; }
.lb-bar .btn { background: rgba(255, 255, 255, .12); color: #fff; border-color: rgba(255, 255, 255, .25); }
.lb-title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.lb-count { font-variant-numeric: tabular-nums; opacity: .8; }
.lb-stage { flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center; padding: 0 56px 16px; overflow: auto; }
.lb-stage img { max-width: 100%; max-height: 100%; object-fit: contain; background: #fff; }
.lb-nav { position: absolute; top: 50%; transform: translateY(-50%); width: 44px; height: 64px; border: 0; border-radius: 8px; background: rgba(255, 255, 255, .15); color: #fff; font-size: 34px; cursor: pointer; }
.lb-prev { left: 6px; } .lb-next { right: 6px; }
@media (max-width: 640px) { .lb-stage { padding: 0 8px 12px; } .lb-nav { width: 36px; opacity: .8; } }
.zoomable { cursor: zoom-in; }
.optthumb { width: 44px; height: 44px; object-fit: cover; border-radius: 6px; border: 1px solid var(--line); background: var(--surface); display: block; cursor: zoom-in; }
.dpage { max-width: 900px; }
.dimg { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); overflow: hidden; }
.dimg .dbar { display: flex; align-items: center; gap: 6px; padding: 6px 8px; border-bottom: 1px solid var(--line-soft); flex-wrap: wrap; }
.dimg img { width: 100%; display: block; cursor: zoom-in; background: repeating-conic-gradient(var(--line-soft) 0% 25%, var(--surface) 0% 50%) 0 0 / 14px 14px; }
.dstrip { display: flex; gap: 6px; overflow-x: auto; }
.dstrip img { height: 72px; width: auto; border-radius: 6px; border: 1px solid var(--line); cursor: zoom-in; flex: none; }
.ptabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin: 4px 0 16px; overflow-x: auto; position: sticky; top: 52px; z-index: 15; background: var(--bg, var(--surface)); }
.ptabs button { flex: none; padding: 10px 16px; background: none; border: 0; border-bottom: 3px solid transparent; cursor: pointer; font: inherit; font-weight: 600; color: var(--muted); white-space: nowrap; }
.ptabs button[aria-selected="true"] { color: var(--accent); border-bottom-color: var(--accent); }
.ptabs button:hover { color: var(--ink); }
.ptabs .tabcount { margin-left: 6px; font-size: 12px; font-weight: 600; padding: 1px 7px; border-radius: 999px; background: var(--line-soft); color: var(--muted); }
.ptabs button[aria-selected="true"] .tabcount { background: var(--accent-soft); color: var(--accent); }
.ptab-body { max-width: 980px; }

/* 메인 달력 */
.homerow { display: grid; grid-template-columns: minmax(260px, 340px) minmax(0, 1fr); gap: 12px; align-items: start; }
.calgrid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 3px; margin-top: 8px; }
.calw { text-align: center; font-size: 11px; color: var(--muted, #888); padding: 2px 0; }
.calc { position: relative; min-height: 38px; border-radius: 6px; padding: 3px 4px; font-size: 11px; background: transparent; }
.calc.empty { visibility: hidden; }
.calc .cald { color: var(--muted, #888); }
.calc.has { background: var(--line-soft); }
.calc.today { outline: 2px solid var(--accent); outline-offset: -2px; }
.calc .calcount { position: absolute; right: 4px; bottom: 2px; font-size: 14px; font-weight: 700; color: var(--accent); }
@media (max-width: 720px) { .homerow { grid-template-columns: minmax(0, 1fr); } }
