:root {
  color-scheme: light;
  font-family:
    Inter, "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  color: #18212f;
  background: #f4f6f8;
  --accent: #176b5b;
  --accent-soft: #e4f2ee;
  --border: #dce2e8;
  --muted: #667384;
  --surface: #ffffff;
  --danger: #b23a48;
  --success: #176b5b;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body {
  height: 100%;
  margin: 0;
}

button,
input,
textarea,
select {
  font: inherit;
}

button,
select {
  min-height: 44px;
}

button {
  cursor: pointer;
}

.muted {
  color: var(--muted);
}

.mobile-only {
  display: none;
}

.topbar {
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.topbar strong {
  margin-right: 10px;
}

.topbar-user {
  display: flex;
  align-items: center;
  gap: 12px;
}

.review-layout {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  height: calc(100vh - 64px);
}

.article-sidebar {
  overflow: auto;
  padding: 16px;
  border-right: 1px solid var(--border);
  background: #f9fafb;
}

.sidebar-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.sidebar-heading h1 {
  margin: 0;
  font-size: 20px;
}

.article-list {
  display: grid;
  gap: 8px;
  margin-top: 14px;
}

.article-item {
  display: grid;
  gap: 7px;
  width: 100%;
  padding: 12px;
  border: 1px solid transparent;
  border-radius: 10px;
  background: transparent;
  text-align: left;
}

.article-item span {
  color: var(--muted);
  font-size: 12px;
}

.article-item:hover,
.article-item.selected {
  border-color: #b9d8d0;
  background: var(--accent-soft);
}

.sidebar-empty {
  padding: 10px;
}

.workspace {
  min-width: 0;
  overflow: hidden;
  background: var(--surface);
}

.empty-state {
  display: grid;
  place-content: center;
  height: 100%;
  text-align: center;
}

.empty-state h2 {
  margin-bottom: 4px;
}

.editor-shell {
  display: grid;
  grid-template-rows: auto auto auto 1fr auto;
  height: 100%;
}

.article-fields {
  display: grid;
  grid-template-columns: minmax(0, 3fr) minmax(180px, 1fr);
  gap: 12px;
  padding: 14px 18px 10px;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
}

input,
textarea,
select {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: inherit;
}

input {
  min-height: 42px;
  padding: 8px 10px;
}

input:focus,
textarea:focus,
select:focus {
  outline: 2px solid #7fc5b6;
  outline-offset: 1px;
}

.platform-tabs {
  display: flex;
  gap: 4px;
  overflow-x: auto;
  padding: 0 18px;
  border-bottom: 1px solid var(--border);
}

.platform-tabs button {
  padding: 0 14px;
  border: 0;
  border-bottom: 3px solid transparent;
  background: transparent;
  color: var(--muted);
  white-space: nowrap;
}

.platform-tabs button.selected {
  border-bottom-color: var(--accent);
  color: var(--accent);
  font-weight: 700;
}

.quality-warnings {
  padding: 9px 18px;
  background: #fff7dc;
  color: #765a09;
  font-size: 13px;
}

.content-panes {
  display: grid;
  grid-template-columns: 1fr 1fr;
  min-height: 0;
}

.editor-pane,
.preview-pane {
  display: grid;
  grid-template-rows: 36px 1fr;
  min-width: 0;
  min-height: 0;
}

.editor-pane {
  border-right: 1px solid var(--border);
}

.pane-title {
  padding: 9px 14px;
  background: #f7f8fa;
  color: var(--muted);
  font-size: 12px;
}

#markdown-editor {
  width: 100%;
  height: 100%;
  resize: none;
  padding: 18px;
  border: 0;
  border-radius: 0;
  line-height: 1.7;
  font-family: "Cascadia Code", "SFMono-Regular", monospace;
}

.article-preview {
  overflow: auto;
  padding: 30px max(24px, calc((100% - 760px) / 2));
  line-height: 1.8;
}

.article-preview h1,
.article-preview h2,
.article-preview h3 {
  line-height: 1.35;
}

.article-preview img {
  max-width: 100%;
}

.article-preview blockquote {
  margin-left: 0;
  padding-left: 14px;
  border-left: 3px solid #73b7a8;
  color: #526171;
}

.article-preview a {
  color: var(--accent);
  overflow-wrap: anywhere;
}

.actionbar {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 18px;
  border-top: 1px solid var(--border);
  background: var(--surface);
}

.actionbar > div {
  display: flex;
  gap: 8px;
}

button {
  padding: 8px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
}

button.primary {
  border-color: var(--accent);
  background: var(--accent);
  color: white;
}

button.success {
  border-color: #78b9aa;
  color: var(--success);
}

button.danger {
  border-color: #e1aab0;
  color: var(--danger);
}

button.quiet,
.icon-button {
  background: transparent;
}

.wide {
  width: 100%;
}

.notification {
  position: fixed;
  right: 22px;
  bottom: 76px;
  z-index: 20;
  max-width: 360px;
  padding: 12px 16px;
  border-radius: 9px;
  background: #163c35;
  color: white;
  box-shadow: 0 12px 30px #20304033;
}

.notification.error,
.notice.error {
  background: #fff0f1;
  color: #8d2633;
}

dialog {
  width: min(560px, calc(100vw - 32px));
  border: 0;
  border-radius: 14px;
  box-shadow: 0 18px 60px #1c283855;
}

dialog::backdrop {
  background: #17202d77;
}

dialog header,
.history-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.history-row {
  padding: 10px 0;
  border-top: 1px solid var(--border);
}

.login-page {
  display: grid;
  place-items: center;
  min-height: 100%;
  padding: 20px;
  background: linear-gradient(145deg, #edf5f2, #f4f6f8 55%);
}

.login-card {
  width: min(420px, 100%);
  padding: 34px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--surface);
  box-shadow: 0 18px 48px #28443918;
}

.login-card form {
  display: grid;
  gap: 16px;
  margin-top: 24px;
}

.eyebrow {
  color: var(--accent);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.12em;
}

.notice {
  padding: 10px 12px;
  border-radius: 8px;
}

@media (max-width: 800px) {
  .mobile-only {
    display: inline-flex;
  }

  .topbar .muted {
    display: none;
  }

  .review-layout {
    display: block;
  }

  .article-sidebar {
    position: fixed;
    inset: 64px auto 0 0;
    z-index: 10;
    width: min(88vw, 320px);
    transform: translateX(-105%);
    transition: transform 0.18s ease;
    box-shadow: 12px 0 30px #24313f28;
  }

  .article-sidebar.open {
    transform: translateX(0);
  }

  .article-fields {
    grid-template-columns: 1fr;
    padding: 10px 12px;
  }

  .platform-tabs {
    padding: 0 8px;
  }

  .mobile-view-switch {
    padding: 8px 12px 0;
    gap: 8px;
  }

  .mobile-view-switch button.selected {
    border-color: var(--accent);
    color: var(--accent);
  }

  .content-panes {
    display: block;
  }

  .content-panes.show-editor .preview-pane,
  .content-panes.show-preview .editor-pane {
    display: none;
  }

  .editor-pane,
  .preview-pane {
    height: 100%;
  }

  .actionbar {
    padding: 9px;
    overflow-x: auto;
  }

  .actionbar > div {
    flex-shrink: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition: none !important;
  }
}
