:root {
  --canvas: #ffffff;
  --surface: #f5f5f7;
  --surface-2: #ececf0;
  --card: #ffffff;
  --ink: #1d1d1f;
  --muted: #626269;
  --tertiary: #86868b;
  --line: rgba(0, 0, 0, 0.09);
  --sep: #e5e5ea;
  --accent: #0066cc;
  --accent-hover: #0055b3;
  --accent-soft: rgba(0, 102, 204, 0.09);
  --studio: #6f39c9;
  --studio-soft: rgba(111, 57, 201, 0.12);
  --site: #0a84a0;
  --site-soft: rgba(10, 132, 160, 0.12);
  --green: #18794e;
  --green-soft: rgba(48, 209, 88, 0.14);
  --orange: #bd5b00;
  --orange-soft: rgba(255, 149, 0, 0.14);
  --danger: #d70015;
  --danger-soft: rgba(255, 59, 48, 0.11);
  --radius: 18px;
  --pill: 9999px;
  --shadow: 0 3px 12px rgba(0, 0, 0, 0.07), 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-sheet: 0 28px 80px rgba(0, 0, 0, 0.2), 0 2px 10px rgba(0, 0, 0, 0.06);
  color-scheme: light;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; background: var(--canvas); color: var(--ink); }
body { font-family: "Pretendard Variable", Pretendard, -apple-system, "Apple SD Gothic Neo", "Malgun Gothic", sans-serif; font-size: 14px; line-height: 1.5; -webkit-font-smoothing: antialiased; }
h1, h2, h3, p { margin: 0; }
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted { color: var(--muted); }
.small { font-size: 12px; }

.btn { border: 0; border-radius: var(--pill); padding: 10px 20px; font-weight: 600; font-size: 14px; background: var(--surface); color: var(--ink); transition: background-color 140ms ease, transform 120ms ease; white-space: nowrap; text-decoration: none; display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
.btn:active:not(:disabled) { transform: scale(0.97); }
.btn:disabled { opacity: 0.45; cursor: default; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--accent-hover); }
.btn-quiet:hover:not(:disabled) { background: var(--surface-2); }
.btn.small { padding: 7px 14px; font-size: 13px; }
.linkish { border: 0; background: none; color: var(--accent); font-weight: 600; padding: 4px 2px; }
.linkish.danger { color: var(--danger); }
.icon-btn { width: 34px; height: 34px; border: 0; border-radius: var(--pill); background: var(--surface); font-size: 18px; line-height: 1; color: var(--muted); display: inline-grid; place-items: center; }
.icon-btn:hover { background: var(--surface-2); }
input[type=text], input[type=password], input[type=datetime-local], textarea { width: 100%; border: 1.5px solid var(--sep); border-radius: 14px; padding: 10px 14px; background: var(--card); outline: none; transition: border-color 140ms ease, box-shadow 140ms ease; }
input:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3.5px rgba(0, 102, 204, 0.18); }
textarea { resize: vertical; line-height: 1.65; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Login */
.login { min-height: 100vh; display: grid; place-items: center; background: var(--surface); padding: 16px; }
.login-card { width: min(360px, 100%); background: var(--card); border-radius: 26px; padding: 32px 28px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 12px; text-align: center; align-items: stretch; }
.login-card .brand-mark { align-self: center; width: 44px; height: 44px; font-size: 18px; }
.login-card h1 { font-size: 22px; letter-spacing: -0.02em; }
.login-card input { text-align: center; font-size: 18px; letter-spacing: 0.3em; }
.login-error { color: var(--danger); font-size: 13px; min-height: 1.5em; }

/* Top bar */
.brand-mark { width: 30px; height: 30px; border-radius: 9px; background: var(--ink); color: #fff; display: inline-grid; place-items: center; font-weight: 700; font-size: 13px; flex: none; }
.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 16px; padding: 12px 28px; background: rgba(255, 255, 255, 0.9); backdrop-filter: blur(18px) saturate(180%); border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 10px; }
.brand strong { font-size: 16px; letter-spacing: -0.02em; }
.handle-chip { font-size: 12px; color: var(--muted); background: var(--surface); padding: 3px 10px; border-radius: var(--pill); }
.tabs { display: flex; gap: 4px; margin-left: 12px; }
.tabs button { border: 0; background: none; padding: 8px 14px; border-radius: var(--pill); font-weight: 600; color: var(--muted); display: inline-flex; align-items: center; gap: 6px; }
.tabs button[aria-current=page] { background: var(--surface); color: var(--ink); }
.tabs b { background: var(--danger); color: #fff; font-size: 11px; border-radius: var(--pill); padding: 1px 7px; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.slots-chip { font-size: 12.5px; color: var(--muted); }

.main { width: min(1280px, calc(100% - 32px)); margin: 0 auto; padding: 22px 0 64px; }
.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.toolbar-right { display: flex; align-items: center; gap: 14px; }
.date-nav { display: flex; align-items: center; gap: 8px; }
.date-nav h2 { font-size: 20px; letter-spacing: -0.02em; margin-left: 8px; }
.legend { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--muted); }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; margin-left: 6px; }
.dot.studio { background: var(--studio); }
.dot.site { background: var(--site); }
.seg { display: inline-flex; padding: 3px; border-radius: var(--pill); background: var(--surface); gap: 2px; }
.seg button { border: 0; background: transparent; padding: 6px 14px; border-radius: var(--pill); font-weight: 600; font-size: 13px; color: var(--muted); }
.seg button[aria-pressed=true] { background: var(--card); color: var(--ink); box-shadow: var(--shadow); }
.seg.wide { display: flex; }
.seg.wide button { flex: 1; padding: 9px 14px; }

