:root {
  color-scheme: dark;
  --bg: #0b0c0f;
  --panel: #111317;
  --panel-strong: #171a20;
  --text: #f4f6f8;
  --muted: #949ca8;
  --dim: #68717e;
  --line: #292d34;
  --line-strong: #3d4653;
  --accent: #6aa7ff;
  --accent-soft: #182437;
  --danger: #ff7a86;
  --success: #65d6a6;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body {
  min-width: 320px;
  min-height: 100%;
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, Pretendard, "Noto Sans KR", "Apple SD Gothic Neo", "Segoe UI", sans-serif;
  letter-spacing: 0;
  -webkit-font-smoothing: antialiased;
}

button,
input,
select,
textarea {
  font: inherit;
}

button,
a,
input,
select,
textarea {
  color: inherit;
}

a {
  text-decoration: none;
}

button {
  cursor: pointer;
}

.admin-topbar {
  position: sticky;
  z-index: 30;
  top: 0;
  display: grid;
  grid-template-columns: minmax(210px, 1fr) auto minmax(210px, 1fr);
  align-items: center;
  min-height: 54px;
  border-bottom: 1px solid var(--line);
  background: var(--bg);
  padding: 0 18px;
}

.admin-brand {
  display: flex;
  align-items: center;
  gap: 9px;
  width: max-content;
}

.admin-brand span {
  display: grid;
  width: 30px;
  height: 30px;
  place-items: center;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  color: var(--accent);
  font-size: 11px;
  font-weight: 800;
}

.admin-brand strong {
  font-size: 15px;
}

.topbar-status {
  color: var(--muted);
  font-size: 12px;
}

.topbar-status[data-tone="success"] {
  color: var(--success);
}

.topbar-status[data-tone="danger"] {
  color: var(--danger);
}

.topbar-actions {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 8px;
}

.topbar-actions a,
.topbar-actions button,
.primary-button,
.secondary-button,
.danger-button {
  display: inline-grid;
  min-height: 32px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel-strong);
  padding: 0 12px;
  font-size: 12px;
  font-weight: 700;
}

.topbar-actions button:hover,
.topbar-actions a:hover,
.primary-button:hover,
.secondary-button:hover {
  border-color: var(--accent);
}

.topbar-actions #save-button,
.primary-button {
  border-color: #345e94;
  background: var(--accent-soft);
}

.danger-button {
  color: var(--danger);
}

.admin-app {
  min-height: calc(100vh - 54px);
}

.loading-state,
.error-state {
  margin: 0;
  padding: 60px 24px;
  color: var(--muted);
  text-align: center;
}

.error-state {
  color: var(--danger);
}

.auth-screen {
  display: grid;
  min-height: calc(100vh - 54px);
  place-items: center;
  padding: 32px;
}

.auth-panel {
  width: min(100%, 360px);
  text-align: center;
}

.auth-mark {
  display: grid;
  width: 48px;
  height: 48px;
  margin: 0 auto 20px;
  place-items: center;
  border: 1px solid var(--accent);
  border-radius: 6px;
  color: var(--accent);
  font-weight: 700;
}

.auth-panel h1 {
  margin: 0;
  font-size: 28px;
}

.auth-panel p {
  margin: 12px 0 24px;
  color: var(--muted);
}

.auth-panel .primary-button {
  width: 100%;
  min-height: 44px;
}

.auth-panel .auth-error {
  color: var(--danger);
}

.collection-layout {
  display: grid;
  grid-template-columns: 190px minmax(0, 820px);
  gap: 52px;
  width: min(1120px, calc(100% - 48px));
  margin: 0 auto;
  padding: 44px 0 70px;
}

.collection-nav {
  border-top: 1px solid var(--line);
  padding-top: 14px;
}

.collection-nav p {
  margin: 0 0 13px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.collection-nav a {
  display: block;
  min-height: 34px;
  border-radius: 6px;
  padding: 8px 10px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
}

.collection-nav a:hover,
.collection-nav a[aria-current="page"] {
  background: var(--accent-soft);
  color: var(--text);
}

.collection-main {
  min-width: 0;
}

.collection-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  min-height: 42px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 14px;
}

.collection-header h1 {
  margin: 0;
  font-size: 24px;
}

.collection-tools {
  display: flex;
  align-items: center;
  gap: 8px;
}

.collection-tools select,
.collection-tools input {
  height: 32px;
  border: 1px solid var(--line);
  border-radius: 6px;
  outline: 0;
  background: var(--panel);
  padding: 0 9px;
  font-size: 12px;
}

