:root {
  --ink: #202b25;
  --ink-soft: #33433a;
  --paper: #f6f5ef;
  --white: #fffdf8;
  --fog: #d7e7e9;
  --blue: #3d7180;
  --moss: #4f6f4d;
  --gold: #c6b276;
  --coral: #c9785f;
  --line: rgba(32, 43, 37, .18);
  --shadow: 0 20px 42px rgba(32, 43, 37, .16);
  --serif: "Noto Serif SC", "Songti SC", "STSong", "SimSun", serif;
  --sans: "Avenir Next", "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }
html { min-height: 100%; }
[hidden] { display: none !important; }
body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background:
    linear-gradient(90deg, rgba(255, 253, 248, .72) 0 1px, transparent 1px) 0 0 / 48px 100%,
    var(--fog);
  font-family: var(--serif);
  line-height: 1.65;
}
::selection { color: var(--white); background: var(--coral); }
button, input, select, textarea { font: inherit; }
button { border-radius: 0; }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 2px solid var(--coral); outline-offset: 4px; }

.admin-shell { min-height: 100vh; }
.login-panel {
  display: grid;
  grid-template-columns: minmax(260px, .72fr) minmax(320px, .42fr);
  min-height: 100vh;
}
.login-mark {
  display: grid;
  align-content: center;
  justify-items: start;
  padding: clamp(34px, 8vw, 110px);
  color: var(--white);
  background: var(--ink);
}
.login-mark img { width: 72px; height: 72px; margin-bottom: 36px; object-fit: contain; filter: brightness(1.45); }
.login-mark span { max-width: 4em; font-size: clamp(58px, 9vw, 118px); line-height: 1.02; letter-spacing: 0; }
.login-form {
  align-self: center;
  display: grid;
  gap: 22px;
  margin: clamp(22px, 5vw, 70px);
  padding: clamp(26px, 4vw, 44px);
  background: var(--white);
  box-shadow: var(--shadow);
}
.panel-label {
  margin: 0;
  color: var(--blue);
  font-family: var(--sans);
  font-size: 10px;
  letter-spacing: 0;
}
h1, h2, p { margin-top: 0; }
.login-form h1, .desk-header h1 { margin: 0; font-size: clamp(34px, 4.5vw, 62px); line-height: 1.12; font-weight: 500; letter-spacing: 0; }
label { display: grid; gap: 8px; color: var(--ink); font-family: var(--sans); font-size: 12px; }
input, select, textarea {
  width: 100%;
  min-height: 48px;
  padding: 11px 13px;
  color: var(--ink);
  background: var(--paper);
  border: 1px solid rgba(32, 43, 37, .26);
  border-radius: 0;
  outline: 0;
  caret-color: var(--coral);
}
textarea { min-height: 118px; resize: vertical; }
input::placeholder, textarea::placeholder { color: rgba(51, 67, 58, .62); }
.login-status, .sync-status {
  min-height: 20px;
  margin: 0;
  color: var(--ink-soft);
  font-family: var(--sans);
  font-size: 12px;
}
.login-status.error, .sync-status.error { color: #8b3329; }
.login-status.success, .sync-status.success { color: var(--moss); }

button {
  min-height: 44px;
  padding: 10px 16px;
  color: var(--white);
  background: var(--ink);
  border: 0;
  cursor: pointer;
  font-family: var(--sans);
  font-size: 12px;
  transition: background .18s ease, opacity .18s ease, transform .18s ease;
}
button:hover { background: var(--coral); transform: translateY(-1px); }
button:disabled { cursor: not-allowed; opacity: .45; transform: none; }
.secondary-button { color: var(--ink); background: var(--paper); }
.danger-button { background: #8b3329; }
.danger-button:hover { background: #6f261f; }

.desk {
  display: grid;
  grid-template-columns: 270px minmax(0, 1fr);
  min-height: 100vh;
}
.desk-tools {
  position: sticky;
  top: 0;
  align-self: start;
  display: grid;
  gap: 30px;
  min-height: 100vh;
  padding: 26px 24px;
  color: var(--white);
  background: var(--ink);
}
.brand-link {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--white);
  text-decoration: none;
  font-family: var(--sans);
  font-size: 11px;
  line-height: 1.35;
}
.brand-link img { width: 38px; height: 38px; object-fit: contain; filter: brightness(1.35); }
.brand-link strong { font-size: 14px; }
.tool-group { display: grid; gap: 14px; }
.desk-tools .panel-label { color: var(--gold); }
.segmented {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  border: 1px solid rgba(255, 253, 248, .24);
}
.segmented button {
  min-width: 0;
  padding: 9px 8px;
  color: var(--fog);
  background: transparent;
  border-right: 1px solid rgba(255, 253, 248, .24);
}
.segmented button:last-child { border-right: 0; }
.segmented button.is-active { color: var(--ink); background: var(--gold); }
.search-field { color: var(--fog); }
.search-field input {
  color: var(--white);
  background: rgba(255, 253, 248, .08);
  border-color: rgba(255, 253, 248, .26);
}
.search-field input::placeholder { color: rgba(215, 231, 233, .72); }
.export-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.export-actions button { color: var(--ink); background: var(--white); }
.export-actions button:hover { color: var(--white); background: var(--coral); }
.logout-button { align-self: end; color: var(--fog); background: transparent; border: 1px solid rgba(255, 253, 248, .24); }

.desk-main { padding: clamp(28px, 5vw, 64px); }
.desk-header {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 24px;
  margin-bottom: 30px;
}
.stat-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin-bottom: 28px;
  background: var(--white);
  box-shadow: var(--shadow);
}
.stat-strip div { min-width: 0; padding: 18px 20px; border-right: 1px solid var(--line); }
.stat-strip div:last-child { border-right: 0; }
.stat-strip span { display: block; overflow: hidden; color: var(--moss); font-family: var(--sans); font-size: clamp(23px, 3vw, 36px); line-height: 1.1; text-overflow: ellipsis; white-space: nowrap; }
.stat-strip p { margin: 8px 0 0; color: var(--ink-soft); font-family: var(--sans); font-size: 11px; }
.content-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 380px);
  gap: 24px;
  align-items: start;
}
.entry-list, .entry-detail {
  min-width: 0;
  background: var(--white);
  box-shadow: var(--shadow);
}
.table-wrap { overflow-x: auto; }
table {
  width: 100%;
  min-width: 860px;
  border-collapse: collapse;
  font-family: var(--sans);
  font-size: 12px;
}
th, td { padding: 14px 16px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--blue); font-size: 10px; letter-spacing: 0; }
tbody tr { cursor: pointer; transition: background .16s ease; }
tbody tr:hover, tbody tr.is-selected { background: rgba(215, 231, 233, .45); }
td strong { display: block; color: var(--ink); font-family: var(--serif); font-size: 16px; font-weight: 500; line-height: 1.45; }
td small { display: block; margin-top: 3px; color: var(--ink-soft); font-size: 11px; }
.type-pill {
  display: inline-block;
  min-width: 48px;
  padding: 4px 8px;
  color: var(--white);
  background: var(--blue);
  text-align: center;
}
.type-pill.submission { background: var(--coral); }
.list-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 14px 16px;
  font-family: var(--sans);
  font-size: 12px;
}
.list-footer button { min-height: 38px; color: var(--ink); background: var(--paper); }
.entry-detail {
  position: sticky;
  top: 24px;
  padding: 22px;
}
.detail-empty { color: var(--ink-soft); font-family: var(--sans); font-size: 13px; }
.entry-detail h2 { margin: 8px 0 22px; font-size: 28px; line-height: 1.25; font-weight: 500; }
.detail-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin: -6px 0 22px;
}
dl { display: grid; gap: 14px; margin: 0; }
dt { color: var(--blue); font-family: var(--sans); font-size: 10px; letter-spacing: 0; }
dd { margin: 4px 0 0; color: var(--ink); font-size: 14px; line-height: 1.8; white-space: pre-wrap; overflow-wrap: anywhere; }
.edit-form {
  display: grid;
  gap: 16px;
  margin-top: 22px;
  padding-top: 20px;
  border-top: 1px solid var(--line);
}
.edit-form label { margin-bottom: 14px; }
.edit-form textarea[name="body"] { min-height: 180px; }
.edit-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.current-user {
  padding: 12px 0;
  color: var(--fog);
  border-top: 1px solid rgba(255, 253, 248, .18);
  border-bottom: 1px solid rgba(255, 253, 248, .18);
  font-family: var(--sans);
  font-size: 12px;
}
.view-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  border: 1px solid rgba(255, 253, 248, .24);
}
.view-tabs button {
  color: var(--fog);
  background: transparent;
  border-right: 1px solid rgba(255, 253, 248, .24);
}
.view-tabs button:last-child { border-right: 0; }
.view-tabs button.is-active { color: var(--ink); background: var(--gold); }
.source-line {
  margin: -12px 0 20px;
  color: var(--ink-soft);
  font-family: var(--sans);
  font-size: 12px;
}
.review-panel {
  margin-top: 24px;
  padding-top: 22px;
  border-top: 1px solid var(--line);
}
.review-panel h3 {
  margin: 0 0 14px;
  font-size: 22px;
  font-weight: 500;
}
.review-list {
  display: grid;
  gap: 12px;
  margin-bottom: 18px;
  color: var(--ink-soft);
  font-family: var(--sans);
  font-size: 12px;
}
.review-item {
  padding: 12px 0;
  border-top: 1px solid rgba(32, 43, 37, .14);
}
.review-item:first-child { border-top: 0; }
.review-item p {
  margin: 0 0 6px;
  color: var(--blue);
  font-size: 11px;
}
.review-item div {
  color: var(--ink);
  font-family: var(--serif);
  font-size: 14px;
  line-height: 1.8;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.review-form { display: grid; gap: 12px; }
.review-form textarea { min-height: 110px; }
.users-view .table-wrap {
  background: var(--white);
  box-shadow: var(--shadow);
}
.user-search {
  max-width: 460px;
  margin-bottom: 22px;
  color: var(--ink);
}
.user-search input {
  color: var(--ink);
  background: var(--white);
  border-color: var(--line);
}
.role-static {
  display: inline-block;
  padding: 6px 8px;
  color: var(--ink-soft);
  background: var(--paper);
  font-family: var(--sans);
  font-size: 12px;
}
.users-view select {
  min-height: 38px;
  padding: 7px 9px;
}

@media (max-width: 980px) {
  .login-panel, .desk { grid-template-columns: 1fr; }
  .login-mark { min-height: 34vh; }
  .login-mark span { max-width: none; }
  .desk-tools { position: static; min-height: auto; }
  .desk-main { padding: 28px 20px 44px; }
  .content-grid { grid-template-columns: 1fr; }
  .entry-detail { position: static; }
}

@media (max-width: 620px) {
  .login-panel { display: block; }
  .login-mark { padding: 34px 24px; }
  .login-mark img { width: 54px; height: 54px; margin-bottom: 24px; }
  .login-mark span { font-size: 48px; }
  .login-form { margin: 20px; padding: 24px; }
  .desk-header { display: grid; }
  .stat-strip { grid-template-columns: 1fr 1fr; }
  .stat-strip div:nth-child(2) { border-right: 0; }
  .stat-strip div:nth-child(n+3) { border-top: 1px solid var(--line); }
  .export-actions { grid-template-columns: 1fr; }
}
