:root {
  --accent: #b85042;
  --accent-dark: #87392f;
  --background: #eef1ed;
  --surface: #fffaf2;
  --text: #25211e;
  --muted: #6f6760;
  --line: rgba(37, 33, 30, 0.14);
  --shadow: 0 20px 55px rgba(41, 35, 30, 0.14);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  font-family: "Segoe UI", Arial, sans-serif;
  background-color: var(--background);
  background-image: var(--background-image, none);
  background-size: cover;
  background-position: center;
  background-attachment: fixed;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  background: rgba(245, 242, 236, 0.76);
  backdrop-filter: blur(1px);
}

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

.app-shell {
  width: min(1500px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 48px;
}

.lock-screen {
  min-height: calc(100vh - 56px);
  display: grid;
  place-items: center;
}

.lock-panel, .panel, .stats-grid article {
  background: color-mix(in srgb, var(--surface) 94%, white 6%);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.lock-panel {
  width: min(460px, 100%);
  padding: 34px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--accent-dark);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 8px; font-size: clamp(2rem, 4vw, 3.6rem); line-height: 1; }
h2 { margin-bottom: 12px; font-size: 1.2rem; }

.library-app { display: grid; gap: 18px; }
.topbar, .panel-heading, .list-heading, .topbar-actions { display: flex; align-items: center; gap: 14px; }
.topbar { justify-content: space-between; }
.panel-heading, .list-heading { justify-content: space-between; }

.primary-action, .ghost-action, .danger-action, .icon-action {
  min-height: 42px;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 0 16px;
  font-weight: 800;
}

.primary-action { background: var(--accent); color: white; }
.primary-action:hover { background: var(--accent-dark); }
.ghost-action { background: rgba(255, 255, 255, 0.42); color: var(--text); border-color: var(--line); }
.danger-action { background: #8e2f2b; color: white; margin-top: 10px; }
.icon-action { width: 42px; padding: 0; font-size: 1.4rem; line-height: 1; transform: rotate(45deg); background: rgba(255,255,255,0.4); border-color: var(--line); }

.stats-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
.stats-grid article { padding: 18px; }
.stats-grid span { display: block; font-size: 2rem; font-weight: 900; color: var(--accent-dark); }
.stats-grid p, .panel-copy, .small-copy, #listMeta { color: var(--muted); margin-bottom: 0; }

.workspace { display: grid; grid-template-columns: minmax(310px, 390px) minmax(0, 1fr); gap: 18px; align-items: start; }
.lower-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; }
.panel { padding: 20px; }

.fiction-form, .field-row { display: grid; gap: 8px; }
.fiction-form { gap: 14px; }
.split-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
label { color: #433d38; font-size: 0.9rem; font-weight: 800; }
input, select, textarea {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.72);
}
textarea { resize: vertical; }
input[type="color"] { padding: 3px; }
.check-row { display: flex; align-items: center; gap: 10px; font-weight: 700; color: var(--muted); }
.check-row input { width: 18px; min-height: 18px; }

.duplicate-warning, .message {
  margin: 0;
  color: #7b321c;
  font-weight: 800;
}

.table-wrap { overflow-x: auto; position: relative; }
table { width: 100%; min-width: 860px; border-collapse: collapse; }
th, td { border-bottom: 1px solid var(--line); padding: 12px 10px; text-align: left; vertical-align: top; }
th { color: var(--muted); font-size: 0.78rem; text-transform: uppercase; }
th button { border: 0; background: transparent; color: inherit; padding: 0; font-weight: 900; text-transform: uppercase; }
td strong { display: block; margin-bottom: 4px; }
.row-notes { color: var(--muted); font-size: 0.86rem; max-width: 30rem; }
.link-stack, .row-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.link-stack a, .row-actions button {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 10px;
  color: var(--accent-dark);
  background: rgba(255, 255, 255, 0.5);
  text-decoration: none;
  font-weight: 800;
  font-size: 0.84rem;
}
.row-actions button.delete-link { color: #8e2f2b; }
.stars { color: #b45a24; white-space: nowrap; font-weight: 900; }
.empty-state { padding: 24px; text-align: center; color: var(--muted); }
.search-wrap { min-width: min(270px, 100%); }

details { margin-top: 14px; color: var(--muted); }
summary { cursor: pointer; font-weight: 800; color: var(--text); }

@media (max-width: 1050px) {
  .workspace, .lower-grid { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 680px) {
  .app-shell { width: min(100% - 18px, 1500px); padding-top: 12px; }
  .topbar, .panel-heading, .list-heading { align-items: stretch; flex-direction: column; }
  .topbar-actions { width: 100%; }
  .topbar-actions button { flex: 1; }
  .split-fields, .stats-grid { grid-template-columns: 1fr; }
  .lock-panel, .panel { padding: 16px; }
  h1 { font-size: 2.1rem; }
}
