:root {
  --bg: #11110f;
  --surface: #191917;
  --surface-2: #20201d;
  --surface-3: #292824;
  --text: #eeeeea;
  --muted: #aaa69d;
  --line: #3b3932;
  --accent: #d1a85b;
  --accent-strong: #e3bf78;
  --green: #75b889;
  --blue: #7da0c4;
  --red: #d7786f;
  --shadow: rgba(0, 0, 0, 0.28);
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

html {
  background: var(--bg);
  color: var(--text);
}

body {
  margin: 0;
  min-width: 320px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 16px;
  line-height: 1.55;
  background: var(--bg);
  color: var(--text);
}

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

a:hover {
  color: var(--accent-strong);
}

img {
  display: block;
  max-width: 100%;
}

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

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 18px;
  min-height: 64px;
  padding: 12px 24px;
  border-bottom: 1px solid var(--line);
  background: rgba(17, 17, 15, 0.94);
  backdrop-filter: blur(14px);
}

.brand {
  flex: 0 0 auto;
  font-weight: 750;
  color: var(--accent-strong);
}

.nav {
  display: flex;
  flex: 1;
  flex-wrap: wrap;
  gap: 6px;
}

.nav a {
  padding: 8px 10px;
  border-radius: var(--radius);
  color: var(--muted);
}

.nav a:hover {
  background: var(--surface-2);
  color: var(--text);
}

.logout-form {
  margin: 0;
}

.page {
  width: min(1320px, 100%);
  margin: 0 auto;
  padding: 28px 24px 56px;
}

.flash-stack {
  display: grid;
  gap: 10px;
  margin-bottom: 18px;
}

.flash {
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-2);
  color: var(--text);
}

.flash.success {
  border-color: rgba(117, 184, 137, 0.55);
}

.flash.error {
  border-color: rgba(215, 120, 111, 0.65);
}

.split-layout {
  display: grid;
  grid-template-columns: minmax(260px, 360px) minmax(0, 1fr);
  gap: 22px;
  align-items: start;
}

.side-panel,
.work-panel,
.note-card,
.empty-state,
.search-panel,
.dictionary-card,
.revision-item {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: 0 14px 40px var(--shadow);
}

.side-panel,
.work-panel {
  padding: 20px;
}

.side-panel.sticky {
  position: sticky;
  top: 86px;
}

.work-panel {
  min-width: 0;
}

.stack {
  display: grid;
  gap: 18px;
}

.stack.narrow {
  width: min(900px, 100%);
  margin: 0 auto;
}

.compact-stack {
  gap: 12px;
}

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

.eyebrow {
  margin: 0 0 4px;
  color: var(--accent-strong);
  font-size: 0.82rem;
  font-weight: 700;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  overflow-wrap: anywhere;
}

h1,
h2,
h3 {
  margin: 0;
  line-height: 1.15;
}

h1 {
  font-size: 2rem;
}

h2 {
  font-size: 1.35rem;
}

h3 {
  font-size: 1.05rem;
}

p {
  margin: 0;
  color: var(--muted);
}

.card-art {
  width: 100%;
  margin: 18px 0;
  aspect-ratio: 7 / 11;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-2);
}

.card-art img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.placeholder-card {
  display: grid;
  place-items: center;
  align-content: center;
  gap: 8px;
  width: 100%;
  height: 100%;
  padding: 20px;
  text-align: center;
  background:
    linear-gradient(135deg, rgba(209, 168, 91, 0.12), transparent 42%),
    var(--surface-2);
}

.placeholder-card span {
  color: var(--text);
  font-size: 1.4rem;
  font-weight: 750;
}

.placeholder-card small {
  color: var(--muted);
}

.meta-list {
  display: grid;
  gap: 10px;
  margin: 0;
}

.meta-list div {
  display: grid;
  grid-template-columns: 90px 1fr;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}

.meta-list dt {
  color: var(--muted);
}

.meta-list dd {
  margin: 0;
  overflow-wrap: anywhere;
}

.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin-top: 16px;
}

.button-row.compact {
  margin-top: 0;
}

.button-row.vertical {
  display: grid;
  align-items: stretch;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 9px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-2);
  color: var(--text);
  cursor: pointer;
  text-align: center;
  overflow-wrap: anywhere;
}

.button:hover {
  border-color: var(--accent);
  color: var(--text);
}

.button.primary {
  border-color: var(--accent);
  background: #4a3820;
  color: #fff5df;
}

.button.ghost {
  background: transparent;
  color: var(--muted);
}

.button.danger {
  border-color: rgba(215, 120, 111, 0.55);
  background: rgba(215, 120, 111, 0.12);
}

