:root {
  --ink: #241910;
  --muted: #74685c;
  --paper: #f4ecdf;
  --paper-2: #fbf6ee;
  --line: #e3d5c3;
  --room: #231910;
  --room-2: #31261d;
  --clay: #c4622d;
  --clay-2: #a34e22;
  --moss: #dce8df;
  --moss-ink: #1d5a40;
  --danger: #8d2f24;
  --shadow: 0 24px 60px rgba(0, 0, 0, .28);
  --sans: "Outfit", "Segoe UI", sans-serif;
  --serif: "Fraunces", "Palatino Linotype", Palatino, serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  color: var(--paper);
  background:
    radial-gradient(1200px 500px at 50% -10%, #3a2c22 0%, transparent 55%),
    var(--room);
  font-family: var(--sans);
  font-weight: 380;
  letter-spacing: .01em;
}
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
h1, h2, h3, p { margin: 0; }
[hidden] { display: none !important; }

.brand {
  font-size: .78rem;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: #c8b8a4;
}

.btn {
  border: 1px solid transparent;
  border-radius: 999px;
  padding: .55rem 1rem;
  background: transparent;
}
.btn.solid { background: var(--clay); color: #fffaf4; }
.btn.solid:hover { background: var(--clay-2); }
.btn.ghost { border-color: #d9cbb8; color: var(--ink); background: transparent; }
.btn.danger { background: transparent; color: var(--danger); border-color: #e4b2ab; }
.shell .btn.ghost { color: var(--paper); border-color: #6d5c4d; }

.gate {
  min-height: 100%;
  display: grid;
  place-items: center;
  padding: 1.5rem;
}
.gate-card, .panel, .sheet {
  background: var(--paper);
  color: var(--ink);
}
.gate-card {
  width: min(440px, 100%);
  padding: 1.6rem 1.5rem 1.4rem;
  border-radius: 18px;
  box-shadow: var(--shadow);
}
.gate-card h1 {
  font-family: var(--serif);
  font-weight: 560;
  font-size: 2rem;
  line-height: 1.15;
  margin: .35rem 0 .6rem;
}
.lede { color: var(--muted); margin-bottom: 1rem; }
.gate-card label, .panel label {
  display: grid;
  gap: .35rem;
  margin-bottom: .75rem;
  font-size: .92rem;
}
input, select {
  width: 100%;
  border: 1px solid var(--line);
  background: var(--paper-2);
  color: var(--ink);
  border-radius: 10px;
  padding: .65rem .75rem;
}
.row-actions { display: flex; flex-wrap: wrap; gap: .6rem; margin-top: .4rem; }
.form-error { min-height: 1.2rem; color: var(--danger); margin-top: .7rem; }

.shell {
  min-height: 100%;
  display: grid;
  grid-template-rows: auto 1fr auto;
}
.top {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 1rem;
  align-items: center;
  padding: .85rem 1.2rem .7rem;
}
.deck-path {
  color: #c8b8a4;
  font-size: .82rem;
  margin-top: .15rem;
}
.top-title { min-width: 0; }
.top-title h1 {
  font-family: var(--sans);
  font-weight: 500;
  font-size: .95rem;
  line-height: 1.3;
  color: #f6efe6;
}
.top-user {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: .85rem;
}
.head-link {
  color: #f6efe6;
  text-decoration: none;
  padding: .4rem .15rem;
  line-height: 1.2;
}
.head-link:hover { color: #fffaf4; }
.user-menu { position: relative; }
.user-name {
  border: 0;
  background: transparent;
  color: #f6efe6;
  padding: .4rem .15rem;
  font-weight: 500;
}
.user-pop {
  position: absolute;
  top: calc(100% + .4rem);
  right: 0;
  min-width: 9.2rem;
  background: var(--paper);
  color: var(--ink);
  border-radius: 12px;
  box-shadow: var(--shadow);
  padding: .3rem;
  z-index: 4;
  display: grid;
}
.user-pop-link {
  display: block;
  width: 100%;
  text-align: left;
  border: 0;
  background: transparent;
  color: var(--ink);
  text-decoration: none;
  border-radius: 8px;
  padding: .55rem .75rem;
}
.user-pop-link:hover { background: #efe4d4; }
.resume-chip {
  border: 1px solid #5c4b3d;
  background: #2c221b;
  color: #f3eadf;
  border-radius: 14px;
  padding: .45rem .8rem .5rem;
  display: grid;
  justify-items: center;
  min-width: 9rem;
}
.resume-chip span { font-size: .75rem; color: #cbbba8; }
.resume-chip strong {
  font-family: var(--serif);
  font-size: 1.45rem;
  font-weight: 650;
}
.resume-chip:disabled { opacity: .45; cursor: default; }

.stage {
  display: grid;
  grid-template-columns: minmax(64px, 1fr) minmax(260px, 760px) minmax(64px, 1fr);
  min-height: 0;
}
.learned {
  border: 1px solid #6d8f78;
  background: #1d5a40;
  color: #f3faf6;
  border-radius: 999px;
  padding: .7rem .85rem;
  font-weight: 500;
  letter-spacing: .01em;
}
.learned:hover { background: #246b4c; }
.learned:disabled { opacity: .45; cursor: default; }
.dock-actions { display: flex; flex-wrap: wrap; align-items: center; gap: .6rem; }
.edge {
  border: 0;
  background: transparent;
  position: relative;
  color: transparent;
}
.edge::after {
  content: "";
  position: absolute;
  top: 50%;
  width: 14px;
  height: 14px;
  border-top: 2px solid #f0e4d4;
  opacity: .16;
}
.edge-left::after {
  right: 22%;
  border-left: 2px solid #f0e4d4;
  transform: translateY(-50%) rotate(-45deg);
}
.edge-right::after {
  left: 22%;
  border-right: 2px solid #f0e4d4;
  transform: translateY(-50%) rotate(45deg);
}
.edge:hover::after, .edge:focus-visible::after { opacity: .95; }
.edge:hover, .edge:focus-visible {
  background: linear-gradient(to right, rgba(255, 244, 230, .08), transparent 70%);
  outline: none;
}
.edge-right:hover, .edge-right:focus-visible {
  background: linear-gradient(to left, rgba(255, 244, 230, .08), transparent 70%);
}

.sheet {
  margin: .2rem 0 1rem;
  border-radius: 22px;
  box-shadow: var(--shadow);
  padding: 1.3rem 1.4rem 1rem;
  display: flex;
  flex-direction: column;
  min-height: min(68vh, 640px);
  background-image: radial-gradient(rgba(90, 60, 30, .035) .7px, transparent .7px);
  background-size: 4px 4px;
}
.sheet-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .6rem;
  margin-bottom: .8rem;
}
.kicker {
  font-size: .75rem;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--clay);
}
.card-font { display: flex; gap: .35rem; }
.card-font button {
  border: 1px solid var(--line);
  background: var(--paper-2);
  color: var(--ink);
  border-radius: 999px;
  padding: .18rem .55rem;
  font-size: .85rem;
  line-height: 1.2;
}
.card-font button:disabled { opacity: .4; cursor: default; }
.field { margin-bottom: .85rem; }
.field-label {
  font-size: .78rem;
  letter-spacing: .04em;
  color: var(--muted);
  margin-bottom: .2rem;
}
.q-text {
  font-family: var(--serif);
  font-weight: 560;
  font-size: calc(clamp(1.7rem, 4vw, 2.7rem) * var(--card-scale, 1));
  line-height: 1.22;
  text-wrap: pretty;
}
.extras {
  display: grid;
  gap: .45rem;
  margin: .4rem 0 1rem;
}
.extra {
  display: grid;
  grid-template-columns: 7.5rem 1fr;
  gap: .6rem;
  padding: .45rem 0;
  border-top: 1px solid var(--line);
  font-size: 1.02rem;
}
.extra .field-label { margin: 0; align-self: center; }
.read-flag {
  margin-top: auto;
  font-size: .85rem;
  color: var(--muted);
}
.read-flag.is-read { color: var(--moss-ink); }
.reveal {
  margin-top: .8rem;
  width: 100%;
  border: 0;
  border-radius: 12px;
  padding: .85rem 1rem;
  background: #2a211b;
  color: #f7f1e8;
}
.reveal:hover { background: #3a2d24; }
.reveal[aria-expanded="true"] { background: #efe4d4; color: var(--ink); }
.answer { margin-top: .9rem; }
.answer-item {
  padding: .75rem 0 .15rem;
  border-top: 1px solid var(--line);
}
.answer-item .field-text,
.extra .field-text {
  font-family: var(--serif);
  font-size: calc(1.28rem * var(--card-scale, 1));
  line-height: 1.35;
  text-wrap: pretty;
}
.empty-note { color: var(--muted); font-size: 1.05rem; }

.dock {
  display: grid;
  grid-template-columns: minmax(180px, 1.2fr) auto auto auto;
  gap: 1rem 1.2rem;
  align-items: center;
  padding: .85rem 1.2rem 1.1rem;
}
.jump { display: flex; flex-wrap: wrap; align-items: end; gap: .6rem .8rem; }
.jump label { display: grid; gap: .25rem; font-size: .85rem; color: #d9cbbd; min-width: 7rem; }
.jump input { width: 7.2rem; background: #2c241d; color: #f6efe6; border-color: #5c4d40; }
.hint { color: #b5a494; font-size: .8rem; max-width: 28rem; }
.modes {
  display: inline-flex;
  justify-self: start;
  width: max-content;
  align-items: stretch;
  background: #2c241d;
  border: 1px solid #5c4d40;
  border-radius: 12px;
}
.mode {
  border: 0;
  background: transparent;
  color: #cbbba8;
  padding: .42rem .72rem .5rem;
  position: relative;
  line-height: 1.15;
}
.mode.active { color: #f4fff8; }
.mode.active::after {
  content: "";
  position: absolute;
  left: .62rem;
  right: .62rem;
  bottom: .16rem;
  height: 3px;
  border-radius: 3px;
  background: #3dce8a;
}
.stats { justify-self: end; display: grid; justify-items: end; gap: .15rem; }
.remain { justify-self: end; color: #efe4d6; font-size: .95rem; }
#today { color: #f3e2cf; }

.overlay {
  position: fixed;
  inset: 0;
  background: rgba(22, 14, 10, .62);
  display: grid;
  place-items: start center;
  overflow: auto;
  padding: 1.2rem;
  z-index: 5;
}
.panel {
  width: min(860px, 100%);
  border-radius: 18px;
  padding: 1rem 1.1rem 1.4rem;
  margin: 1rem 0 2rem;
}
.panel-head, .block h3 { display: flex; justify-content: space-between; align-items: center; gap: 1rem; }
.panel-foot {
  display: flex;
  flex-wrap: wrap;
  gap: .6rem;
  margin-top: 1.2rem;
  padding-top: 1rem;
  border-top: 1px solid var(--line);
}
.menu-link {
  display: inline-flex;
  margin-top: .85rem;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--clay-2);
  text-decoration: underline;
  text-underline-offset: .18em;
  font-size: 1.02rem;
}
.edit-panel { width: min(640px, 100%); }
.edit-field { display: grid; gap: .35rem; margin-bottom: .9rem; }
.edit-field span { color: var(--muted); font-size: .85rem; }
textarea {
  width: 100%;
  min-height: 4.6rem;
  border: 1px solid var(--line);
  background: var(--paper-2);
  color: var(--ink);
  border-radius: 10px;
  padding: .65rem .75rem;
  resize: vertical;
  font: inherit;
}
.panel h2, .block h3 { font-family: var(--serif); font-weight: 560; }
.block { margin-top: 1.1rem; padding-top: 1rem; border-top: 1px solid var(--line); }
.block h3 { margin-bottom: .7rem; }
.deck-tree { display: grid; gap: .1rem; margin-bottom: .85rem; }
.deck-folder-head { display: flex; align-items: center; gap: .1rem; }
.deck-twist {
  width: 1.5rem;
  flex: none;
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: .35rem 0;
}
.deck-folder-label { padding: .28rem .25rem; font-weight: 500; font-size: .88rem; }
.deck-leaf {
  flex: 1;
  text-align: left;
  border: 0;
  background: transparent;
  color: var(--ink);
  border-radius: 8px;
  padding: .28rem .4rem;
  font-size: .88rem;
}
.deck-leaf.active { background: #efe4d4; }
.deck-leaf:hover, .deck-twist:hover { background: #f6efe6; }
.font-lock { display: flex; align-items: center; gap: .75rem; }
.font-lock strong { min-width: 6.5rem; font-weight: 500; }
.font-lock .btn { width: auto; }
.font-lock .btn:disabled { opacity: .4; cursor: default; }
.panel .hint { color: var(--muted); margin: .35rem 0 .7rem; }
.resume-line { font-size: 1.05rem; margin-bottom: .7rem; }
.pick-row {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: .7rem;
  align-items: start;
  padding: .55rem 0;
  border-bottom: 1px solid #efe4d6;
}
.compare-row {
  display: grid;
  width: 100%;
  text-align: left;
  border: 0;
  border-bottom: 1px solid #efe4d6;
  background: transparent;
  color: var(--ink);
  padding: .75rem .2rem;
  gap: .15rem;
}
.compare-row:hover { background: #efe4d4; }
#import-report { z-index: 7; }
#duplicates { z-index: 6; }
.dup-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: .6rem;
  margin: .2rem 0 1rem;
}
.dup-stat {
  background: var(--paper-2);
  border-radius: 12px;
  padding: .65rem .75rem;
}
.dup-stat span { display: block; color: var(--muted); font-size: .78rem; }
.dup-stat strong { font-family: var(--serif); font-size: 1.35rem; font-weight: 560; }
.dup-item { padding: .8rem 0; border-top: 1px solid var(--line); }
.dup-text { font-size: 1.02rem; line-height: 1.4; }
.dup-where { margin: .2rem 0 .35rem; color: var(--muted); font-size: .82rem; }
.dup-places { display: grid; gap: .2rem; }
.dup-place {
  text-align: left;
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: 0;
  font-size: .9rem;
}
button.dup-place { color: var(--clay-2); cursor: pointer; }
button.dup-place:hover { text-decoration: underline; text-underline-offset: .15em; }
.compare-row span { color: var(--muted); font-size: .88rem; }
.compare-group {
  padding: .85rem 0 .7rem;
  border-bottom: 1px solid #efe4d6;
}
.compare-text {
  white-space: pre-wrap;
  line-height: 1.4;
  margin-bottom: .55rem;
}
.compare-pos { display: flex; flex-wrap: wrap; gap: .4rem; }
.compare-pos button {
  border: 1px solid var(--line);
  background: var(--paper-2);
  color: var(--ink);
  border-radius: 999px;
  padding: .28rem .65rem;
}
.compare-pos button:hover { background: #efe4d4; }
.pick-row input { width: auto; margin-top: .2rem; }
.pick-row p { color: var(--muted); font-size: .88rem; margin-top: .15rem; }
.col-row {
  display: grid;
  grid-template-columns: 4.2rem 1fr 13.5rem 1fr;
  gap: .55rem;
  align-items: center;
  padding: .45rem 0;
  border-bottom: 1px solid #efe4d6;
}
.col-no { color: var(--muted); font-size: .85rem; }
.col-sample { font-size: .92rem; line-height: 1.3; }
.col-row input, .col-row select { padding: .45rem .55rem; }
.export-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: .45rem .8rem;
  padding: .6rem 0;
  border-bottom: 1px solid #efe4d6;
}
.export-row p { font-weight: 500; font-size: .9rem; }
.empty-cols { margin-top: .8rem; color: var(--muted); }
.empty-cols summary { cursor: pointer; margin-bottom: .4rem; }

.toast {
  position: fixed;
  left: 50%;
  bottom: 1.2rem;
  transform: translateX(-50%);
  background: #f6efe6;
  color: var(--ink);
  border-radius: 999px;
  padding: .65rem 1rem;
  box-shadow: var(--shadow);
  z-index: 6;
}

@media (max-width: 800px) {
  .top { grid-template-columns: 1fr; justify-items: start; }
  .top-user { justify-content: flex-start; }
  .stage { grid-template-columns: 46px 1fr 46px; }
  .sheet { padding: 1rem .85rem .8rem; min-height: 58vh; }
  .dock { grid-template-columns: 1fr; }
  .dock-actions { justify-self: start; }
  .stats, .remain { justify-self: start; }
  .col-row { grid-template-columns: 1fr 1fr; }
  .col-sample { grid-column: 1 / -1; }
  .extra { grid-template-columns: 1fr; gap: .15rem; }
}
