/* artpost — mobile-first, minimal. Light default; dark via [data-theme="dark"]. */

@font-face { font-family: ArtpostSans; src: url("fonts/NotoSansKR-400.ttf") format("truetype"); font-weight: 400; font-style: normal; font-display: swap; }
@font-face { font-family: ArtpostSans; src: url("fonts/NotoSansKR-700.ttf") format("truetype"); font-weight: 700; font-style: normal; font-display: swap; }
@font-face { font-family: ArtpostSerif; src: url("fonts/NotoSerifKR-400.ttf") format("truetype"); font-weight: 400; font-style: normal; font-display: swap; }
@font-face { font-family: ArtpostSerif; src: url("fonts/NotoSerifKR-700.ttf") format("truetype"); font-weight: 700; font-style: normal; font-display: swap; }

:root {
  --bg: #ffffff;
  --surface: #ffffff;
  --surface-2: #f5f4f2;
  --surface-3: #ecebe8;
  --border: #e4e2de;
  --text: #161616;
  --muted: #6b6966;
  --primary: #161616;
  --primary-text: #ffffff;
  --primary-hover: #2e2e2e;
  --success: #2c7a4b;
  --success-bg: #e8f4ec;
  --danger: #b93a2e;
  --error-bg: #fcebe9;
  --warn: #8a5a00;
  --warn-bg: #fff5dc;
  --info-bg: #eef3f9;
  --focus: #3b73c9;
  --shadow: 0 1px 2px rgba(0,0,0,.05), 0 4px 16px rgba(0,0,0,.06);
  --radius: 14px;
  --accent: #B8893A;
  --accent-art: #B8893A;
  --accent-sculpture: #8C8577;
  --accent-music: #4F7CAC;
  --accent-literature: #A5603F;
  --font: ArtpostSans, -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Malgun Gothic", "Segoe UI", "Noto Sans KR", system-ui, sans-serif;
  --serif: ArtpostSerif, "AppleMyungjo", "Batang", "Noto Serif KR", Georgia, serif;
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #121316;
  --surface: #1a1b1f;
  --surface-2: #222429;
  --surface-3: #2b2d33;
  --border: #30333a;
  --text: #f0efed;
  --muted: #a3a09b;
  --primary: #f0efed;
  --primary-text: #121316;
  --primary-hover: #ffffff;
  --success: #6cc38f;
  --success-bg: #1d3226;
  --danger: #f08578;
  --error-bg: #3a1f1c;
  --warn: #f2c46b;
  --warn-bg: #352b14;
  --info-bg: #1c2733;
  --focus: #7aa7f0;
  --shadow: 0 1px 2px rgba(0,0,0,.4), 0 6px 20px rgba(0,0,0,.35);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 17px;
  line-height: 1.5;
  word-break: keep-all;
  overflow-wrap: anywhere;
  -webkit-tap-highlight-color: transparent;
  min-height: 100vh;
  overflow-x: hidden;
}
body.no-scroll { overflow: hidden; }
img, canvas { max-width: 100%; }
a { color: inherit; }
button, input, textarea, select { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 8px; }
[hidden] { display: none !important; }

/* ---------- header ---------- */
.header {
  position: sticky; top: 0; z-index: 30;
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: saturate(1.4) blur(10px);
  -webkit-backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--border);
  padding-top: env(safe-area-inset-top);
}
.header-inner {
  max-width: 1100px; margin: 0 auto;
  display: flex; align-items: center; gap: 2px;
  padding: 4px 8px; min-height: 58px;
}
.header-spacer { flex: 1; }
.brand { display: flex; align-items: center; gap: 8px; text-decoration: none; font-weight: 700; font-size: 18px; padding: 8px 6px; min-height: 48px; }
.brand img { border-radius: 7px; }
.lang-toggle { display: inline-flex; background: var(--surface-2); border-radius: 999px; padding: 3px; margin-right: 2px; }
.lang-toggle { padding: 2px; }
.lang-toggle button {
  border: 0; background: transparent; border-radius: 999px; min-height: 44px; min-width: 48px; padding: 0 11px;
  font-size: 14px; font-weight: 600; color: var(--muted); cursor: pointer;
}
.lang-toggle button.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 48px; height: 48px; border: 0; background: transparent; border-radius: 12px;
  cursor: pointer; color: var(--text); text-decoration: none; flex: none;
}
.icon-btn:hover { background: var(--surface-2); }
.icon-btn.on { background: var(--surface-2); }
.icon-btn:disabled { opacity: .3; cursor: default; background: transparent; }
.icon-btn.danger { color: var(--danger); }
@media (max-width: 420px) {
  .brand-name { display: none; }
  .header-inner { padding: 4px 4px; }
  .icon-btn { width: 44px; }
  .lang-toggle button { padding: 0 8px; min-width: 44px; }
}

/* ---------- banner ---------- */
.banner-host { max-width: 1100px; margin: 0 auto; padding: 0 16px; }
.banner {
  display: flex; gap: 12px; align-items: flex-start; margin-top: 12px;
  padding: 14px 16px; border-radius: var(--radius); font-size: 15px;
}
.banner-warn { background: var(--warn-bg); color: var(--text); }
.banner-warn > svg { color: var(--warn); flex: none; margin-top: 2px; }
.banner-error { background: var(--error-bg); }
.banner-error > svg { color: var(--danger); flex: none; margin-top: 2px; }
.banner-text { flex: 1; min-width: 0; }
.banner details { margin-top: 6px; }
.banner summary { cursor: pointer; font-weight: 600; min-height: 32px; }
.fix-text { white-space: pre-wrap; padding-top: 6px; }
@media (max-width: 560px) { .banner { flex-wrap: wrap; } .banner .btn { width: 100%; } }