.button.small {
  min-height: 34px;
  padding: 6px 10px;
  font-size: 0.92rem;
}

.danger-zone {
  margin-top: 24px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.entry-preview,
.note-card,
.empty-state {
  padding: 18px;
}

.entry-preview {
  border-left: 3px solid var(--accent);
  background: var(--surface-2);
}

.empty-state {
  display: grid;
  gap: 10px;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 4px 9px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-2);
  color: var(--muted);
  font-size: 0.84rem;
}

.status-badge.final {
  border-color: rgba(117, 184, 137, 0.58);
  color: #bde0c6;
}

.status-badge.started {
  border-color: rgba(209, 168, 91, 0.55);
  color: #e7d09a;
}

.status-badge.after-chatgpt {
  border-color: rgba(125, 160, 196, 0.55);
  color: #b9cce1;
}

.status-badge.empty {
  color: #b6b1a4;
}

.badge-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.progress {
  height: 10px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-2);
}

.progress span {
  display: block;
  height: 100%;
  background: var(--green);
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
  gap: 14px;
}

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

.dictionary-main h2 {
  margin-bottom: 3px;
  font-size: 1rem;
}

.dictionary-main p {
  font-size: 0.92rem;
}

.dictionary-actions {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.mini-art {
  display: grid;
  place-items: center;
  width: 58px;
  height: 86px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-2);
}

.mini-art img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.mini-art span,
.table-card span {
  color: var(--accent-strong);
  font-weight: 800;
}

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

.field {
  display: grid;
  gap: 7px;
}

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

.field span,
.check-field span {
  color: var(--muted);
  font-size: 0.92rem;
}

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

input,
select {
  min-height: 42px;
  padding: 9px 11px;
}

textarea {
  min-height: 84px;
  padding: 11px;
  resize: vertical;
}

input:focus,
textarea:focus,
select:focus {
  outline: 2px solid rgba(209, 168, 91, 0.35);
  border-color: var(--accent);
}

.search-panel {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) minmax(180px, 240px) auto auto auto;
  gap: 12px;
  align-items: end;
  padding: 16px;
}

.check-field {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 42px;
}

.check-field input {
  width: auto;
  min-height: auto;
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

table {
  width: 100%;
  min-width: 680px;
  border-collapse: collapse;
  background: var(--surface);
}

th,
td {
  padding: 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
}

th {
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 700;
}

.table-card {
  display: flex;
  align-items: center;
  gap: 10px;
}

.table-card img,
.table-card span {
  width: 36px;
  height: 52px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-2);
  object-fit: cover;
}

.table-card span {
  display: grid;
  place-items: center;
}

.table-actions {
  text-align: right;
}

.entry-list,
.revision-list,
.tool-list {
  display: grid;
  gap: 14px;
}

.entry-item {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-2);
}

.entry-item > div:first-child {
  min-width: 0;
}

.revision-item {
  padding: 0;
  overflow: hidden;
}

.revision-item summary {
  padding: 14px 16px;
  cursor: pointer;
  color: var(--accent-strong);
}

pre {
  margin: 0;
  padding: 16px;
  overflow-x: auto;
  border-top: 1px solid var(--line);
  background: #0d0d0b;
  color: #e9e1d0;
  white-space: pre-wrap;
}

.login-panel {
  display: grid;
  place-items: center;
  min-height: 58vh;
}

.login-panel .note-card {
  width: min(440px, 100%);
}

@media (max-width: 900px) {
  .topbar {
    align-items: flex-start;
    flex-direction: column;
    gap: 10px;
  }

  .page {
    padding: 20px 14px 42px;
  }

  .split-layout {
    grid-template-columns: 1fr;
  }

  .side-panel.sticky {
    position: static;
  }

  .card-art {
    max-width: 340px;
  }

  .section-heading {
    display: grid;
  }

  .form-grid,
  .search-panel {
    grid-template-columns: 1fr;
  }

  .entry-item {
    display: grid;
  }
}

@media (max-width: 560px) {
  h1 {
    font-size: 1.55rem;
  }

  .topbar {
    padding: 12px 14px;
  }

  .nav {
    width: 100%;
  }

  .nav a {
    flex: 1 1 auto;
    text-align: center;
  }

  .side-panel,
  .work-panel,
  .note-card,
  .empty-state,
  .search-panel,
  .dictionary-card {
    padding: 14px;
  }

  .dictionary-card {
    grid-template-columns: 48px minmax(0, 1fr);
  }

  .mini-art {
    width: 48px;
    height: 72px;
  }

  .button-row,
  .button-row.compact {
    display: grid;
    width: 100%;
  }

  .button {
    width: 100%;
  }
}
