:root {
  color-scheme: light;
  --ink: #1c2431;
  --muted: #687386;
  --line: #dde2e9;
  --soft: #f4f6f9;
  --paper: #ffffff;
  --navy: #172132;
  --navy-soft: #26334a;
  --blue: #3e63dd;
  --blue-dark: #2e4db5;
  --red: #b42318;
  --green: #137a50;
  font-family: Inter, Pretendard, "Noto Sans KR", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html, body { min-height: 100%; margin: 0; }
body { color: var(--ink); background: var(--soft); }
button, input, textarea { font: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }
.sr-only, .skip-link:not(:focus) { 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:focus { position: fixed; z-index: 100; top: 12px; left: 12px; padding: 10px 14px; background: white; border-radius: 8px; }
.muted { color: var(--muted); }
.eyebrow { margin: 0 0 4px; color: var(--blue); font-size: 12px; font-weight: 750; letter-spacing: .08em; text-transform: uppercase; }
h1, h2, h3, p { margin-top: 0; }

.studio-shell { display: grid; grid-template-columns: 244px minmax(0, 1fr); min-height: 100vh; }
.sidebar { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; padding: 22px 16px; color: white; background: var(--navy); }
.studio-brand { display: flex; align-items: center; gap: 11px; margin: 0 6px 28px; }
.studio-brand strong, .studio-brand small { display: block; }
.studio-brand small { margin-top: 2px; color: #9ba8bc; }
.brand-mark { display: grid; width: 40px; height: 40px; place-items: center; border-radius: 12px; color: white; background: linear-gradient(145deg, #5577ea, #7857dc); font-weight: 800; letter-spacing: -.04em; box-shadow: 0 8px 20px rgb(47 61 120 / 35%); }
.sidebar-label { margin: 0 8px 8px; color: #8290a6; font-size: 11px; font-weight: 700; letter-spacing: .09em; text-transform: uppercase; }
.site-list { display: grid; gap: 5px; }
.site-button { width: 100%; padding: 11px 12px; border: 0; border-radius: 9px; color: #c9d0dc; background: transparent; text-align: left; }
.site-button:hover { background: var(--navy-soft); color: white; }
.site-button.is-active { background: #33415b; color: white; box-shadow: inset 3px 0 var(--blue); }
.sidebar-foot { display: grid; gap: 4px; margin-top: auto; padding: 16px 7px 0; border-top: 1px solid #303c50; }
.sidebar-foot span { margin: 0 8px 5px; color: #aab4c4; font-size: 13px; }
.sidebar .button-quiet { color: #cdd4df; }

.workspace { min-width: 0; padding: 30px clamp(20px, 4vw, 58px) 60px; }
.workspace-header, .section-heading, .editor-topline, .editor-actions, .button-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.workspace-header h1 { margin-bottom: 6px; font-size: clamp(25px, 3vw, 36px); letter-spacing: -.04em; }
.workspace-header p:last-child { margin-bottom: 0; }
.status-pill { padding: 7px 11px; border: 1px solid #c5ebd9; border-radius: 999px; color: var(--green); background: #ecfbf4; font-size: 12px; font-weight: 700; }
.tabs { display: flex; gap: 4px; margin: 26px 0 22px; border-bottom: 1px solid var(--line); }
.tab { padding: 11px 14px; border: 0; border-bottom: 2px solid transparent; color: var(--muted); background: transparent; font-weight: 650; }
.tab:hover { color: var(--ink); }
.tab.is-active { border-bottom-color: var(--blue); color: var(--blue); }
.view { min-width: 0; }
.section-heading { align-items: flex-start; margin-bottom: 18px; }
.section-heading h2 { margin-bottom: 5px; }
.section-heading p { margin-bottom: 0; }

.button { min-height: 36px; padding: 8px 12px; border: 1px solid var(--line); border-radius: 8px; color: var(--ink); background: var(--paper); font-weight: 650; }
.button:hover:not(:disabled) { border-color: #b9c1cc; background: #fafbfc; }
.button:disabled { cursor: not-allowed; opacity: .48; }
.button-primary { border-color: var(--blue); color: white; background: var(--blue); }
.button-primary:hover:not(:disabled) { border-color: var(--blue-dark); background: var(--blue-dark); }
.button-danger { border-color: #f0c5c2; color: var(--red); background: #fff8f7; }
.button-quiet { border-color: transparent; background: transparent; }

.page-workbench { display: grid; grid-template-columns: minmax(220px, 290px) minmax(0, 1fr); min-height: 650px; overflow: hidden; border: 1px solid var(--line); border-radius: 13px; background: var(--paper); box-shadow: 0 8px 25px rgb(30 42 62 / 5%); }
.block-sync-card { margin-bottom: 14px; padding: 13px 15px; border: 1px solid var(--line); border-radius: 10px; background: white; }
.block-sync-card summary { cursor: pointer; font-weight: 700; }
.block-sync-card > p { margin: 10px 0; font-size: 13px; }
.block-sync-form { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 14px; padding-top: 5px; }
.block-sync-form > label:not(.check-label) { display: grid; gap: 5px; color: #465165; font-size: 13px; font-weight: 650; }
.block-sync-form input[type=text], .block-sync-form input:not([type]) { width: 100%; padding: 8px 9px; border: 1px solid #cfd5dd; border-radius: 7px; }
.check-label { display: flex; align-items: center; gap: 7px; color: var(--muted); font-size: 13px; }
.block-sync-form .button-row, .block-result { grid-column: 1 / -1; }
.block-result { margin-top: 10px; padding: 11px 12px; border-radius: 7px; background: var(--soft); font-size: 13px; }
.block-result ul { max-height: 160px; margin-bottom: 0; overflow: auto; }
.page-browser { min-width: 0; border-right: 1px solid var(--line); background: #fafbfc; }
.search-field { display: block; padding: 14px 12px 8px; }
.search-field input, .field-grid input, .field-grid textarea, .dialog-form input { width: 100%; padding: 9px 10px; border: 1px solid #cfd5dd; border-radius: 7px; color: var(--ink); background: white; }
input:focus, textarea:focus, button:focus-visible { outline: 3px solid rgb(62 99 221 / 22%); outline-offset: 1px; }
.page-count { padding: 2px 14px 10px; color: var(--muted); font-size: 12px; }
.page-list { max-height: 590px; overflow: auto; border-top: 1px solid var(--line); }
.page-row { display: grid; gap: 3px; width: 100%; padding: 11px 13px; border: 0; border-bottom: 1px solid #e9edf2; background: transparent; text-align: left; }
.page-row strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.page-row small { overflow: hidden; color: var(--muted); text-overflow: ellipsis; white-space: nowrap; }
.page-row:hover, .page-row.is-active { background: white; }
.page-row.is-active { box-shadow: inset 3px 0 var(--blue); }
.row-meta { display: flex; align-items: center; gap: 6px; }
.private-dot { width: 7px; height: 7px; border-radius: 50%; background: #dd8b28; }
.public-dot { width: 7px; height: 7px; border-radius: 50%; background: #1e9b68; }
.empty-panel { display: grid; align-content: center; justify-items: center; gap: 7px; min-height: 500px; padding: 28px; color: var(--muted); text-align: center; }
.empty-panel strong { color: var(--ink); }
.editor { min-width: 0; padding: 18px; }
.editor-topline { padding-bottom: 14px; border-bottom: 1px solid var(--line); }
.editor-topline code { display: inline-block; max-width: min(50vw, 620px); overflow: hidden; color: var(--muted); text-overflow: ellipsis; vertical-align: middle; white-space: nowrap; }
.visibility-badge { display: inline-block; margin-right: 7px; padding: 3px 7px; border-radius: 999px; font-size: 11px; font-weight: 750; }
.visibility-badge.public { color: #08704a; background: #e6f7ef; }
.visibility-badge.private { color: #955e10; background: #fff3df; }
.field-grid { display: grid; grid-template-columns: 1fr 1.5fr; gap: 12px; margin: 15px 0; }
.field-grid label, .dialog-form label, .source-wrap { display: grid; gap: 6px; color: #465165; font-size: 13px; font-weight: 650; }
.field-grid textarea { resize: vertical; }
.editor-mode { display: flex; align-items: center; gap: 5px; margin-bottom: 10px; }
.editor-mode .muted { margin-left: 8px; font-size: 12px; }
.mode-button { padding: 7px 10px; border: 1px solid var(--line); color: var(--muted); background: white; }
.mode-button:first-child { border-radius: 7px 0 0 7px; }
.mode-button:nth-child(2) { margin-left: -6px; border-radius: 0 7px 7px 0; }
.mode-button.is-active { z-index: 1; border-color: var(--blue); color: var(--blue); background: #f2f5ff; }
.visual-wrap, .source-wrap { min-height: 440px; overflow: hidden; border: 1px solid var(--line); border-radius: 8px; background: white; }
.visual-wrap iframe { display: block; width: 100%; height: 55vh; min-height: 440px; border: 0; }
.source-wrap > span { padding: 9px 11px 0; }
.source-wrap textarea { width: 100%; min-height: 52vh; padding: 12px; resize: vertical; border: 0; border-top: 1px solid var(--line); color: #d8e1ef; background: #17202e; font: 13px/1.55 ui-monospace, SFMono-Regular, Consolas, monospace; tab-size: 2; }
.editor-actions { justify-content: flex-start; padding-top: 13px; }
.editor-actions #save-page { margin-left: auto; }
.upload-button { display: inline-flex; align-items: center; }

.theme-card { display: grid; grid-template-columns: repeat(3, minmax(150px, 1fr)); gap: 14px; max-width: 900px; padding: 22px; border: 1px solid var(--line); border-radius: 13px; background: white; }
.theme-card .theme-enable { grid-column: 1 / -1; grid-template-columns: auto 1fr; justify-content: start; }
.theme-card .theme-enable span { grid-column: auto; }
.theme-card .theme-enable small { grid-column: 1 / -1; }
.theme-card .theme-enable input { width: 19px; height: 19px; grid-column: 1; grid-row: 1; }
.theme-card label { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 6px; padding: 12px; border: 1px solid var(--line); border-radius: 9px; }
.theme-card label span { grid-column: 1 / -1; font-weight: 650; }
.theme-card input[type=color] { width: 48px; height: 36px; padding: 2px; border: 1px solid var(--line); border-radius: 6px; background: white; }
.theme-card output { font: 12px ui-monospace, monospace; }
.theme-preview { grid-column: 1 / -1; padding: 30px; border: 1px solid var(--line); border-radius: 9px; transition: background-color .2s, color .2s; }
.theme-card > button { justify-self: start; }
.job-panel { display: flex; align-items: center; gap: 14px; margin: 14px 0 22px; padding: 16px; border: 1px solid #cad4f5; border-radius: 10px; background: #f4f6ff; }
.job-panel p { margin: 4px 0 0; }
.spinner { width: 23px; height: 23px; border: 3px solid #cbd4f4; border-top-color: var(--blue); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.revision-list { display: grid; gap: 8px; max-width: 900px; }
.revision-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 13px 15px; border: 1px solid var(--line); border-radius: 9px; background: white; }
.revision-row code, .revision-row small { display: block; }
.revision-row small { margin-top: 4px; color: var(--muted); }
.empty-row { padding: 30px; border: 1px dashed #cbd2dc; border-radius: 9px; color: var(--muted); text-align: center; }
.table-wrap { overflow: auto; border: 1px solid var(--line); border-radius: 10px; background: white; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 11px 13px; border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; }
th { color: var(--muted); background: #f7f8fa; font-size: 12px; }
td { font-size: 13px; }

dialog { width: min(92vw, 520px); padding: 0; border: 0; border-radius: 13px; box-shadow: 0 24px 80px rgb(16 24 40 / 28%); }
dialog::backdrop { background: rgb(17 24 39 / 55%); backdrop-filter: blur(2px); }
.dialog-form { display: grid; gap: 15px; padding: 24px; }
.dialog-form h2 { margin-bottom: 0; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; padding-top: 6px; }
.toast { position: fixed; right: 24px; bottom: 24px; z-index: 200; max-width: min(420px, calc(100vw - 48px)); padding: 12px 15px; border-radius: 9px; color: white; background: #202a3a; box-shadow: 0 12px 36px rgb(15 23 42 / 24%); }
.toast.is-error { background: #9f2e26; }

.login-page { display: grid; min-height: 100vh; place-items: center; padding: 24px; background: radial-gradient(circle at 20% 15%, #edf1ff, transparent 35%), #f4f6f9; }
.login-card { width: min(100%, 410px); padding: 34px; border: 1px solid var(--line); border-radius: 16px; background: white; box-shadow: 0 22px 65px rgb(24 34 52 / 12%); }
.login-card .brand-mark { margin-bottom: 22px; }
.login-card h1 { margin-bottom: 8px; }
.login-form { display: grid; gap: 14px; margin-top: 24px; }
.login-form label { display: grid; gap: 6px; color: #465165; font-size: 13px; font-weight: 650; }
.login-form input { width: 100%; padding: 10px 11px; border: 1px solid #cfd5dd; border-radius: 8px; }
.login-form button { margin-top: 5px; padding: 11px; border: 0; border-radius: 8px; color: white; background: var(--blue); font-weight: 750; }
.form-error { padding: 10px 12px; border-radius: 7px; color: var(--red); background: #fff0ef; font-size: 13px; }

@media (max-width: 900px) {
  .studio-shell { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; }
  .site-list { grid-template-columns: repeat(3, 1fr); }
  .sidebar-foot { grid-template-columns: 1fr auto auto; align-items: center; }
  .page-workbench { grid-template-columns: 1fr; }
  .page-browser { border-right: 0; border-bottom: 1px solid var(--line); }
  .page-list { max-height: 260px; }
}

@media (max-width: 620px) {
  .workspace { padding: 22px 13px 45px; }
  .workspace-header, .section-heading { align-items: flex-start; flex-direction: column; }
  .tabs { overflow-x: auto; }
  .tab { white-space: nowrap; }
  .field-grid, .theme-card { grid-template-columns: 1fr; }
  .theme-preview { grid-column: auto; }
  .editor-topline { align-items: flex-start; flex-direction: column; }
  .editor-mode { flex-wrap: wrap; }
  .editor-mode .muted { width: 100%; margin: 5px 0 0; }
}