.admin-list {
  margin-top: 8px;
}

.admin-row {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr) 110px;
  align-items: center;
  min-height: 44px;
  border-bottom: 1px solid var(--line);
  color: var(--text);
  font-size: 13px;
}

.admin-row:hover {
  background: var(--accent-soft);
}

.admin-row strong {
  overflow: hidden;
  padding-right: 14px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.admin-row span,
.admin-row time {
  color: var(--muted);
}

.admin-row time {
  text-align: right;
}

.simple-row {
  grid-template-columns: minmax(0, 1fr) 110px;
  padding-left: 10px;
}

.status-pill {
  justify-self: end;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 3px 8px;
  font-size: 11px;
}

.status-pill.visible {
  color: var(--success);
}

.editor-layout {
  width: min(1240px, calc(100% - 32px));
  margin: 0 auto;
  padding: 0 0 72px;
}

.editor-toolbar {
  position: sticky;
  z-index: 20;
  top: 54px;
  display: flex;
  min-height: 48px;
  align-items: center;
  gap: 2px;
  overflow-x: auto;
  border-bottom: 1px solid var(--line);
  background: var(--bg);
  padding: 7px 0;
  scrollbar-width: none;
}

.editor-toolbar::-webkit-scrollbar {
  display: none;
}

.editor-toolbar button,
.editor-toolbar select {
  flex: 0 0 auto;
  height: 32px;
  border: 0;
  border-radius: 5px;
  background: transparent;
  padding: 0 10px;
  color: var(--text);
  font-size: 12px;
  font-weight: 800;
}

.editor-toolbar button:hover,
.editor-toolbar select:hover {
  background: var(--panel-strong);
}

.editor-toolbar .toolbar-separator {
  width: 1px;
  height: 22px;
  margin: 0 5px;
  background: var(--line);
}

.editor-metadata {
  display: grid;
  grid-template-columns: 90px 150px minmax(150px, 210px) minmax(180px, 1fr) 120px;
  gap: 16px;
  align-items: end;
  min-height: 72px;
  border-bottom: 1px solid var(--line);
  padding: 13px 0;
}

.field {
  min-width: 0;
}

.field label {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
}

.field input,
.field select,
.field textarea {
  width: 100%;
  min-height: 32px;
  border: 0;
  border-bottom: 1px solid var(--line-strong);
  border-radius: 0;
  outline: 0;
  background: transparent;
  padding: 4px 2px;
  color: var(--text);
  font-size: 13px;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
  border-color: var(--accent);
}

.field input[readonly] {
  color: var(--muted);
}

.editor-main {
  max-width: 820px;
  padding: 48px 0 0;
}

.title-input {
  display: block;
  width: 100%;
  overflow: hidden;
  border: 0;
  outline: 0;
  background: transparent;
  padding: 0;
  resize: none;
  color: var(--text);
  font-family: Georgia, "Noto Serif KR", serif;
  font-size: clamp(34px, 5vw, 48px);
  font-weight: 700;
  line-height: 1.25;
}

.title-input::placeholder {
  color: var(--dim);
}

.body-editor {
  min-height: 55vh;
  margin-top: 54px;
  outline: 0;
  color: var(--text);
  font-family: Georgia, "Noto Serif KR", serif;
  font-size: 19px;
  line-height: 1.9;
}

.body-editor:empty::before {
  content: attr(data-placeholder);
  color: var(--dim);
  pointer-events: none;
}

.body-editor p,
.body-editor h1,
.body-editor h2,
.body-editor h3,
.body-editor blockquote {
  margin-top: 0;
}

.body-editor p {
  margin-bottom: 0;
}

.body-editor img {
  display: block;
  max-width: 100%;
  margin: 16px 0;
  border: 1px solid var(--line);
  border-radius: 6px;
}

.body-editor blockquote {
  border-left: 2px solid var(--accent);
  padding-left: 18px;
  color: var(--muted);
}

.body-editor pre {
  overflow: auto;
  border-radius: 6px;
  background: var(--panel);
  padding: 16px;
  font-family: "IBM Plex Mono", Consolas, monospace;
  font-size: 14px;
}

.settings-editor {
  max-width: 680px;
  margin: 0 auto;
  padding: 48px 0;
}

.settings-editor h1 {
  margin: 0 0 34px;
  font-size: 30px;
}

.settings-fields {
  display: grid;
  gap: 24px;
}

.toggle-field {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 44px;
  border-bottom: 1px solid var(--line);
}

.toggle-field input {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
}

.series-editor-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: 44px;
  padding: 42px 0 0;
}

