:root {
  color-scheme: light;
  --ink: #242321;
  --muted: #68615c;
  --line: #ddd5cc;
  --paper: #fbf8f2;
  --panel: rgba(255, 255, 255, 0.9);
  --moss: #315c54;
  --moss-2: #3f746a;
  --clay: #a85240;
  --amber: #c2963d;
  --blue: #496f91;
  --shadow: 0 18px 45px rgba(36, 35, 33, 0.09);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-width: 320px;
  background:
    linear-gradient(120deg, rgba(49, 92, 84, 0.1), transparent 36%),
    linear-gradient(270deg, rgba(168, 82, 64, 0.1), transparent 32%),
    var(--paper);
  color: var(--ink);
}

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

button {
  border: 0;
  cursor: pointer;
}

input,
textarea,
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffdfa;
  color: var(--ink);
}

input,
select {
  min-height: 42px;
  padding: 0 12px;
}

textarea {
  min-height: 112px;
  padding: 12px;
  resize: vertical;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  max-width: 900px;
  margin-bottom: 10px;
  font-size: clamp(2.2rem, 5vw, 4.8rem);
  line-height: 0.96;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 6px;
  font-size: 1.18rem;
}

small,
.muted,
.topbar p,
.panel p {
  color: var(--muted);
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--clay);
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.auth-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(340px, 480px);
  gap: 24px;
  align-items: center;
  padding: clamp(20px, 5vw, 64px);
}

.auth-hero {
  max-width: 860px;
}

.brand-mark,
.brand span,
.avatar {
  width: 46px;
  height: 46px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: var(--moss);
  color: white;
  font-weight: 900;
}

.auth-points,
.tag-row,
.button-row,
.top-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.auth-points span,
.tag-row span {
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.72);
  color: var(--muted);
  font-size: 0.86rem;
}

.auth-panel,
.panel,
.metric,
.profile-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.auth-panel {
  padding: 24px;
}

.auth-panel form {
  display: grid;
  gap: 14px;
}

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 800;
}

.primary,
.ghost,
.success,
.nav-item {
  min-height: 42px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 14px;
  font-weight: 800;
  transition: 150ms ease;
}

.primary {
  background: var(--moss);
  color: white;
}

.primary:hover {
  background: var(--moss-2);
}

.ghost {
  border: 1px solid var(--line);
  background: #fffdfa;
  color: var(--ink);
}

.success {
  background: var(--blue);
  color: white;
}

.wide {
  width: 100%;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
}

.sidebar {
  min-height: 100vh;
  padding: 22px 16px;
  display: flex;
  flex-direction: column;
  gap: 24px;
  border-right: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.72);
  backdrop-filter: blur(18px);
}

.brand {
  display: grid;
  grid-template-columns: 46px 1fr;
  gap: 12px;
  align-items: center;
  background: transparent;
  color: var(--ink);
  text-align: left;
}

.brand small {
  display: block;
  grid-column: 2;
  margin-top: -10px;
}

nav {
  display: grid;
  gap: 8px;
}

.nav-item {
  justify-content: flex-start;
  background: transparent;
  color: var(--muted);
}

.nav-item.active,
.nav-item:hover {
  background: #ece6dd;
  color: var(--ink);
}

.profile-card {
  margin-top: auto;
  padding: 12px;
  display: flex;
  gap: 12px;
  align-items: center;
}

.avatar {
  background: var(--clay);
  flex: 0 0 auto;
}

.profile-card strong,
.profile-card small {
  display: block;
}

.workspace {
  min-width: 0;
  padding: 28px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 18px;
  margin-bottom: 18px;
}

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

.stats-row {
  display: grid;
  grid-template-columns: repeat(4, minmax(150px, 1fr));
  gap: 14px;
  margin-bottom: 14px;
}

.metric {
  min-height: 92px;
  padding: 16px;
}

.metric span,
.metric small {
  display: block;
  font-size: 0.78rem;
  color: var(--muted);
}

.metric strong {
  display: block;
  margin: 3px 0;
  font-size: 1.55rem;
}

.content-grid {
  display: grid;
  grid-template-columns: minmax(320px, 1fr) minmax(320px, 0.9fr);
  gap: 14px;
  align-items: start;
}

.panel {
  overflow: hidden;
}

.wide-panel {
  grid-column: 1 / -1;
}

.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 14px;
  padding: 18px;
  border-bottom: 1px solid var(--line);
}