/* ---------- layout ---------- */
.main { max-width: 1100px; margin: 0 auto; padding: 8px 16px calc(96px + env(safe-area-inset-bottom)); outline: none; }
.page { padding-top: 12px; }
.page-title { font-size: 26px; line-height: 1.25; margin: 6px 0 6px; letter-spacing: -0.01em; }
.lead { font-size: 16px; margin: 0 0 20px; }
.section { margin-top: 28px; }
.section-title { font-size: 19px; margin: 0 0 10px; font-weight: 700; }
.section-head { margin-bottom: 6px; }
.section-head .section-title { margin: 0; }
.sub-title { font-size: 16px; margin: 16px 0 6px; }
.muted { color: var(--muted); }
.small { font-size: 14px; }
.center { text-align: center; }
.center-col { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; padding: 24px 0; }
.pad { padding: 40px 0; }
.stack { display: flex; flex-direction: column; gap: 14px; }
.stack-sm { display: flex; flex-direction: column; gap: 8px; }
.row { display: flex; align-items: center; gap: 10px; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.row-end { display: flex; justify-content: flex-end; gap: 10px; flex-wrap: wrap; margin-top: 8px; }
.row-wrap { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-top: 10px; }
.grow { flex: 1 1 auto; }
.pre-wrap { white-space: pre-wrap; }
.break { word-break: break-all; }
.clamp-2 { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.link { color: var(--focus); text-decoration: underline; text-underline-offset: 3px; }
.links { display: flex; gap: 16px; flex-wrap: wrap; margin: 0; }
.error-text { color: var(--danger); }
.danger-text { color: var(--danger) !important; }
.meta-line { margin: 0 0 12px; }
code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 13px; background: var(--surface-2); padding: 2px 6px; border-radius: 6px; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 10px 18px; border-radius: 12px;
  border: 1px solid transparent; cursor: pointer; font-weight: 600; font-size: 16px;
  text-decoration: none; line-height: 1.2; text-align: center;
  transition: background .15s, transform .05s, opacity .15s;
  max-width: 100%;
}
.btn:active:not(:disabled) { transform: scale(.98); }
.btn:disabled { opacity: .45; cursor: default; }
.btn svg { flex: none; }
.btn-primary { background: var(--primary); color: var(--primary-text); }
.btn-primary:hover:not(:disabled) { background: var(--primary-hover); }
.btn-secondary { background: var(--surface); color: var(--text); border-color: var(--border); }
.btn-secondary:hover:not(:disabled) { background: var(--surface-2); }
.btn-ghost { background: transparent; color: var(--text); }
.btn-ghost:hover:not(:disabled) { background: var(--surface-2); }
.btn-success { background: var(--success-bg); color: var(--success); border-color: color-mix(in srgb, var(--success) 35%, transparent); }
.btn-danger { background: var(--danger); color: #fff; }
.btn.block { display: flex; width: 100%; }
.btn.big { min-height: 56px; font-size: 18px; border-radius: 14px; }
.btn.small { min-height: 40px; padding: 6px 14px; font-size: 15px; }

/* ---------- inputs ---------- */
.input {
  width: 100%; min-height: 48px; padding: 11px 14px; border-radius: 12px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  font-size: 17px; line-height: 1.45;
}
textarea.input { resize: vertical; min-height: 80px; }
.input:focus { outline: none; border-color: var(--focus); box-shadow: 0 0 0 3px color-mix(in srgb, var(--focus) 25%, transparent); }
.input:disabled { opacity: .6; }
.input.num { max-width: 160px; }
.field { display: flex; flex-direction: column; gap: 6px; margin-top: 12px; }
.field-label { font-weight: 600; font-size: 15px; }
.check { display: flex; align-items: center; gap: 10px; min-height: 48px; cursor: pointer; }
.check input { width: 28px; height: 28px; margin: 0; flex: none; accent-color: var(--primary); }
fieldset.l10n-field { border: 0; padding: 0; margin: 14px 0 0; min-width: 0; }
fieldset.l10n-field legend { padding: 0; margin-bottom: 6px; }
.lang-row { position: relative; margin-top: 8px; gap: 4px; }
.lang-tag { font-size: 13px; font-weight: 600; color: var(--muted); }
.lang-row .count { align-self: flex-end; font-size: 12px; }
select.input { appearance: auto; }

/* segmented */
.seg { display: flex; background: var(--surface-2); border-radius: 12px; padding: 4px; gap: 4px; max-width: 100%; }
.seg-btn {
  flex: 1 1 0; min-height: 44px; border: 0; background: transparent; border-radius: 9px;
  font-weight: 600; font-size: 15px; color: var(--muted); cursor: pointer; padding: 0 10px; white-space: nowrap;
}
.seg-btn.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.seg.small .seg-btn { min-height: 44px; font-size: 14px; }

/* ---------- chips ---------- */
.chips { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.chip {
  display: inline-flex; align-items: center; gap: 4px; padding: 3px 10px; border-radius: 999px;
  font-size: 13px; font-weight: 600; background: var(--surface-2); color: var(--muted); white-space: nowrap;
}
.chip.cat { background: color-mix(in srgb, var(--accent) 16%, transparent); color: color-mix(in srgb, var(--accent) 80%, var(--text)); }
.st-idea { background: var(--info-bg); color: var(--focus); }
.st-analysing { background: var(--warn-bg); color: var(--warn); }
.st-draft { background: var(--surface-3); color: var(--text); }
.st-ready { background: var(--success-bg); color: var(--success); }
.st-posted { background: var(--primary); color: var(--primary-text); }
.st-dismissed { background: var(--surface-2); color: var(--muted); }
.st-failed { background: var(--error-bg); color: var(--danger); }

/* ---------- cards ---------- */
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px; box-shadow: var(--shadow);
}
.list { display: flex; flex-direction: column; gap: 12px; }
.card-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.empty { text-align: center; padding: 32px 16px; color: var(--muted); border: 2px dashed var(--border); border-radius: var(--radius); }
.empty p { margin: 0; }

/* home */
.cat-grid { display: grid; grid-template-columns: 1fr; gap: 12px; }
@media (min-width: 720px) { .cat-grid { grid-template-columns: 1fr 1fr; } }
.cat-card {
  display: flex; align-items: center; gap: 16px; text-decoration: none; color: inherit;
  padding: 20px 18px; border-radius: 18px; background: var(--surface); border: 1px solid var(--border);
  box-shadow: var(--shadow); min-height: 104px; position: relative; overflow: hidden;
}
.cat-card::before { content: ""; position: absolute; inset: 0 auto 0 0; width: 6px; background: var(--accent); }
.cat-card:hover { border-color: color-mix(in srgb, var(--accent) 50%, var(--border)); }
.cat-icon {
  display: inline-flex; align-items: center; justify-content: center; flex: none;
  width: 56px; height: 56px; border-radius: 16px; color: var(--accent);
  background: color-mix(in srgb, var(--accent) 14%, transparent);
}
.cat-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1; }
.cat-name { font-size: 21px; font-weight: 700; }
.cat-desc { font-size: 15px; color: var(--muted); }
.cat-counts { font-size: 13px; color: var(--muted); margin-top: 4px; }
.cat-arrow { font-size: 30px; color: var(--muted); line-height: 1; }
.cat-head { display: flex; align-items: center; gap: 12px; }
.cat-head .page-title { margin: 0; }

/* category */
.gen-box { margin-top: 16px; display: flex; flex-direction: column; gap: 12px; }
.hint-fold { margin-top: 8px; }
.hint-fold summary {
  cursor: pointer; color: var(--text); font-size: 15px; font-weight: 600; min-height: 48px;
  display: flex; align-items: center; gap: 8px; list-style: none; width: fit-content; max-width: 100%;
}
.hint-fold summary::-webkit-details-marker { display: none; }
.hint-fold summary::before {
  content: "+"; display: inline-flex; align-items: center; justify-content: center; flex: none;
  width: 26px; height: 26px; border-radius: 50%; background: var(--surface-2); color: var(--text);
  font-size: 18px; line-height: 1; font-weight: 700;
}
.hint-fold[open] summary::before { content: "−"; }
.hint-fold .input { margin-top: 4px; }
.job-host:not(:empty) { margin-top: 16px; }
.idea-card { padding: 0; overflow: hidden; }
.idea-main { display: block; padding: 16px 16px 4px; text-decoration: none; color: inherit; }
.idea-card .card-actions { padding: 0 16px 16px; margin-top: 8px; }
.idea-title { font-size: 18px; font-weight: 700; line-height: 1.3; }
.idea-meta { font-size: 15px; margin-top: 2px; }
.idea-hook { margin: 8px 0 0; font-size: 16px; }
.row-card { padding: 0; overflow: hidden; }
.row-card > div:not(.row-link) { padding: 0 16px 14px; }
.row-link { display: flex; align-items: center; gap: 14px; padding: 12px 12px 12px 12px; text-decoration: none; color: inherit; min-height: 88px; }
.row-body { flex: 1; min-width: 0; }
.row-top { display: flex; gap: 8px; align-items: center; margin-bottom: 4px; flex-wrap: wrap; }
.row-arrow { color: var(--muted); flex: none; }
.thumb { width: 64px; height: 80px; border-radius: 10px; object-fit: cover; flex: none; background: var(--surface-2); }
.thumb-empty { display: inline-flex; align-items: center; justify-content: center; color: var(--accent); background: color-mix(in srgb, var(--accent) 12%, var(--surface-2)); }
.mini-progress { display: flex; align-items: center; gap: 10px; }
.mini-progress .progress { flex: 1; margin: 0; }

/* job card */
.job-card { border-color: color-mix(in srgb, var(--accent) 40%, var(--border)); }
.job-head { display: flex; align-items: center; gap: 10px; }
.job-title { flex: 1; }
.job-time { font-variant-numeric: tabular-nums; font-size: 14px; }
.job-msg { margin: 8px 0 0; }
.job-card.compact { box-shadow: none; padding: 12px; }
.job-card.compact .job-msg { font-size: 15px; }
.progress { height: 10px; border-radius: 999px; background: var(--surface-3); overflow: hidden; margin-top: 12px; }
.progress.thin { height: 6px; margin: 6px 0; }
.progress-bar { height: 100%; background: var(--accent); border-radius: 999px; transition: width .6s ease; }

/* spinner */
.spinner { width: 32px; height: 32px; border: 3px solid var(--surface-3); border-top-color: var(--accent); border-radius: 50%; animation: spin .9s linear infinite; display: inline-block; flex: none; }
.spinner.small { width: 20px; height: 20px; border-width: 2.5px; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation-duration: 2.5s; } .progress-bar { transition: none; } }