.site-editor-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 280px;
  gap: 44px;
  padding-top: 34px;
}

.site-editor-main {
  min-width: 0;
}

.site-fields {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.site-info-editor {
  margin-top: 38px;
  border-top: 1px solid var(--line);
  padding-top: 18px;
}

.site-info-editor .body-editor {
  min-height: 240px;
  margin-top: 20px;
}

.editor-label {
  margin: 0;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.series-editor-main .body-editor {
  min-height: 420px;
}

.series-inspector {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.inspector-section {
  border-top: 1px solid var(--line);
  padding-top: 14px;
}

.inspector-section h2 {
  margin: 0 0 12px;
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
}

.cover-preview {
  width: 100%;
  aspect-ratio: 16 / 9;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
  object-fit: contain;
}

.cover-placeholder {
  display: grid;
  width: 100%;
  aspect-ratio: 16 / 9;
  place-items: center;
  border: 1px dashed var(--line-strong);
  border-radius: 6px;
  color: var(--muted);
  font-size: 12px;
}

.cover-placeholder[hidden],
.cover-preview[hidden] {
  display: none;
}

.site-image-preview {
  margin-bottom: 9px;
}

.series-post-picker {
  max-height: 390px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 6px;
}

.series-post-option {
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  min-height: 40px;
  border-bottom: 1px solid var(--line);
  padding: 7px 8px;
  font-size: 12px;
}

.series-post-option:last-child {
  border-bottom: 0;
}

.series-post-option span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.series-order-buttons {
  display: flex;
  gap: 3px;
}

.series-order-buttons button {
  width: 25px;
  height: 25px;
  border: 0;
  border-radius: 4px;
  background: var(--panel-strong);
}

@media (max-width: 900px) {
  .admin-topbar {
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .topbar-status {
    display: none;
  }

  .collection-layout {
    grid-template-columns: 150px minmax(0, 1fr);
    gap: 24px;
    width: calc(100% - 28px);
  }

  .editor-metadata {
    grid-template-columns: 70px 130px minmax(140px, 1fr);
  }

  .editor-metadata .aliases-field,
  .editor-metadata .status-field {
    grid-column: span 1;
  }

  .series-editor-grid {
    grid-template-columns: minmax(0, 1fr) 260px;
    gap: 24px;
  }

  .site-editor-grid {
    grid-template-columns: minmax(0, 1fr) 240px;
    gap: 24px;
  }
}

@media (max-width: 680px) {
  .admin-topbar {
    min-height: 52px;
    padding: 0 10px;
  }

  .admin-brand strong,
  .topbar-actions a {
    display: none;
  }

  .topbar-actions button {
    padding: 0 9px;
  }

  .collection-layout {
    display: block;
    width: calc(100% - 24px);
    padding-top: 18px;
  }

  .collection-nav {
    display: flex;
    gap: 5px;
    overflow-x: auto;
    margin-bottom: 20px;
    padding: 7px 0;
  }

  .collection-nav p {
    display: none;
  }

  .collection-nav a {
    flex: 0 0 auto;
  }

  .collection-header {
    align-items: flex-start;
  }

  .collection-tools input,
  .collection-tools select {
    max-width: 110px;
  }

  .admin-row {
    grid-template-columns: 30px minmax(0, 1fr);
    padding: 5px 0;
  }

  .admin-row time,
  .admin-row .status-pill {
    grid-column: 2;
    justify-self: start;
    text-align: left;
  }

  .simple-row {
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .editor-layout {
    width: calc(100% - 24px);
  }

  .editor-toolbar {
    top: 52px;
  }

  .editor-metadata {
    grid-template-columns: 64px minmax(110px, 1fr) minmax(110px, 1fr);
    gap: 10px;
  }

  .editor-metadata .aliases-field,
  .editor-metadata .status-field {
    grid-column: 1 / -1;
  }

  .editor-main {
    padding-top: 34px;
  }

  .title-input {
    font-size: 34px;
  }

  .body-editor {
    margin-top: 38px;
    font-size: 17px;
  }

  .settings-editor {
    padding-top: 30px;
  }

  .series-editor-grid {
    display: flex;
    flex-direction: column;
    padding-top: 28px;
  }


  .site-editor-grid {
    display: flex;
    flex-direction: column;
    padding-top: 24px;
  }

  .site-fields {
    grid-template-columns: minmax(0, 1fr);
  }

  .series-inspector {
    order: -1;
  }
}
