:root {
  --bg: #efe8dc;
  --paper: #f7f2ea;
  --ink: #1d1914;
  --muted: #6b6256;
  --line: #d8cfc0;
  --accent: #9a3b1c;
  --ok: #2f6b45;
  --side: #221c17;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
[hidden] { display: none !important; }
body {
  font-family: "IBM Plex Sans", system-ui, sans-serif;
  color: var(--ink);
  background: var(--bg);
}

.login-body {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background:
    radial-gradient(circle at 10% 10%, #f4e7cf, transparent 40%),
    #1c1713;
}
.login-card {
  width: min(440px, 92vw);
  background: var(--paper);
  padding: 36px 32px;
  border-radius: 8px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.35);
}
.eyebrow {
  letter-spacing: 0.14em;
  text-transform: uppercase;
  font-size: 0.72rem;
  color: var(--accent);
  margin: 0 0 8px;
}
.login-card h1 {
  font-family: Fraunces, Georgia, serif;
  font-weight: 500;
  margin: 0 0 8px;
}
.lead, .hint { color: var(--muted); line-height: 1.45; }
.lead-sub {
  color: var(--muted);
  font-size: 0.85rem;
  line-height: 1.4;
  margin: -4px 0 16px;
}
.login-card label,
.panel label {
  display: block;
  font-size: 0.8rem;
  margin: 12px 0;
  color: var(--muted);
}
.login-card input,
.panel input,
.panel select,
.panel textarea,
.filters select {
  display: block;
  width: 100%;
  margin-top: 6px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  padding: 10px 12px;
  font: 400 1rem "IBM Plex Sans", sans-serif;
  border-radius: 6px;
}
button, .login-card button {
  appearance: none;
  border: 0;
  background: var(--accent);
  color: #fff;
  padding: 12px 16px;
  border-radius: 6px;
  font: 600 0.95rem "IBM Plex Sans", sans-serif;
  cursor: pointer;
}
.login-actions {
  display: flex;
  gap: 10px;
  margin-top: 8px;
}
.login-actions .ghost-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none !important;
  font: 600 0.95rem "IBM Plex Sans", sans-serif;
}
.form-error { color: #9a1f12; }
.form-ok { color: var(--ok); }
.form-actions {
  display: flex;
  gap: 10px;
  margin-top: 8px;
}
.ghost-btn {
  background: #fff;
  color: var(--ink);
  border: 1px solid var(--line);
  padding: 12px 16px;
  border-radius: 6px;
}

.desk { display: grid; grid-template-columns: 240px 1fr; min-height: 100vh; }
.side {
  background: var(--side);
  color: #efe6d6;
  padding: 22px 16px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}
.logo {
  font-family: Fraunces, Georgia, serif;
  color: #efe6d6;
  text-decoration: none;
  font-size: 1.4rem;
}
.side nav { display: flex; flex-direction: column; gap: 6px; }
.side nav a {
  color: #cbbba4;
  text-decoration: none;
  padding: 8px 10px;
  border-radius: 6px;
}
.side nav a.on, .side nav a:hover { background: #3a3128; color: #fff; }
.who { margin-top: auto; color: #b7aa97; font-size: 0.9rem; }
.permalink {
  color: #cbbba4;
  font-size: 0.72rem;
  line-height: 1.35;
  word-break: break-all;
  margin: 0;
  font-family: "IBM Plex Mono", ui-monospace, monospace;
}
.side button { background: #3a3128; width: 100%; }
a.hash-link {
  color: var(--accent);
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-weight: 500;
}

.work { padding: 28px 32px 60px; }
.work header h1 {
  font-family: Fraunces, Georgia, serif;
  font-weight: 500;
  margin: 0 0 6px;
}
.work header p { margin: 0 0 20px; color: var(--muted); }
.grid-2 { display: grid; grid-template-columns: 1.1fr 0.9fr; gap: 20px; }
.panel {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 18px;
}
.row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.preview img {
  width: 100%;
  border-radius: 8px;
  max-height: 420px;
  object-fit: contain;
  background: #1c1713;
}
.dropzone {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 160px;
  margin-bottom: 12px;
  border: 2px dashed #c4b49a;
  border-radius: 10px;
  background: #f3ece1;
  text-align: center;
  cursor: pointer;
  color: var(--muted);
}
.dropzone input[type="file"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  display: block;
}
.dropzone-copy {
  margin: 0;
  pointer-events: none;
  font-size: 1rem;
  color: var(--ink);
  line-height: 1.35;
}
.dropzone-copy small {
  display: inline-block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.85rem;
}
.dropzone.over,
.preview.over {
  border-color: var(--accent);
  background: #f6e4d4;
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}
.preview.drop-target {
  min-height: 220px;
}
.muted { color: var(--muted); }

.table-wrap { overflow: auto; background: var(--paper); border: 1px solid var(--line); border-radius: 10px; }
table { width: 100%; border-collapse: collapse; font-size: 0.92rem; }
th, td { padding: 10px 12px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
th { font-size: 0.75rem; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }
td img.thumb { width: 44px; height: 58px; object-fit: cover; border-radius: 4px; display: block; }
.stato {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 99px;
  font-size: 0.75rem;
  background: #eee4d4;
}
.stato.pending { background: #f3d7a2; }
.stato.published { background: #cfe6d4; }
.stato.rejected { background: #f0c8c0; }
.cards { display: grid; gap: 16px; }
.approve {
  display: grid;
  grid-template-columns: 160px 1fr;
  gap: 16px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 14px;
}
.approve img { width: 160px; height: 214px; object-fit: cover; border-radius: 6px; }
.actions { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; align-items: center; }
.actions a { text-decoration: none; display: inline-flex; align-items: center; }
.actions .ghost { background: #fff; color: var(--ink); border: 1px solid var(--line); }
.actions .danger,
button.danger { background: #7a2414; }

.inline { display: grid; grid-template-columns: 1fr 1fr 140px auto; gap: 10px; align-items: end; margin-bottom: 16px; }
.inline label { margin: 0; }
#edit-editor { max-width: 520px; margin-bottom: 16px; }
#edit-editor h2 {
  font-family: Fraunces, Georgia, serif;
  font-weight: 500;
  font-size: 1.15rem;
  margin: 0 0 8px;
}

.db-layout { display: grid; grid-template-columns: 220px 1fr; gap: 14px; min-height: 60vh; }
.db-tables {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px;
}
.db-tables button {
  display: block;
  width: 100%;
  text-align: left;
  background: transparent;
  color: var(--ink);
  margin-bottom: 4px;
  font-weight: 500;
}
.db-tables button small { display: block; color: var(--muted); font-weight: 400; }
.db-tables button.on { background: #e8d8c2; }
.db-view { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.db-toolbar { display: flex; justify-content: space-between; gap: 12px; align-items: center; }
.db-toolbar input { width: min(320px, 50%); padding: 8px 10px; border: 1px solid var(--line); border-radius: 6px; }
.db-grid { max-height: 62vh; }
.db-grid th, .db-grid td {
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 0.78rem;
  white-space: nowrap;
  max-width: 280px;
  overflow: hidden;
  text-overflow: ellipsis;
}
.db-pager { display: flex; gap: 10px; align-items: center; }
.db-pager button { background: #3a3128; }

.linkish { background: transparent; color: var(--accent); padding: 0; font-weight: 500; }
.hash-link {
  background: transparent;
  color: var(--accent);
  padding: 0;
  font-weight: 500;
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
}
#btn-rientro { background: #3a3128; }

.versioni {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 12px;
  max-width: 720px;
}
.versioni li {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 16px 18px;
}
.versioni li.now { border-color: var(--accent); }
.ver-head {
  display: flex;
  gap: 12px;
  align-items: baseline;
  flex-wrap: wrap;
}
.ver-num {
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-weight: 500;
  color: var(--accent);
}
.ver-head h3 {
  font-family: Fraunces, Georgia, serif;
  font-weight: 500;
  font-size: 1.15rem;
  margin: 0;
}
.ver-head time { color: var(--muted); font-size: 0.9rem; }
.versioni p { margin: 8px 0 0; color: #3d362e; line-height: 1.45; }

@media (max-width: 900px) {
  .desk { grid-template-columns: 1fr; }
  .grid-2, .row, .db-layout, .inline, .approve { grid-template-columns: 1fr; }
}
