:root {
  --bg: #f5f5f7;
  --surface: rgba(255, 255, 255, 0.9);
  --surface-strong: #fff;
  --text: #1d1d1f;
  --muted: #6e6e73;
  --line: rgba(29, 29, 31, 0.1);
  --blue: #0066cc;
  --blue-bright: #0071e3;
  --blue-soft: #eaf4ff;
  --red: #b42318;
  --red-soft: #fff0ee;
  --green: #067647;
  --radius: 24px;
  --shadow: 0 14px 40px rgba(0, 0, 0, 0.06);
  --font: "Pretendard Variable", Pretendard, "Apple SD Gothic Neo", "Noto Sans KR", sans-serif;
}

* { box-sizing: border-box; }
html { color-scheme: light; background: var(--bg); }
body { margin: 0; color: var(--text); background: var(--bg); font-family: var(--font); -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
a { color: inherit; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.skip-link { position: fixed; z-index: 1000; top: 10px; left: 10px; padding: 12px 18px; color: #fff; background: #000; border-radius: 12px; transform: translateY(-150%); }
.skip-link:focus { transform: none; }
:focus-visible { outline: 3px solid rgba(0, 113, 227, 0.45); outline-offset: 3px; }

.button { display: inline-flex; min-height: 44px; align-items: center; justify-content: center; gap: 8px; padding: 0 18px; border: 1px solid transparent; border-radius: 999px; font-weight: 700; cursor: pointer; transition: transform .18s ease, background .18s ease, opacity .18s ease; text-decoration: none; }
.button:hover { transform: translateY(-1px); }
.button:disabled { opacity: .42; cursor: not-allowed; transform: none; }
.button-primary { color: #fff; background: var(--blue-bright); }
.button-primary:hover { background: var(--blue); }
.button-quiet { color: var(--text); border-color: var(--line); background: rgba(255,255,255,.72); }
.button-danger { color: var(--red); border-color: rgba(180,35,24,.18); background: var(--red-soft); }
.text-link, .text-button { color: var(--blue); font-weight: 700; text-decoration: none; }
.text-button { padding: 8px; border: 0; background: transparent; cursor: pointer; }
.eyebrow { margin: 0 0 10px; color: var(--blue); font-size: 12px; line-height: 1; font-weight: 800; letter-spacing: .14em; }

.login-view { min-height: 100vh; display: grid; place-items: center; padding: 28px; background: radial-gradient(circle at 75% 15%, rgba(0,113,227,.13), transparent 32%), linear-gradient(145deg, #fff 0%, #f5f5f7 64%); }
.login-panel { width: min(100%, 520px); padding: 52px; border: 1px solid rgba(255,255,255,.9); border-radius: 32px; background: rgba(255,255,255,.78); box-shadow: 0 30px 80px rgba(0,0,0,.1); backdrop-filter: blur(24px) saturate(150%); }
.login-brand, .admin-brand { display: inline-flex; align-items: center; gap: 9px; margin-bottom: 54px; font-weight: 800; text-decoration: none; }
.brand-number { display: inline-grid; width: 30px; height: 30px; place-items: center; color: #fff; background: var(--blue-bright); border-radius: 9px; }
.login-panel h1 { margin: 0; font-size: clamp(38px, 7vw, 58px); line-height: 1.05; letter-spacing: -.055em; }
.login-copy { margin: 18px 0 38px; color: var(--muted); line-height: 1.7; }
.login-form label { display: block; margin-bottom: 10px; font-weight: 700; }
.password-row { display: grid; grid-template-columns: 1fr auto; gap: 10px; }
.password-row input, .search-field input, select, .field-grid input, textarea { width: 100%; border: 1px solid var(--line); color: var(--text); background: rgba(255,255,255,.9); border-radius: 14px; }
.password-row input { min-height: 50px; padding: 0 15px; }
.form-error { margin: 12px 0 0; color: var(--red); font-weight: 700; }
.login-panel > .text-link { display: inline-block; margin-top: 32px; }

.admin-header { position: sticky; z-index: 50; top: 0; min-height: 72px; display: flex; align-items: center; justify-content: space-between; padding: 12px 28px; border-bottom: 1px solid var(--line); background: rgba(245,245,247,.8); backdrop-filter: blur(24px) saturate(180%); }
.admin-brand { margin: 0; }
.admin-brand small { padding-left: 10px; border-left: 1px solid var(--line); color: var(--muted); font-weight: 600; }
.header-actions { display: flex; align-items: center; gap: 10px; }
.sync-time { margin-right: 10px; color: var(--muted); font-size: 13px; }
.admin-layout { display: grid; grid-template-columns: 248px minmax(0, 1fr); min-height: calc(100vh - 72px); }
.admin-nav { position: sticky; top: 72px; height: calc(100vh - 72px); display: flex; flex-direction: column; gap: 8px; padding: 28px 18px; border-right: 1px solid var(--line); }
.nav-item { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; padding: 16px; border: 0; border-radius: 16px; color: var(--muted); background: transparent; text-align: left; cursor: pointer; }
.nav-item span { color: inherit; font-weight: 750; }
.nav-item small { font-size: 12px; opacity: .75; }
.nav-item:hover { background: rgba(255,255,255,.72); }
.nav-item.is-active { color: var(--blue); background: var(--blue-soft); }
.admin-content { min-width: 0; padding: clamp(30px, 4vw, 64px); }
.panel { max-width: 1500px; margin: 0 auto; }
.panel-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; margin-bottom: 32px; }
.panel-heading h1 { margin: 0; font-size: clamp(36px, 5vw, 64px); line-height: 1; letter-spacing: -.055em; }
.panel-heading > div > p:not(.eyebrow) { max-width: 680px; margin: 14px 0 0; color: var(--muted); line-height: 1.65; }
.heading-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.surface, .metric-card { border: 1px solid rgba(29,29,31,.08); background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); }
.metric-grid { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 16px; margin-bottom: 18px; }
.metric-card { min-height: 190px; display: flex; flex-direction: column; justify-content: space-between; padding: 26px; }
.metric-card span { color: var(--muted); font-weight: 700; }
.metric-card strong { color: var(--blue); font-size: clamp(54px, 6vw, 84px); line-height: .9; letter-spacing: -.06em; }
.metric-card small { color: var(--muted); }
.overview-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 18px; }
.chart-card, .recent-card, .editor-card { padding: 28px; }
.card-heading { display: flex; align-items: center; justify-content: space-between; gap: 20px; margin-bottom: 24px; }
.card-heading h2 { margin: 0; font-size: 24px; letter-spacing: -.035em; }
.card-heading p:not(.eyebrow) { margin: 7px 0 0; color: var(--muted); }
.bar-chart { display: grid; gap: 14px; min-height: 240px; align-content: start; }
.bar-row { display: grid; grid-template-columns: minmax(110px, .8fr) minmax(120px, 2fr) 38px; align-items: center; gap: 12px; font-size: 13px; }
.bar-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); }
.bar-track { height: 8px; overflow: hidden; background: #e8e8ed; border-radius: 999px; }
.bar-fill { height: 100%; background: linear-gradient(90deg, var(--blue), #52a8ff); border-radius: inherit; }
.bar-count { color: var(--text); text-align: right; font-weight: 800; }
.recent-card { margin-top: 18px; }
.recent-list { display: grid; }
.recent-item { display: grid; grid-template-columns: minmax(110px,.6fr) minmax(130px,.7fr) minmax(0,1.7fr) auto; align-items: center; gap: 16px; padding: 17px 0; border-top: 1px solid var(--line); }
.recent-item:first-child { border-top: 0; }
.recent-item strong { font-size: 15px; }
.recent-item span { color: var(--muted); font-size: 14px; }
.status-pill { display: inline-flex; align-items: center; justify-content: center; min-height: 28px; padding: 0 10px; border-radius: 999px; font-size: 12px; font-weight: 800; }
.status-public { color: var(--green); background: #ecfdf3; }
.status-hidden { color: var(--muted); background: #eeeef2; }

.table-surface { overflow: hidden; }
.table-toolbar, .message-toolbar { display: flex; align-items: center; gap: 12px; padding: 18px; }
.search-field { flex: 1; }
.search-field input, select { min-height: 46px; padding: 0 14px; }
select { width: auto; min-width: 150px; }
.selection-status { margin-left: auto; color: var(--muted); font-size: 13px; font-weight: 700; white-space: nowrap; }
.table-wrap { overflow-x: auto; border-top: 1px solid var(--line); }
table { width: 100%; border-collapse: collapse; min-width: 1080px; }
th, td { padding: 16px 14px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
th { position: sticky; top: 0; z-index: 1; color: var(--muted); background: rgba(255,255,255,.96); font-size: 12px; letter-spacing: .02em; }
td { font-size: 13px; line-height: 1.5; }
.check-cell { width: 48px; text-align: center; }
.schedule-cell { min-width: 250px; max-width: 340px; }
.empty-state { margin: 0; padding: 64px 24px; color: var(--muted); text-align: center; }
.message-toolbar { margin-bottom: 18px; }
.message-grid { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 16px; }
.message-card { min-height: 220px; display: flex; flex-direction: column; padding: 24px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface-strong); box-shadow: var(--shadow); }
.message-card blockquote { flex: 1; margin: 0; font-size: 20px; line-height: 1.55; letter-spacing: -.02em; }
.message-meta { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 24px; padding-top: 16px; border-top: 1px solid var(--line); }
.message-person { color: var(--muted); font-size: 13px; }
.message-toggle { min-height: 36px; padding: 0 13px; border: 1px solid var(--line); border-radius: 999px; background: #fff; font-weight: 750; cursor: pointer; }
.content-grid { display: grid; grid-template-columns: minmax(0,1fr) minmax(360px,.7fr); gap: 18px; }
.field-grid { display: grid; gap: 20px; }
.field-grid label, .json-field { display: grid; gap: 9px; color: var(--muted); font-size: 13px; font-weight: 700; }
.field-grid input, textarea { padding: 14px; resize: vertical; line-height: 1.55; }
details { border-top: 1px solid var(--line); }
summary { padding: 18px 0; color: var(--blue); font-weight: 750; cursor: pointer; }
.json-field textarea { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; }
.save-status { min-height: 24px; color: var(--muted); }
.toast { position: fixed; z-index: 100; right: 24px; bottom: 24px; max-width: min(420px, calc(100vw - 48px)); padding: 15px 20px; color: #fff; background: rgba(29,29,31,.92); border-radius: 14px; box-shadow: var(--shadow); }

@media (max-width: 1120px) {
  .metric-grid { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .overview-grid, .content-grid { grid-template-columns: 1fr; }
  .message-grid { grid-template-columns: repeat(2, minmax(0,1fr)); }
}

@media (max-width: 780px) {
  .admin-header { align-items: flex-start; padding: 12px 16px; }
  .admin-brand small, .sync-time, .header-actions .button-quiet:first-of-type { display: none; }
  .admin-layout { display: block; }
  .admin-nav { position: sticky; z-index: 40; top: 72px; width: 100%; height: auto; flex-direction: row; gap: 6px; overflow-x: auto; padding: 10px 14px; border: 0; border-bottom: 1px solid var(--line); background: rgba(245,245,247,.92); backdrop-filter: blur(16px); }
  .nav-item { min-width: max-content; padding: 10px 14px; }
  .nav-item small { display: none; }
  .admin-content { padding: 30px 16px 70px; }
  .panel-heading { align-items: flex-start; flex-direction: column; }
  .panel-heading h1 { font-size: 40px; }
  .heading-actions { width: 100%; }
  .heading-actions .button { flex: 1; }
  .metric-card { min-height: 150px; padding: 20px; }
  .metric-card strong { font-size: 56px; }
  .recent-item { grid-template-columns: 1fr auto; }
  .recent-item span:nth-child(3) { grid-column: 1 / -1; }
  .table-toolbar, .message-toolbar { align-items: stretch; flex-direction: column; }
  select { width: 100%; }
  .selection-status { margin-left: 0; }
  .message-grid { grid-template-columns: 1fr; }
}

@media (max-width: 520px) {
  .login-view { padding: 14px; }
  .login-panel { padding: 34px 24px; border-radius: 26px; }
  .login-brand { margin-bottom: 42px; }
  .password-row { grid-template-columns: 1fr; }
  .metric-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .metric-card { min-height: 132px; border-radius: 20px; }
  .metric-card strong { font-size: 46px; }
  .bar-row { grid-template-columns: 90px 1fr 32px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; animation-duration: .01ms !important; }
}