/* alerts */
.alert { display: flex; gap: 10px; align-items: flex-start; padding: 14px 16px; border-radius: var(--radius); margin-top: 12px; }
.alert > svg { flex: none; margin-top: 2px; }
.alert-text { flex: 1; min-width: 0; }
.alert-error { background: var(--error-bg); }
.alert-error > svg { color: var(--danger); }
.alert-warn { background: var(--warn-bg); }
.alert-warn > svg { color: var(--warn); }
.alert-success { background: var(--success-bg); }
.alert-success > svg { color: var(--success); }
.alert-info { background: var(--info-bg); }
.alert .btn { flex: none; }
@media (max-width: 560px) { .alert { flex-wrap: wrap; } .alert .btn { width: 100%; } }

/* ---------- post ---------- */
.hook-card { background: color-mix(in srgb, var(--accent) 8%, var(--surface)); }
.hook-text { font-size: 18px; margin: 4px 0 0; }
.preview-grid { display: grid; grid-template-columns: minmax(0, 1fr); gap: 10px; margin-top: 10px; }
/* Phone/tablet: the side column dissolves into the grid so the Approve bar can stick to the bottom
   of the screen while the slide is on screen (Approve always reachable without scrolling). */
@media (max-width: 899px) {
  .preview-grid > .thumbs-col { display: contents; }
  .preview-bar {
    position: sticky; bottom: 0; z-index: 6; max-width: 520px; width: 100%; margin: 0 auto;
    background: color-mix(in srgb, var(--bg) 94%, transparent);
    backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
    padding: 6px 0 calc(8px + env(safe-area-inset-bottom));
  }
  .preview-bar .row-wrap { margin-top: 6px; flex-wrap: nowrap; gap: 6px; }
  .preview-bar .row-wrap .btn { padding: 8px 10px; gap: 6px; font-size: 15px; white-space: nowrap; }
  .preview-bar .row-wrap .btn.grow { flex: 1 1 auto; }
}
@media (min-width: 900px) {
  .preview-grid { grid-template-columns: auto minmax(0, 1fr); align-items: start; }
  /* slide + actions fit one screen: slide height capped by the viewport, actions beside it */
  /* ~300px = sticky header + title/meta + section head above the stage on first load (no scrolling needed) */
  .preview-col .preview-stage { width: clamp(280px, calc((100vh - 300px) * var(--arn, 0.8)), 460px); width: clamp(280px, calc((100dvh - 300px) * var(--arn, 0.8)), 460px); max-width: none; }
  .thumbs-col { position: sticky; top: 72px; }
  .thumbs-col .thumbs { flex-wrap: wrap; overflow: visible; }
  .thumbs-col .preview-bar { margin: 0; max-width: none; }
}
.preview-col { min-width: 0; }
.preview-stage {
  position: relative; width: 100%; max-width: 520px; margin: 0 auto; aspect-ratio: var(--ar, 4 / 5);
  border-radius: 12px; overflow: hidden; background: var(--surface-2); box-shadow: var(--shadow);
  touch-action: pan-y; user-select: none; -webkit-user-select: none;
}
.preview-canvas { display: block; width: 100%; height: 100%; }
@media (max-width: 899px) {
  /* first-paint guess (header + title block above, sticky Approve bar below ≈ 420px); post.js then
     measures the real space so the whole slide sits above the bar */
  .preview-col .preview-stage { width: min(100%, 520px, max(200px, calc((100vh - 420px) * var(--arn, 0.8)))); width: min(100%, 520px, max(200px, calc((100dvh - 420px) * var(--arn, 0.8)))); }
}
/* prev/next sit in the bar under the slide (never over the slide text) */
.slide-nav-row { flex-wrap: nowrap; gap: 4px; }
.slide-nav-label { flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: center; text-align: center; line-height: 1.25; }
.nav-btn { background: var(--surface-2); border-radius: 50%; }
.nav-btn:hover { background: var(--border); }
.badge-approved {
  position: absolute; top: 10px; right: 10px; width: 34px; height: 34px; border-radius: 50%;
  background: #2c7a4b; color: #fff; display: flex; align-items: center; justify-content: center; box-shadow: 0 2px 8px rgba(0,0,0,.3);
}
.preview-bar { max-width: 520px; margin: 0 auto; }
.slide-label { font-weight: 700; }
.thumbs { display: flex; gap: 8px; overflow-x: auto; padding: 4px 2px 10px; scroll-snap-type: x proximity; -webkit-overflow-scrolling: touch; }
.thumb-btn {
  position: relative; flex: none; width: 72px; padding: 0; border: 2px solid transparent; border-radius: 10px;
  background: var(--surface-2); cursor: pointer; overflow: hidden; scroll-snap-align: center; aspect-ratio: var(--ar, 4 / 5);
}
.thumb-btn.on { border-color: var(--text); }
.thumb-canvas { display: block; width: 100%; height: 100%; }
.thumb-check {
  position: absolute; top: 4px; right: 4px; width: 20px; height: 20px; border-radius: 50%;
  background: #2c7a4b; color: #fff; display: flex; align-items: center; justify-content: center;
}
.thumb-warn {
  position: absolute; top: 4px; left: 4px; width: 22px; height: 22px; border-radius: 50%;
  background: #b7791f; color: #fff; display: flex; align-items: center; justify-content: center;
}
.fit-warn {
  display: flex; gap: 8px; align-items: flex-start; font-size: 14px; line-height: 1.35;
  background: var(--warn-bg); border-radius: 10px; padding: 8px 10px; margin-bottom: 6px;
}
.fit-warn > svg { flex: none; color: var(--warn); margin-top: 1px; }
.fit-row { color: var(--warn); font-weight: 600; }
.fit-list { margin: 8px 0 0; padding-left: 20px; }
.thumb-num {
  position: absolute; bottom: 3px; left: 4px; font-size: 11px; font-weight: 700; color: #fff;
  background: rgba(0,0,0,.55); border-radius: 6px; padding: 0 5px;
}
.thumbs-col { min-width: 0; display: flex; flex-direction: column; gap: 10px; }
.download-box { padding: 16px; border-radius: var(--radius); background: var(--surface-2); }
.download-box .section-title { margin-bottom: 4px; }
.caption-input { min-height: 160px; }
.fold { border: 1px solid var(--border); border-radius: var(--radius); padding: 0 16px; background: var(--surface); }
.fold > summary { cursor: pointer; min-height: 52px; display: flex; align-items: center; gap: 4px; list-style: none; }
.fold > summary::-webkit-details-marker { display: none; }
.fold > summary::after { content: "›"; margin-left: auto; font-size: 22px; color: var(--muted); transition: transform .15s; }
.fold[open] > summary::after { transform: rotate(90deg); }
.fold[open] { padding-bottom: 16px; }
.fold .section-title { margin: 0; font-size: 17px; }
.arrange-list { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }
.arrange-row { display: flex; align-items: center; gap: 4px; border-bottom: 1px solid var(--border); padding: 6px 0; }
.arrange-main { flex: 1; min-width: 0; display: flex; gap: 10px; align-items: center; background: transparent; border: 0; text-align: left; cursor: pointer; padding: 4px 0; min-height: 48px; }
.row-thumb { width: 44px; height: auto; aspect-ratio: var(--ar, 4 / 5); border-radius: 6px; flex: none; background: var(--surface-2); }
.arrange-text { min-width: 0; font-size: 15px; }
.arrange-btns { display: flex; flex: none; }
.kv-list { display: flex; flex-direction: column; gap: 6px; }
.kv { display: grid; grid-template-columns: minmax(90px, 30%) 1fr; gap: 10px; }
.src-list { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 6px; font-size: 15px; }
.src-link { display: inline-flex; align-items: center; justify-content: center; min-width: 44px; min-height: 44px; margin: -10px 0; text-decoration: none; font-size: 18px; vertical-align: middle; }
.src-list a.link:not(.src-link) { display: inline-block; padding: 13px 0; }
.media-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 10px; }
.media-pick { border: 2px solid var(--border); border-radius: 10px; padding: 4px; background: var(--surface); cursor: pointer; display: flex; flex-direction: column; gap: 4px; min-height: 48px; }
.media-pick.on { border-color: var(--text); }
.media-pick img { width: 100%; aspect-ratio: 4 / 5; object-fit: cover; border-radius: 6px; }

