:root {
  --bg: #f5f1e8;
  --panel: #fffdf9;
  --panel-strong: #ffffff;
  --line: #ddd2bf;
  --text: #1f2421;
  --muted: #6d6a63;
  --accent: #b44f2e;
  --accent-dark: #8e3d21;
  --success: #1f7a4c;
  --danger: #ac2f2f;
  --shadow: 0 18px 40px rgba(84, 66, 40, 0.08);
  --radius: 20px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Segoe UI", "PingFang SC", "Hiragino Sans GB", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(180, 79, 46, 0.15), transparent 32%),
    linear-gradient(180deg, #f6f0e6 0%, #efe7da 100%);
  min-height: 100vh;
}

a {
  color: inherit;
  text-decoration: none;
}

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

.app-shell {
  margin-left: 300px;
  padding: 32px;
}

.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: 280px;
  padding: 28px 22px;
  background: rgba(255, 251, 244, 0.88);
  backdrop-filter: blur(18px);
  border-right: 1px solid rgba(160, 141, 116, 0.2);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.brand {
  display: flex;
  gap: 14px;
  align-items: center;
}

.brand-mark {
  width: 54px;
  height: 54px;
  border-radius: 18px;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, #bb5a37, #d08b4f);
  color: white;
  font-weight: 800;
  letter-spacing: 0.08em;
}

.brand-title {
  font-size: 20px;
  font-weight: 700;
}

.brand-subtitle {
  color: var(--muted);
  font-size: 13px;
}

.menu {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 36px;
}

.menu-link {
  padding: 14px 16px;
  border-radius: 16px;
  color: var(--muted);
  transition: all 0.2s ease;
}

.menu-link.active,
.menu-link:hover {
  background: rgba(180, 79, 46, 0.12);
  color: var(--text);
}

.sidebar-footer {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.admin-badge {
  padding: 12px 14px;
  border-radius: 16px;
  background: var(--panel);
  border: 1px solid var(--line);
}

.page-head {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  align-items: end;
  margin-bottom: 24px;
}

.page-head h1 {
  margin: 8px 0 6px;
  font-size: 34px;
}

.page-head p {
  margin: 0;
  color: var(--muted);
  max-width: 720px;
}

.eyebrow {
  margin: 0;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 12px;
  font-weight: 700;
}

.stats-grid,
.two-column {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 18px;
}

.two-column {
  grid-template-columns: 1.2fr 1fr;
  margin-top: 18px;
}

.stat-card,
.panel,
.login-card {
  background: rgba(255, 253, 249, 0.9);
  border: 1px solid rgba(166, 146, 118, 0.18);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.stat-card {
  padding: 22px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.stat-card span,
.stat-card small,
.panel-head p,
.table-sub,
.empty,
.log-item small {
  color: var(--muted);
}

.stat-card strong {
  font-size: 28px;
}

.panel {
  padding: 24px;
  margin-bottom: 18px;
}

.panel-head {
  margin-bottom: 16px;
}

.panel-head h2 {
  margin: 0 0 6px;
}

.code-block {
  margin: 0;
  padding: 18px;
  border-radius: 18px;
  background: #201d19;
  color: #f3eee5;
  overflow-x: auto;
}

.table-shell {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  padding: 16px 12px;
  border-bottom: 1px solid rgba(166, 146, 118, 0.18);
  text-align: left;
  vertical-align: top;
}

thead th {
  color: var(--muted);
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.inline-actions,
.stacked-actions {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

.stacked-actions {
  justify-content: flex-end;
}

.primary-btn,
.secondary-btn,
.ghost-btn {
  padding: 12px 18px;
  border-radius: 14px;
  border: none;
  cursor: pointer;
  transition: transform 0.15s ease, opacity 0.15s ease;
}

.primary-btn:hover,
.secondary-btn:hover,
.ghost-btn:hover {
  transform: translateY(-1px);
}

.primary-btn {
  background: linear-gradient(135deg, var(--accent), #cf7d4b);
  color: white;
}

.secondary-btn {
  background: #efe2d4;
  color: var(--text);
}

.ghost-btn {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--text);
}

.ghost-btn.danger {
  color: var(--danger);
}

.full {
  width: 100%;
}

.small {
  padding: 8px 12px;
  border-radius: 12px;
  font-size: 14px;
}

.mono {
  font-family: "SFMono-Regular", "Menlo", "Consolas", monospace;
  word-break: break-all;
}

.status {
  display: inline-flex;
  padding: 6px 10px;
  border-radius: 999px;
  background: #efe7da;
  text-transform: uppercase;
  font-size: 12px;
}

.status.published {
  background: rgba(31, 122, 76, 0.12);
  color: var(--success);
}

.status.draft {
  background: rgba(180, 79, 46, 0.12);
  color: var(--accent-dark);
}

.status.active {
  background: rgba(31, 122, 76, 0.12);
  color: var(--success);
}

.status.archived {
  background: rgba(109, 106, 99, 0.12);
  color: var(--muted);
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}

.form-grid > .full {
  grid-column: 1 / -1;
}

.form-grid label {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.form-grid input,
.form-grid select,
.form-grid textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 14px 16px;
  background: rgba(255, 255, 255, 0.85);
}

.form-grid textarea {
  resize: vertical;
  min-height: 120px;
}

.checkbox {
  display: flex;
  flex-direction: row !important;
  align-items: center;
  gap: 10px !important;
  padding-top: 34px;
}

.checkbox input {
  width: auto;
}

.flash {
  margin-bottom: 18px;
  padding: 14px 16px;
  border-radius: 16px;
}

.flash.success {
  background: rgba(31, 122, 76, 0.12);
  color: var(--success);
}

.flash.error {
  background: rgba(172, 47, 47, 0.12);
  color: var(--danger);
}

.log-list {
  display: grid;
  gap: 12px;
}

.log-item {
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 16px;
}

.log-main {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 6px;
}

.login-card {
  width: min(580px, 100%);
  padding: 34px;
}

.login-intro h1 {
  margin: 10px 0 8px;
  font-size: 36px;
}

.tip-box {
  margin-top: 18px;
  padding: 16px 18px;
  border-radius: 18px;
  background: rgba(180, 79, 46, 0.08);
}

.detail-grid {
  display: grid;
  grid-template-columns: 1.2fr 1fr;
  gap: 18px;
  margin-bottom: 18px;
}

.timeline-list,
.note-stack {
  display: grid;
  gap: 14px;
}

.timeline-item,
.note-block {
  padding: 16px 18px;
  border: 1px solid rgba(166, 146, 118, 0.2);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.66);
}

.timeline-item.role-user {
  border-left: 4px solid #d08b4f;
}

.timeline-item.role-assistant {
  border-left: 4px solid #1f7a4c;
}

.timeline-item.role-system,
.timeline-item.role-summary {
  border-left: 4px solid #5e6b8c;
}

.timeline-item.role-tool,
.checkpoint-item {
  border-left: 4px solid #8e3d21;
}

.timeline-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.timeline-head span,
.sub-note {
  color: var(--muted);
  font-size: 14px;
}

.message-body {
  white-space: pre-wrap;
  line-height: 1.72;
}

.code-inline {
  margin: 12px 0 0;
  padding: 12px 14px;
  border-radius: 14px;
  background: rgba(32, 29, 25, 0.94);
  color: #f3eee5;
  overflow-x: auto;
}

.sub-note {
  margin-top: 10px;
  white-space: pre-wrap;
}

@media (max-width: 1100px) {
  .app-shell {
    margin-left: 0;
    padding: 20px;
  }

  .sidebar {
    position: static;
    width: auto;
    border-right: none;
    border-bottom: 1px solid rgba(160, 141, 116, 0.2);
  }

  .stats-grid,
  .two-column,
  .form-grid,
  .detail-grid {
    grid-template-columns: 1fr;
  }

  .page-head {
    flex-direction: column;
    align-items: start;
  }
}