.stack-row,
.feed-item {
  width: 100%;
  display: block;
  padding: 17px 18px;
  border-bottom: 1px solid var(--line);
  background: transparent;
  color: var(--ink);
  text-align: left;
}

.stack-row:hover,
.stack-row.selected {
  background: #f3eee6;
}

.stack-row span,
.stack-row small,
.feed-item small,
.card-grid span,
.card-grid small {
  display: block;
  color: var(--muted);
}

.stack-row span,
.card-grid span {
  margin-bottom: 7px;
  font-size: 0.75rem;
  font-weight: 900;
  text-transform: uppercase;
}

.stack-row strong,
.feed-item strong,
.card-grid strong {
  display: block;
  margin-bottom: 5px;
}

.cover-card {
  min-height: 320px;
  padding: 24px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  background:
    linear-gradient(150deg, rgba(36, 35, 33, 0.12), transparent),
    radial-gradient(circle at 18% 18%, rgba(255, 255, 255, 0.24), transparent 28%),
    linear-gradient(135deg, #315c54, #6c4650 54%, #a85240);
  color: white;
}

.cover-card strong {
  max-width: 13ch;
  font-family: Georgia, serif;
  font-size: 3rem;
  line-height: 0.95;
}

.cover-card span,
.cover-card small {
  color: rgba(255, 255, 255, 0.82);
}

.detail-copy {
  padding: 20px;
}

.tag-row {
  margin: 18px 0;
}

.empty-state {
  padding: 28px 18px;
}

.empty-state strong {
  display: block;
  margin-bottom: 8px;
}

.form-panel {
  margin-top: 14px;
}

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

.form-grid.tight {
  grid-template-columns: 1fr 1fr auto;
  align-items: end;
}

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

.desk-panel {
  min-height: 360px;
}

.draft-page {
  padding: 22px;
  font-family: Georgia, serif;
  line-height: 1.7;
}

.draft-page h3 {
  margin: 0 0 6px;
  font-size: 1.45rem;
}

.draft-page small {
  display: block;
  margin-bottom: 18px;
  font-family: Inter, sans-serif;
}

.chapter-tabs {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  padding: 12px 18px;
  border-bottom: 1px solid var(--line);
  background: #f6f0e8;
}

.chapter-tabs button,
.chapter-tabs span {
  min-height: 34px;
  padding: 0 10px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: #fffdfa;
  color: var(--muted);
  display: inline-flex;
  align-items: center;
}

.chapter-tabs button.active {
  background: var(--moss);
  color: white;
  border-color: var(--moss);
}

.chapter-input {
  min-height: 360px;
  font-family: Georgia, serif;
  line-height: 1.65;
}

.annotation {
  padding: 12px;
  border-left: 4px solid var(--amber);
  background: rgba(194, 150, 61, 0.14);
  color: #5f4714;
  font-family: Inter, sans-serif;
  font-size: 0.92rem;
}

.composer {
  display: grid;
  gap: 12px;
  padding: 18px;
  border-bottom: 1px solid var(--line);
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  padding: 18px;
}

.card-grid article,
.admin-grid article {
  min-height: 160px;
  padding: 16px;
  display: grid;
  align-content: start;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffdfa;
}

.admin-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  padding: 18px;
}

.admin-grid article {
  min-height: 118px;
}

.admin-grid span {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 900;
  text-transform: uppercase;
}

.admin-grid strong {
  font-size: 2rem;
}

.deploy-box {
  margin: 0 18px 18px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f5efe6;
}

.deploy-box code {
  display: block;
  margin-top: 10px;
  padding: 12px;
  border-radius: 8px;
  background: #fffdfa;
  border: 1px solid var(--line);
  overflow-x: auto;
}

@media (max-width: 1080px) {
  .auth-shell,
  .app-shell,
  .content-grid {
    grid-template-columns: 1fr;
  }

  .sidebar {
    min-height: auto;
  }

  nav,
  .stats-row,
  .card-grid,
  .admin-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 680px) {
  .workspace {
    padding: 18px;
  }

  .topbar,
  .panel-head {
    display: grid;
  }

  .stats-row,
  .form-grid,
  .form-grid.tight,
  .card-grid,
  .admin-grid,
  nav {
    grid-template-columns: 1fr;
  }

  .top-actions,
  .button-row {
    display: grid;
  }
}