/* ---------- slide editor ---------- */
.slide-nav { margin-bottom: 10px; flex-wrap: nowrap; }
.slide-nav > .center { min-width: 0; flex: 1; }
.editor-grid { display: grid; grid-template-columns: minmax(0, 1fr); gap: 20px; }
.editor-preview .preview-stage { max-width: 340px; }
@media (min-width: 900px) {
  .editor-grid { grid-template-columns: minmax(0, 420px) minmax(0, 1fr); align-items: start; }
  .editor-preview { position: sticky; top: 76px; }
  .editor-preview .preview-stage { max-width: 420px; }
}
.editor-form { min-width: 0; }
.editor-form .field:first-child, .editor-form fieldset:first-child { margin-top: 0; }
.pic-card .row-wrap { margin-top: 6px; }
.quote-card blockquote.original { font-family: var(--serif); font-size: 17px; margin: 8px 0; padding-left: 12px; border-left: 3px solid var(--accent); white-space: pre-wrap; }
.tools { border-top: 1px solid var(--border); padding-top: 14px; }
.save-bar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 25;
  background: color-mix(in srgb, var(--bg) 94%, transparent);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  border-top: 1px solid var(--border); padding: 10px 16px calc(10px + env(safe-area-inset-bottom));
}
.save-bar-inner { max-width: 1100px; margin: 0 auto; display: flex; gap: 8px; align-items: center; }
.save-bar.dirty { border-top-color: var(--focus); }
@media (max-width: 480px) {
  .save-bar-inner .btn { padding: 10px 12px; font-size: 15px; }
  .save-bar-inner .btn-ghost { display: none; }
}

