:root {
  --paper: #ffffff;
  --ink: #121212;
  --muted: #666;
  --rule: #121212;
  --box: #999;
  --bg: #e8e6e1;
  --accent: #326891;
  --serif: "Libre Caslon Text", "Times New Roman", Georgia, serif;
  --sans: "Libre Franklin", "Helvetica Neue", Arial, sans-serif;
  --sheet-w: 1100px;
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
}

/* ---------- toolbar (not part of the exported image) ---------- */

.toolbar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: #fafaf8;
  border-bottom: 1px solid #d5d2cb;
}
.toolbar-inner {
  max-width: var(--sheet-w);
  margin: 0 auto;
  padding: 12px 16px;
  display: flex;
  flex-wrap: wrap;
  gap: 12px 24px;
  align-items: center;
  justify-content: space-between;
}
.toolbar-title { display: flex; flex-direction: column; gap: 2px; font-size: 14px; }
.toolbar-title .hint { color: var(--muted); font-size: 12px; max-width: 560px; }
.toolbar-actions { display: flex; flex-wrap: wrap; gap: 8px; }

button {
  font: 500 13px/1 var(--sans);
  padding: 9px 14px;
  border: 1px solid var(--ink);
  background: var(--ink);
  color: #fff;
  border-radius: 3px;
  cursor: pointer;
}
button:hover { background: #333; }
button.secondary { background: #fff; color: var(--ink); }
button.secondary:hover { background: #f0f0f0; }
button.danger { background: #fff; color: #a3231b; border-color: #a3231b; }
button.danger:hover { background: #fbeeed; }
button.danger.armed { background: #a3231b; color: #fff; }

/* ---------- the sheet ---------- */

.page { padding: 28px 16px 64px; }
.sheet-wrap { overflow-x: auto; }

.sheet {
  width: var(--sheet-w);
  min-width: var(--sheet-w);
  margin: 0 auto;
  background: var(--paper);
  color: var(--ink);
  padding: 56px 64px 48px;
  box-shadow: 0 1px 2px rgba(0,0,0,.08), 0 12px 40px rgba(0,0,0,.10);
}

.masthead { margin-bottom: 20px; }
.kicker {
  font: 500 12px/1.3 var(--sans);
  letter-spacing: .02em;
  color: var(--muted);
  margin-bottom: 10px;
}
.headline {
  font: 400 44px/1.1 var(--serif);
  letter-spacing: -.01em;
  margin: 0;
  outline: none;
  min-height: 1.1em;
  padding: 2px 0;
  border-bottom: 1px dashed transparent;
  cursor: text;
}
.headline:hover, .headline:focus { border-bottom-color: #bbb; }
.headline:empty::before {
  content: attr(data-placeholder);
  color: #aaa;
}
.sheet.exporting .headline { border-bottom-color: transparent; }

.rule { height: 1px; background: var(--rule); }

.col-heads {
  display: grid;
  grid-template-columns: 1fr 1fr;
  column-gap: 48px;
  padding: 12px 0 8px;
}
.col-head { display: flex; justify-content: flex-end; gap: 0; }
.box-head {
  width: 60px;
  font: 500 9px/1.25 var(--sans);
  text-transform: uppercase;
  letter-spacing: .04em;
  color: #444;
  text-align: center;
}

/* ---------- the list ---------- */

.list {
  list-style: none;
  margin: 0;
  padding: 26px 0 20px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: repeat(var(--rows, 50), auto);
  grid-auto-flow: column;
  column-gap: 48px;
  row-gap: 0;
}

.row {
  display: flex;
  align-items: center;
  height: 23.5px;
  font-size: 13px;
  line-height: 1.2;
  position: relative;
  background: var(--paper);
  cursor: grab;
}
.row:active { cursor: grabbing; }
.row .num {
  width: 36px;
  flex: none;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.row .show {
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  padding-right: 8px;
}
.row .title { font-weight: 700; color: inherit; text-decoration: none; }
a.title:hover { text-decoration: underline; text-decoration-color: var(--accent); }
.row .years { font-weight: 400; color: #333; }

.boxes { display: flex; flex: none; }
.box {
  width: 60px;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 0;
  background: none;
  padding: 0;
  cursor: pointer;
}
.box span {
  display: block;
  width: 12px;
  height: 12px;
  border: 1px solid var(--box);
  font: 700 11px/10px var(--sans);
  text-align: center;
  color: var(--ink);
}
.box[aria-pressed="true"] span::before { content: "\2713"; }

.row-actions {
  position: absolute;
  right: 120px;
  top: 0;
  height: 100%;
  display: none;
  align-items: center;
  gap: 4px;
  padding-left: 12px;
  background: linear-gradient(90deg, rgba(255,255,255,0), #fff 25%);
}
.row:hover .row-actions { display: flex; }
.sheet.exporting .row-actions { display: none !important; }
.row-actions button {
  font: 500 10px/1 var(--sans);
  padding: 4px 6px;
  border-radius: 2px;
  background: #fff;
  color: var(--ink);
  border: 1px solid #bbb;
}
.row-actions button:hover { border-color: var(--ink); }
.row-actions button.remove:hover { color: #a3231b; border-color: #a3231b; }

.sortable-ghost { opacity: .25; }
.sortable-drag { box-shadow: 0 4px 16px rgba(0,0,0,.2); cursor: grabbing; }
.sortable-chosen { background: #f5f2ea; }

.sheet-footer {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  padding-top: 14px;
  font: 400 12px/1.3 var(--sans);
  color: #333;
}
.sheet-footer a { color: inherit; text-decoration: none; }
.sheet-footer .credit { color: var(--muted); }

/* ---------- dialog ---------- */

dialog {
  border: 1px solid #ccc;
  border-radius: 6px;
  padding: 0;
  width: min(480px, calc(100vw - 32px));
  box-shadow: 0 20px 60px rgba(0,0,0,.25);
  font-family: var(--sans);
}
dialog::backdrop { background: rgba(0,0,0,.35); }
dialog form { padding: 22px 24px; display: flex; flex-direction: column; gap: 14px; }
dialog h2 { margin: 0 0 4px; font: 400 24px/1.1 var(--serif); }
.field { display: flex; flex-direction: column; gap: 5px; font-size: 12px; color: #444; }
.field input {
  font: 400 14px/1.3 var(--sans);
  padding: 8px 10px;
  border: 1px solid #bbb;
  border-radius: 3px;
}
.field input:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: var(--accent); }
.results {
  list-style: none;
  margin: -8px 0 0;
  padding: 0;
  border: 1px solid #ccc;
  border-radius: 3px;
  max-height: 200px;
  overflow-y: auto;
}
.results li { padding: 8px 10px; font-size: 13px; cursor: pointer; border-bottom: 1px solid #eee; }
.results li:last-child { border-bottom: 0; }
.results li:hover { background: #f3f1ec; }
.results li .desc { display: block; color: var(--muted); font-size: 11px; }
.results li.empty { color: var(--muted); cursor: default; }
.dlg-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 6px; }

/* ---------- toast ---------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translate(-50%, 20px);
  background: var(--ink);
  color: #fff;
  font-size: 13px;
  padding: 10px 16px;
  border-radius: 4px;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s, transform .2s;
  max-width: calc(100vw - 32px);
  z-index: 20;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 720px) {
  .toolbar-title .hint { display: none; }
}