/* Week */
.week-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 8px; }
.day { background: var(--surface); border-radius: var(--radius); padding: 10px; min-height: 420px; display: flex; flex-direction: column; gap: 8px; transition: box-shadow 120ms ease, background-color 120ms ease; }
.day.is-past { opacity: 0.6; }
.day.is-today { background: var(--accent-soft); }
.day.is-drop { box-shadow: inset 0 0 0 2px var(--accent); }
.day-head { display: flex; align-items: baseline; justify-content: space-between; padding: 2px 4px 4px; }
.day-head b { font-size: 15px; }
.day-head span { font-size: 12px; color: var(--muted); }
.day.is-today .day-head b { color: var(--accent); }
.post { background: var(--card); border-radius: 14px; padding: 8px; box-shadow: var(--shadow); display: grid; grid-template-columns: 46px minmax(0, 1fr); gap: 8px; text-align: left; border: 0; width: 100%; border-left: 3px solid var(--studio); }
.post.site { border-left-color: var(--site); }
.post[draggable=true] { cursor: grab; }
.post.is-dragging { opacity: 0.4; }
.post-thumb { width: 46px; aspect-ratio: 9 / 16; border-radius: 8px; background: #111 center / cover no-repeat; }
.post-info { min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.post-time { font-size: 12px; font-weight: 700; display: flex; align-items: center; gap: 6px; }
.post-title { font-size: 12.5px; font-weight: 600; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.status { font-size: 10.5px; font-weight: 700; padding: 1px 7px; border-radius: var(--pill); white-space: nowrap; }
.status.scheduled { background: var(--accent-soft); color: var(--accent); }
.status.publishing { background: var(--orange-soft); color: var(--orange); }
.status.published { background: var(--green-soft); color: var(--green); }
.status.failed { background: var(--danger-soft); color: var(--danger); }
.slot-ghost { border: 1.5px dashed var(--sep); background: transparent; border-radius: 12px; padding: 7px; font-size: 12px; font-weight: 600; color: var(--tertiary); }
.slot-ghost:hover { border-color: var(--accent); color: var(--accent); background: var(--card); }

/* Month */
.month-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; }
.month-head { font-size: 12px; font-weight: 700; color: var(--muted); text-align: center; padding: 4px 0; }
.mcell { background: var(--surface); border-radius: 12px; min-height: 112px; padding: 6px; display: flex; flex-direction: column; gap: 4px; }
.mcell.is-other { opacity: 0.45; }
.mcell.is-today { background: var(--accent-soft); }
.mcell-head { display: flex; justify-content: space-between; font-size: 12px; font-weight: 700; padding: 0 2px; }
.mcell-add { border: 0; background: none; color: var(--tertiary); font-weight: 700; padding: 0 4px; border-radius: 6px; }
.mcell-add:hover { color: var(--accent); background: var(--card); }
.chip { border: 0; text-align: left; font-size: 11.5px; padding: 3px 7px; border-radius: 7px; background: var(--card); box-shadow: var(--shadow); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; border-left: 3px solid var(--studio); }
.chip.site { border-left-color: var(--site); }
.chip.failed { background: var(--danger-soft); }

/* List */
.list-tabs { display: inline-flex; gap: 6px; }
.list-tabs button { border: 0; background: var(--surface); border-radius: var(--pill); padding: 8px 16px; font-weight: 600; color: var(--muted); }
.list-tabs button b { margin-left: 4px; font-variant-numeric: tabular-nums; }
.list-tabs button[aria-pressed=true] { background: var(--ink); color: #fff; }
.list-body { display: flex; flex-direction: column; gap: 8px; }
.row { display: grid; grid-template-columns: 54px minmax(0, 1fr) auto; gap: 14px; align-items: center; background: var(--surface); border-radius: var(--radius); padding: 10px 14px; }
.row .post-thumb { width: 54px; }
.row-main { min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.row-top { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--muted); flex-wrap: wrap; }
.row-title { font-weight: 700; font-size: 14px; }
.row-caption { font-size: 12.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-error { font-size: 12.5px; color: var(--danger); }
.row-actions { display: flex; gap: 6px; }
.src { font-size: 10.5px; font-weight: 700; padding: 1px 7px; border-radius: var(--pill); background: var(--studio-soft); color: var(--studio); }
.src.site { background: var(--site-soft); color: var(--site); }
.empty { text-align: center; color: var(--muted); padding: 60px 20px; background: var(--surface); border-radius: var(--radius); }

/* Sheets */
dialog.sheet { border: 0; padding: 0; border-radius: 26px; box-shadow: var(--shadow-sheet); background: var(--canvas); color: var(--ink); max-height: 92vh; width: min(980px, calc(100vw - 32px)); display: flex; flex-direction: column; overflow: hidden; }
dialog.sheet:not([open]) { display: none; }
dialog::backdrop { background: rgba(0, 0, 0, 0.34); backdrop-filter: blur(6px); }
.sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 22px; border-bottom: 1px solid var(--sep); }
.sheet-head h2 { font-size: 18px; letter-spacing: -0.02em; }
.sheet-foot { display: flex; align-items: center; gap: 10px; padding: 12px 22px 14px; border-top: 1px solid var(--sep); }
.foot-status { flex: 1; font-size: 13px; color: var(--muted); min-width: 0; }
.foot-status.is-error { color: var(--danger); font-weight: 600; }
.foot-status.is-ok { color: var(--green); font-weight: 600; }

.composer-body { display: grid; grid-template-columns: 300px minmax(0, 1fr); gap: 22px; padding: 18px 22px; overflow-y: auto; }
.composer-media { display: flex; flex-direction: column; gap: 10px; }
.dropzone { aspect-ratio: 9 / 16; border: 2px dashed var(--sep); border-radius: 20px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; text-align: center; padding: 20px; cursor: pointer; background: var(--surface); transition: border-color 120ms ease, background-color 120ms ease; }
.dropzone strong { font-size: 14px; }
.dropzone span { font-size: 12px; color: var(--muted); }
.dropzone.is-over, .dropzone:hover { border-color: var(--accent); background: var(--accent-soft); }
.preview { aspect-ratio: 9 / 16; border-radius: 20px; overflow: hidden; background: #000; position: relative; }
.preview video { width: 100%; height: 100%; object-fit: contain; display: block; }
.preview-error { position: absolute; inset: auto 10px 10px; background: rgba(0, 0, 0, 0.7); color: #fff; font-size: 12px; padding: 8px 10px; border-radius: 10px; }
.cover-pick { background: var(--surface); border-radius: 14px; padding: 10px 12px; }
.cover-head { display: flex; justify-content: space-between; font-size: 12.5px; font-weight: 600; margin-bottom: 4px; }
.cover-pick input { width: 100%; }

.composer-form { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.file-card { background: var(--surface); border-radius: 16px; padding: 12px 14px; display: flex; flex-direction: column; gap: 8px; }
.file-name { font-weight: 700; font-size: 13.5px; word-break: break-all; }
.checks { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 3px; font-size: 12.5px; }
.checks li::before { content: "✓"; color: var(--green); font-weight: 700; margin-right: 6px; }
.checks li.warn { color: var(--orange); }
.checks li.warn::before { content: "!"; color: var(--orange); }
.checks li.bad { color: var(--danger); font-weight: 600; }
.checks li.bad::before { content: "×"; color: var(--danger); }
.upload-bar { height: 6px; border-radius: 3px; background: var(--surface-2); overflow: hidden; }
.upload-bar i { display: block; height: 100%; width: 0; background: var(--accent); transition: width 200ms ease; }
.upload-bar.is-done i { background: var(--green); }
.upload-text { font-size: 12px; color: var(--muted); }

.field { display: flex; flex-direction: column; gap: 6px; font-size: 13px; font-weight: 600; }
.field em { font-style: normal; font-weight: 500; color: var(--tertiary); margin-left: 4px; }
.caption-meta { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); margin-top: -8px; }
.caption-meta .over { color: var(--danger); font-weight: 700; }
.when { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.when button { border: 1.5px solid var(--sep); background: var(--card); border-radius: 14px; padding: 9px 10px; display: flex; flex-direction: column; align-items: flex-start; gap: 1px; text-align: left; }
.when button b { font-size: 13px; }
.when button small { font-size: 11.5px; color: var(--muted); }
.when button[aria-pressed=true] { border-color: var(--accent); background: var(--accent-soft); }
#customTime { margin-top: 8px; }

.detail { width: min(820px, calc(100vw - 32px)); }
.detail-kicker { font-size: 12px; color: var(--muted); margin-bottom: 2px; display: flex; gap: 6px; align-items: center; }
.detail-body { display: grid; grid-template-columns: 200px minmax(0, 1fr); gap: 20px; padding: 18px 22px; overflow-y: auto; }
.detail-thumb { aspect-ratio: 9 / 16; border-radius: 16px; overflow: hidden; background: #111; }
.detail-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.detail-form { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.detail-banner { font-size: 13px; padding: 10px 12px; border-radius: 12px; background: var(--surface); color: var(--muted); }
.detail-banner.is-failed { background: var(--danger-soft); color: var(--danger); }
.detail-banner.is-published { background: var(--green-soft); color: var(--green); }

.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 11px 18px; border-radius: var(--pill); font-size: 13.5px; font-weight: 600; box-shadow: var(--shadow-sheet); z-index: 100; max-width: calc(100vw - 32px); }

@media (max-width: 900px) {
  .topbar { padding: 10px 14px; flex-wrap: wrap; }
  .slots-chip { display: none; }
  .week-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .composer-body, .detail-body { grid-template-columns: 1fr; }
  .composer-media, .detail-thumb { max-width: 260px; margin: 0 auto; width: 100%; }
  .row { grid-template-columns: 54px minmax(0, 1fr); }
  .row-actions { grid-column: 1 / -1; justify-content: flex-end; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

/* loading hint while the schedule is fetched */
body.is-loading .main { position: relative; }
body.is-loading .main::before { content: "불러오는 중…"; position: absolute; top: 18px; left: 50%; transform: translateX(-50%); font-size: 12.5px; color: var(--muted); background: var(--surface); padding: 4px 12px; border-radius: 9999px; }