/* ---------- history ---------- */
.filters { display: flex; flex-direction: column; gap: 10px; margin: 12px 0; }
.search-row { display: flex; gap: 8px; align-items: center; position: relative; }
.search-row .search { padding-left: 42px; flex: 1; min-width: 0; }
.search-icon { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); display: flex; pointer-events: none; }
.search-row .sort { width: auto; flex: none; max-width: 42%; }
@media (max-width: 520px) {
  .search-row { flex-wrap: wrap; }
  .search-row .search { flex: 1 1 100%; }
  .search-row .search-icon { top: 24px; }
  .search-row .sort { max-width: none; width: 100%; }
}
.hist-activity { padding: 0 12px 10px; }
.hist-activity > summary { cursor: pointer; min-height: 48px; display: flex; align-items: center; gap: 6px; font-size: 15px; color: var(--muted); font-weight: 600; list-style: none; width: fit-content; }
.hist-activity > summary::-webkit-details-marker { display: none; }
.hist-activity > summary::after { content: "›"; font-size: 20px; transition: transform .15s; }
.hist-activity[open] > summary::after { transform: rotate(90deg); }
.activity-list { list-style: none; margin: 4px 0 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.activity-item { display: flex; gap: 10px; align-items: flex-start; font-size: 15px; }
.activity-item.undone .activity-text { text-decoration: line-through; color: var(--muted); }
.activity-icon { flex: none; width: 22px; height: 22px; display: inline-flex; align-items: center; justify-content: center; color: var(--muted); margin-top: 1px; }
.activity-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--border); }
.activity-body { display: flex; flex-direction: column; min-width: 0; }
.activity-date { font-size: 13px; }
.chip-row { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; -webkit-overflow-scrolling: touch; scrollbar-width: thin; }
.fchip {
  flex: none; display: inline-flex; align-items: center; gap: 6px; min-height: 48px; padding: 0 14px;
  border-radius: 999px; border: 1px solid var(--border); background: var(--surface); cursor: pointer; font-weight: 600; font-size: 15px;
}
.fchip.on { background: var(--primary); color: var(--primary-text); border-color: var(--primary); }
.fchip-count { font-size: 12px; opacity: .7; font-variant-numeric: tabular-nums; }
.hist-row { padding: 0; overflow: hidden; }
.hist-row .card-actions { padding: 0 12px 12px; margin-top: 0; }
.hist-dates { display: flex; flex-wrap: wrap; gap: 4px 12px; margin-top: 4px; }
.posted-date { color: var(--success); display: inline-flex; align-items: center; }
.hist-summary { margin: 4px 0 10px; }
#main > .page > .btn.block { margin-top: 16px; }

/* ---------- settings ---------- */
.engine-card { margin-bottom: 10px; }
.engine-state { font-size: 17px; }
.dot { width: 12px; height: 12px; border-radius: 50%; flex: none; }
.dot.ok { background: #2c9a5b; }
.dot.maybe { background: #d6a531; }
.dot.bad { background: #d24b3e; }
.fix-box { background: var(--warn-bg); border-radius: 10px; padding: 12px; margin: 8px 0; }
.fix-box p { margin: 6px 0 0; }
.big-url { font-size: 22px; font-weight: 700; margin: 4px 0; word-break: break-all; }
.settings-page > .btn.big { margin-top: 24px; }
.settings-page > .card:last-child { margin-top: 24px; }

/* ---------- modal ---------- */
.modal-back {
  position: fixed; inset: 0; z-index: 100; background: rgba(0,0,0,.45);
  display: flex; align-items: flex-end; justify-content: center; opacity: 0; transition: opacity .18s;
}
.modal-back.show { opacity: 1; }
.modal {
  background: var(--surface); color: var(--text); width: 100%; max-height: 92vh; max-height: 92dvh;
  border-radius: 20px 20px 0 0; display: flex; flex-direction: column; outline: none;
  transform: translateY(24px); transition: transform .2s; padding-bottom: env(safe-area-inset-bottom);
}
.modal-back.show .modal { transform: none; }
.modal-head { display: flex; align-items: center; gap: 8px; padding: 8px 8px 0 18px; min-height: 56px; }
.modal-title { flex: 1; font-size: 19px; margin: 0; }
.modal-body { padding: 8px 18px 16px; overflow-y: auto; overscroll-behavior: contain; flex: 1; }
.modal-foot { display: flex; gap: 10px; padding: 12px 18px 16px; border-top: 1px solid var(--border); flex-wrap: wrap; }
/* basis = label width: buttons share a row only when their labels fit on one line, otherwise each gets a full row */
.modal-foot .btn { flex: 1 1 auto; }
.confirm-text { font-size: 18px; margin: 4px 0 8px; }
.modal.full { height: 100vh; height: 100dvh; max-height: none; border-radius: 0; }
@media (min-width: 720px) {
  .modal-back { align-items: center; padding: 24px; }
  .modal { width: min(560px, 100%); border-radius: 20px; max-height: 88vh; }
  .modal.wide { width: min(880px, 100%); }
  .modal.full { width: min(1000px, 100%); height: auto; max-height: 94vh; border-radius: 20px; }
}

/* ---------- crop editor ---------- */
.crop-wrap { display: flex; flex-direction: column; gap: 12px; }
.crop-help { margin: 0; }
.crop-stage { display: flex; flex-direction: column; align-items: center; gap: 12px; }
.crop-frame {
  position: relative; aspect-ratio: var(--ar, 4 / 5); width: min(100%, calc((100dvh - 440px) * var(--arn, 0.8)));
  min-width: 200px; background: #111; border-radius: 8px; overflow: hidden; touch-action: none; cursor: grab;
  box-shadow: 0 0 0 1px var(--border);
}
.crop-frame:active { cursor: grabbing; }
.crop-canvas, .crop-overlay { position: absolute; inset: 0; width: 100%; height: 100%; display: block; pointer-events: none; }
.crop-side { width: 100%; display: flex; justify-content: center; }
.crop-mini-wrap { width: min(220px, 70%); display: flex; justify-content: center; }
.crop-mini { display: block; border-radius: 6px; cursor: crosshair; touch-action: none; box-shadow: 0 0 0 1px var(--border); }
.crop-zoom { display: flex; align-items: center; gap: 10px; color: var(--muted); }
.crop-slider { flex: 1; height: 40px; accent-color: var(--primary); }
.crop-tools { display: flex; gap: 4px 10px; flex-wrap: wrap; align-items: center; }
.crop-tools .check { gap: 8px; min-height: 44px; }
.crop-tools .btn.small { min-height: 44px; }
@media (max-width: 899px) { .crop-wrap { gap: 8px; } .crop-stage { gap: 8px; } }
@media (min-width: 900px) {
  .crop-stage { flex-direction: row; align-items: flex-start; justify-content: center; }
  .crop-frame { width: min(100%, calc((94vh - 300px) * var(--arn, 0.8)), 520px); }
  .crop-side { width: 220px; }
  .crop-mini-wrap { width: 220px; }
}

/* fallback save grid */
.save-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 12px; }
.save-item { display: flex; flex-direction: column; gap: 6px; }
.save-item img { width: 100%; aspect-ratio: var(--ar, 4 / 5); object-fit: cover; border-radius: 8px; background: var(--surface-2); }
.caption-copy {
  font-size: 15px; line-height: 1.5; white-space: pre-wrap; padding: 11px 14px; border-radius: 12px;
  border: 1px solid var(--border); background: var(--surface); max-height: 40vh; overflow-y: auto;
  -webkit-user-select: all; user-select: all;
}
.nowrap { white-space: nowrap; }
/* hashtag chips (a textarea would break Korean tags right after the '#') */
.tag-list { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.tag-chip {
  display: inline-flex; align-items: center; min-height: 48px; padding-left: 14px; border-radius: 999px;
  background: var(--surface-2); border: 1px solid var(--border); white-space: nowrap; max-width: 100%;
}
.tag-text { overflow: hidden; text-overflow: ellipsis; }
.tag-x {
  display: inline-flex; align-items: center; justify-content: center; width: 44px; min-height: 46px; flex: none;
  border: 0; background: transparent; color: var(--muted); cursor: pointer; border-radius: 999px;
}
.tag-add { gap: 8px; }
.tag-add .input { flex: 1; min-width: 0; }
.more-link { display: inline-flex; align-items: center; min-height: 48px; padding: 0 8px; }

/* ---------- toast ---------- */
.toasts { position: fixed; left: 0; right: 0; bottom: calc(84px + env(safe-area-inset-bottom)); z-index: 200; display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; padding: 0 16px; }
.toast {
  pointer-events: auto; max-width: 560px; width: fit-content; padding: 12px 18px; border-radius: 12px;
  background: #1f2024; color: #fff; box-shadow: 0 6px 24px rgba(0,0,0,.25); font-size: 15px;
  opacity: 0; transform: translateY(10px); transition: opacity .2s, transform .2s;
}
.toast.show { opacity: 1; transform: none; }
.toast-success { background: #1f5c39; }
.toast-error { background: #9b2d23; }
:root[data-theme="dark"] .toast { background: #f0efed; color: #121316; }
:root[data-theme="dark"] .toast-success { background: #6cc38f; color: #0e1a13; }
:root[data-theme="dark"] .toast-error { background: #f08578; color: #200b08; }

/* output format switch (post view) */
.format-box { display: flex; flex-direction: column; gap: 6px; max-width: 520px; margin: 16px auto 0; }
@media (min-width: 900px) { .thumbs-col .format-box { max-width: none; margin: 16px 0 0; } }
.format-box .field-label { margin: 0; }

/* ---------- idea thumbnails + image viewer (public/js/viewer.js) ---------- */
.row-line { display: flex; align-items: center; }
.row-card > .row-line, .hist-row > .row-line { padding: 0 0 0 12px; }
.row-line > .row-link { flex: 1; min-width: 0; padding-left: 14px; }
.idea-row { display: flex; align-items: flex-start; gap: 14px; padding: 16px 16px 4px; }
.idea-row > .idea-main { flex: 1; min-width: 0; padding: 0; }
.ithumb {
  position: relative; flex: none; width: 64px; height: 80px; padding: 0; margin: 0; border: 0; border-radius: 10px;
  overflow: hidden; cursor: zoom-in; color: var(--accent);
  background: color-mix(in srgb, var(--accent) 12%, var(--surface-2));
  display: inline-flex; align-items: center; justify-content: center;
}
.ithumb:disabled { cursor: default; opacity: 1; }
.ithumb:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.ithumb.has-img { background: var(--surface-2); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--text) 8%, transparent); }
.ithumb-img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; display: block; }
.ithumb-ph { display: inline-flex; opacity: .85; }
.ithumb:not(.has-img):not(.no-img):disabled .ithumb-ph { animation: ithumb-pulse 1.4s ease-in-out infinite; }
@keyframes ithumb-pulse { 50% { opacity: .35; } }
@media (prefers-reduced-motion: reduce) { .ithumb-ph { animation: none !important; } }
@media (min-width: 720px) {
  .idea-card .ithumb, .row-line .ithumb { width: 80px; height: 100px; }
}

html.iv-open, html.iv-open body { overflow: hidden; }
.iv {
  position: fixed; inset: 0; z-index: 150; display: flex; flex-direction: column;
  background: var(--surface-2); color: var(--text);
  opacity: 0; transition: opacity .16s; outline: none;
}
:root[data-theme="dark"] .iv { background: #08090b; }
.iv.show { opacity: 1; }
.iv-stage { position: absolute; inset: 0; overflow: hidden; touch-action: none; cursor: zoom-in; user-select: none; -webkit-user-select: none; }
.iv.zoomed .iv-stage { cursor: grab; }
.iv.zoomed .iv-stage:active { cursor: grabbing; }
.iv-img { position: absolute; left: 0; top: 0; transform-origin: 0 0; max-width: none; will-change: transform; -webkit-user-drag: none; }
.iv-busy { position: absolute; left: 50%; bottom: calc(96px + env(safe-area-inset-bottom)); transform: translateX(-50%); pointer-events: none; }
.iv-top {
  position: relative; display: flex; align-items: center; gap: 8px; pointer-events: none;
  padding: calc(8px + env(safe-area-inset-top)) 12px 8px 16px;
}
.iv-hint-wrap { flex: 1; min-width: 0; display: flex; }
.iv-hint {
  min-width: 0; font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  padding: 6px 12px; border-radius: 999px; background: color-mix(in srgb, var(--surface) 88%, transparent); transition: opacity .2s;
}
.iv.zoomed .iv-hint { opacity: 0; }
.iv-tools { display: flex; gap: 6px; pointer-events: auto; }
.iv-btn {
  width: 44px; height: 44px; border-radius: 999px; border: 1px solid var(--border); display: inline-flex;
  align-items: center; justify-content: center; cursor: pointer; padding: 0;
  background: color-mix(in srgb, var(--surface) 88%, transparent); color: var(--text);
  -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
}
.iv-btn:hover:not(:disabled) { background: var(--surface-2); }
.iv-btn:disabled { opacity: .4; cursor: default; }
.iv-btn:focus-visible, .iv-source:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.iv-bar {
  position: relative; margin-top: auto; display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  background: color-mix(in srgb, var(--surface) 90%, transparent); border-top: 1px solid var(--border);
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
}
.iv-caption { flex: 1 1 200px; min-width: 0; }
.iv-title { font-weight: 700; font-size: 16px; line-height: 1.3; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.iv-credit { font-size: 13px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.iv-source {
  display: inline-flex; align-items: center; gap: 6px; min-height: 44px; padding: 0 14px; border-radius: 999px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text); font-size: 14px; font-weight: 600;
  text-decoration: none; white-space: nowrap;
}
.iv-source:hover { background: var(--surface-2); }

/* Gemini key help + token usage line */
.help-card p { margin: 0 0 8px; }
.steps { margin: 0 0 8px; padding-left: 22px; }
.steps li { margin: 4px 0; overflow-wrap: anywhere; }
.usage-line { font-variant-numeric: tabular-nums; }

/* per-action AI engine picker */
.engine-pick { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.engine-pick .field-label { margin: 0; }

/* password page */
.login-page { display: flex; align-items: center; justify-content: center; min-height: 100vh; min-height: 100dvh; padding: 16px; }
.login-card { width: 100%; max-width: 360px; display: flex; flex-direction: column; gap: 14px; text-align: center; align-items: stretch; }
.login-card img { align-self: center; }
.login-err { color: var(--danger, #c0392b); margin: 0; }

/* settings: watermark */
.wm-preview { width: 100%; max-width: 324px; height: auto; border-radius: 10px; box-shadow: 0 4px 18px rgba(0,0,0,.18); }
.wm-logo { height: 56px; max-width: 160px; object-fit: contain; border-radius: 6px;
  background: repeating-conic-gradient(#d8d8d8 0 25%, #fff 0 50%) 0 0 / 12px 12px; }

/* slide editor: museum wall choices */
.chip-pick { display: flex; flex-wrap: wrap; gap: 8px; }
.chip-opt { display: inline-flex; align-items: center; gap: 8px; padding: 8px 12px; border-radius: 999px;
  border: 1px solid var(--line, rgba(0,0,0,.15)); background: transparent; color: inherit; font: inherit; font-size: 15px; cursor: pointer; }
.chip-opt.on { border-color: var(--accent, #B8893A); box-shadow: inset 0 0 0 1px var(--accent, #B8893A); font-weight: 600; }
.chip-opt .swatch { width: 18px; height: 18px; border-radius: 50%; box-shadow: inset 0 0 0 1px rgba(0,0,0,.25); }

/* post preview: tap to zoom */
.preview-stage.zoomable { cursor: zoom-in; }
.zoom-hint { position: absolute; right: 10px; bottom: 10px; width: 32px; height: 32px; border-radius: 50%;
  display: grid; place-items: center; background: rgba(0,0,0,.45); color: #fff; pointer-events: none; }
