:root {
  --desk: #16181d;
  --paper: #f7f6f2;
  --rail: #1e2128;
  --ink: #14161a;
  --rail-text: #d9d6cf;
  --mute: #8a877f;
  --tungsten: #e0a35c;
  --counter: #d45a48;
  --holds: #3d9a7a;
  --shaky: #c9a227;
  --fails: #d45a48;
  --rule: #e4e0d8;
  --hair: rgba(255, 255, 255, 0.08);
  --sans: "IBM Plex Sans", "Helvetica Neue", sans-serif;
  --serif: "Source Serif 4", "Iowan Old Style", Georgia, serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--desk);
  color: var(--rail-text);
  font-family: var(--sans);
  display: flex;
  flex-direction: column;
}

.bar {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.65rem 1rem;
  border-bottom: 1px solid var(--hair);
  background: #14161b;
}
.mark {
  font-family: var(--serif);
  font-weight: 600;
  color: var(--paper);
  text-decoration: none;
  letter-spacing: -0.02em;
  white-space: nowrap;
}
.mark i {
  font-weight: 400;
  font-size: 0.78em;
  color: var(--mute);
  letter-spacing: 0;
  margin-left: 0.35em;
}
.status {
  flex: 1;
  margin: 0;
  font-size: 0.8rem;
  color: var(--mute);
}
.actions { display: flex; gap: 0.5rem; }
button {
  font-family: var(--sans);
  font-size: 0.85rem;
  font-weight: 600;
  border: 0;
  border-radius: 2px;
  padding: 0.45rem 0.8rem;
  background: var(--tungsten);
  color: var(--ink);
  cursor: pointer;
}
button:disabled { opacity: 0.4; cursor: not-allowed; }
button.quiet {
  background: transparent;
  color: var(--rail-text);
  border: 1px solid var(--hair);
}
button:focus-visible { outline: 2px solid var(--tungsten); outline-offset: 2px; }

.progress {
  display: none;
  padding: 0.35rem 1rem 0.5rem;
  border-bottom: 1px solid var(--hair);
  background: #14161b;
}
.progress .bar {
  height: 4px;
  background: var(--hair);
  border-radius: 2px;
  overflow: hidden;
}
.progress .bar i {
  display: block;
  height: 100%;
  width: 0;
  background: var(--tungsten);
}
.progress.is-live .bar i {
  min-width: 2.5rem;
  background: linear-gradient(
    90deg,
    var(--tungsten) 0%,
    #f0c98a 45%,
    var(--tungsten) 90%
  );
  background-size: 220% 100%;
  animation: bar-sheen 1.8s linear infinite;
}
.progress-label {
  margin: 0.3rem 0 0;
  font-size: 0.75rem;
  color: var(--mute);
}

.desk {
  flex: 1;
  display: grid;
  grid-template-columns: minmax(16rem, 1fr) 7px minmax(16rem, var(--rail-w, 32%));
  min-height: 0;
}
.desk.is-resizing,
.desk.is-resizing * {
  cursor: col-resize !important;
  user-select: none !important;
}

.split {
  cursor: col-resize;
  background: var(--hair);
  position: relative;
  z-index: 2;
}
.split::after {
  content: "";
  position: absolute;
  inset: 0 -5px;
}
.split:hover,
.split:focus-visible,
.split.is-on {
  background: var(--tungsten);
}
.split:focus-visible { outline: none; }

.story {
  background: var(--paper);
  color: var(--ink);
  overflow: auto;
  position: relative;
}
.autoscroll {
  position: sticky;
  top: 0.7rem;
  float: right;
  z-index: 4;
  display: grid;
  place-items: center;
  width: 2rem;
  height: 2rem;
  margin: 0.7rem 0.75rem -2.7rem 0;
  padding: 0;
  border-radius: 3px;
  background: color-mix(in srgb, var(--paper) 82%, #000);
  border: 1px solid var(--rule);
  color: #5c5a54;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
}
.autoscroll:hover {
  color: var(--ink);
  border-color: color-mix(in srgb, var(--tungsten) 50%, var(--rule));
}
.autoscroll.is-off {
  color: #9a968c;
  opacity: 0.85;
}
.autoscroll.is-off::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 1.15rem;
  height: 1.5px;
  background: currentColor;
  transform: translate(-50%, -50%) rotate(-42deg);
  pointer-events: none;
}
.autoscroll[hidden] { display: none; }
.paste, .original {
  min-height: 100%;
  padding: 2rem 2.2rem 4rem 1.4rem;
}
.paste:empty:before {
  content: attr(data-placeholder);
  color: #9a968c;
  font-family: var(--serif);
  font-style: italic;
}
.paste:focus { outline: none; }
.paste {
  font-family: var(--serif);
  font-size: 1.15rem;
  line-height: 1.6;
}

.block {
  display: grid;
  grid-template-columns: 2.2rem 1fr;
  column-gap: 0.75rem;
  padding: 0.35rem 0.5rem 0.35rem 0.2rem;
  border-radius: 2px;
  cursor: pointer;
  scroll-margin: 4rem;
  position: relative;
}
.block .tick {
  position: absolute;
  left: 0;
  top: 0.4rem;
  bottom: 0.4rem;
  width: 3px;
  border-radius: 1px;
  background: transparent;
}
.block.mark-ok .tick { background: var(--holds); opacity: 0.65; }
.block.mark-shaky .tick { background: var(--shaky); }
.block.mark-hot .tick,
.block.mark-must .tick { background: var(--counter); }
.block.mark-must .tick {
  width: 4px;
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--counter) 40%, transparent);
}
.block.mark-shaky .num { color: var(--shaky); }
.block.mark-hot .num,
.block.mark-must .num { color: var(--counter); }
.block .num {
  font-family: var(--sans);
  font-size: 0.7rem;
  font-weight: 600;
  color: #9a968c;
  padding-top: 0.45rem;
  user-select: none;
}
.block .body {
  font-family: var(--serif);
  font-size: 1.12rem;
  line-height: 1.55;
}
.block .body p, .block .body h1, .block .body h2, .block .body h3,
.block .body blockquote, .block .body ul, .block .body ol {
  margin: 0.2rem 0;
}
.block .body h1, .block .body h2, .block .body h3 {
  font-size: 1.2rem;
  font-weight: 600;
}
.block .body blockquote {
  border-left: 2px solid var(--rule);
  padding-left: 0.8rem;
  color: #3a3935;
}
.block.is-on {
  background: color-mix(in srgb, var(--tungsten) 18%, var(--paper));
  box-shadow: inset 3px 0 0 var(--tungsten);
}
.block.is-on .num { color: var(--tungsten); }
.block.is-pending {
  background: color-mix(in srgb, var(--tungsten) 12%, var(--paper));
}
.block.is-pending .num { color: var(--tungsten); }
.block.is-pending .tick {
  background: var(--tungsten);
  animation: tick-pulse 1.4s ease-in-out infinite;
}

.rail {
  background: var(--rail);
  overflow: auto;
  min-width: 0;
}
.rail-empty {
  padding: 2rem 1.1rem;
  color: var(--mute);
  font-size: 0.92rem;
  line-height: 1.45;
}
.rail-empty p { margin: 0 0 1.1rem; }
.rail-empty .begin {
  display: block;
  width: 100%;
  padding: 0.7rem 0.9rem;
  font-size: 0.95rem;
}
#summary-col { padding: 0.55rem 0.7rem 0; }
.cards { padding: 1.6rem 0.7rem 1.6rem; display: grid; gap: 1.85rem; }
.job-meta {
  margin: 0 0.7rem 2.2rem;
  padding: 0.85rem 0.15rem 0;
  border-top: 1px solid var(--hair);
  font-size: 0.72rem;
  letter-spacing: 0.03em;
  color: var(--mute);
  font-variant-numeric: tabular-nums;
  line-height: 1.45;
}
.job-meta[hidden] { display: none; }

.card {
  position: relative;
  background: #252830;
  border: 1px solid var(--hair);
  border-radius: 3px;
  padding: 1.65rem 0.9rem 0.85rem;
  scroll-margin: 1.5rem;
  cursor: pointer;
  transition: background 0.12s ease, border-color 0.12s ease, box-shadow 0.12s ease, opacity 0.18s ease;
}
.card-ref {
  position: absolute;
  top: 0.4rem;
  left: 0.72rem;
  font-family: var(--sans);
  font-size: 0.68rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.04em;
  color: var(--mute);
  line-height: 1;
  padding: 0.16rem 0.34rem;
  border-radius: 2px;
}
.card.is-on {
  background: color-mix(in srgb, var(--tungsten) 28%, #252830);
  border-color: var(--tungsten);
  box-shadow: 0 0 0 2px var(--tungsten);
}
.card.is-on .card-ref {
  color: #1a1c22;
  background: var(--tungsten);
}
.card.mark-ok { box-shadow: inset 4px 0 0 var(--holds); }
.card.mark-shaky { box-shadow: inset 4px 0 0 var(--shaky); }
.card.mark-hot { box-shadow: inset 4px 0 0 var(--counter); }
.card.is-on.mark-ok {
  box-shadow: inset 4px 0 0 var(--holds), 0 0 0 2px var(--tungsten);
}
.card.is-on.mark-shaky {
  box-shadow: inset 4px 0 0 var(--shaky), 0 0 0 2px var(--tungsten);
}
.card.is-on.mark-hot {
  box-shadow: inset 4px 0 0 var(--counter), 0 0 0 2px var(--tungsten);
}
@keyframes card-flash {
  0% { background: color-mix(in srgb, var(--tungsten) 48%, #252830); }
  100% { background: color-mix(in srgb, var(--tungsten) 28%, #252830); }
}
.card.is-on.is-flash { animation: card-flash 0.65s ease; }
.cards:has(.card.is-on) .card:not(.is-on) {
  opacity: 0.38;
}
.cards:has(.card.is-on) .card:not(.is-on):hover,
.cards:has(.card.is-on) .card:not(.is-on):focus-visible {
  opacity: 0.78;
}
.card:not(.summary):not(.working):hover,
.card:not(.summary):not(.working):focus-visible {
  background: color-mix(in srgb, var(--tungsten) 14%, #252830);
  border-color: color-mix(in srgb, var(--tungsten) 42%, var(--hair));
}
.card.is-on:not(.summary):not(.working):hover {
  background: color-mix(in srgb, var(--tungsten) 32%, #252830);
  border-color: var(--tungsten);
}
.card.working {
  background: #1a1c22;
  border-style: dashed;
  border-color: color-mix(in srgb, var(--tungsten) 40%, var(--hair));
}
.card.working .headline {
  font-family: var(--sans);
  font-variant-numeric: tabular-nums;
  color: var(--tungsten);
  margin: 0 0 0.55rem;
}
.card.working .working-note {
  margin: 0;
  font-size: 0.82rem;
  line-height: 1.4;
  color: var(--mute);
}
.card.summary {
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--hair);
  border-radius: 0;
  cursor: default;
  padding: 0.35rem 0.15rem 1.35rem;
  box-shadow: none;
}
.summary .score-row {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  column-gap: 0.65rem;
  row-gap: 0.15rem;
  margin: 0.1rem 0 0.55rem;
}
.score-mark {
  display: inline-flex;
  align-items: baseline;
  gap: 0.2rem;
  flex: 0 0 auto;
  white-space: nowrap;
}
.score-grade {
  font-family: Caveat, "Segoe Script", "Comic Sans MS", cursive;
  font-weight: 700;
  font-size: 4.1rem;
  line-height: 0.8;
  display: inline-block;
  transform: rotate(-9deg);
  transform-origin: left bottom;
}
.summary .score-label {
  font-family: var(--sans);
  font-size: 1.4rem;
  font-weight: 600;
  line-height: 1.15;
  letter-spacing: -0.02em;
  color: var(--paper);
  min-width: 0;
}
.score-row.is-A, .score-row.is-Aminus, .score-row.is-Bplus, .score-row.is-B {
  color: var(--holds);
}
.score-row.is-Cplus, .score-row.is-C, .score-row.is-Dplus {
  color: var(--shaky);
}
.score-row.is-D, .score-row.is-F {
  color: var(--fails);
}
.score-row .score-grade {
  color: inherit;
}
.score-row .score-label {
  color: var(--paper);
}
.summary .score-num {
  flex: 1 0 100%;
  font-family: var(--sans);
  font-size: 0.76rem;
  font-weight: 500;
  letter-spacing: 0.04em;
  line-height: 1;
  color: var(--mute);
  margin: 0.35rem 0 0.1rem;
  white-space: nowrap;
}
.summary .headline {
  font-family: var(--sans);
  font-size: 0.92rem;
  font-weight: 400;
  line-height: 1.45;
  margin: 0;
  color: var(--mute);
}
.skim {
  font-size: 0.88rem;
  line-height: 1.45;
  margin: 0 0 0.65rem;
  padding: 0.5rem 0.55rem;
  background: #1a1c22;
  border-radius: 2px;
  color: var(--rail-text);
  max-height: 4.4em;
  overflow: hidden;
}
.card.is-open .skim { max-height: none; }
.skim .n {
  color: var(--tungsten);
  font-weight: 600;
  margin-right: 0.35rem;
  font-variant-numeric: tabular-nums;
}
.tease {
  margin: 0 0 0.65rem;
  font-size: 0.88rem;
  line-height: 1.45;
  color: var(--mute);
  max-height: 2.9em;
  overflow: hidden;
  mask-image: linear-gradient(to bottom, #000 40%, transparent);
}
.card.is-open .tease { display: none; }
.more { margin-top: 0; }
.more > summary {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 1.7rem;
  height: 1.7rem;
  margin: 0;
  padding: 0;
  border: none;
  border-radius: 2px;
  background: transparent;
  color: var(--mute);
  cursor: pointer;
  list-style: none;
}
.more > summary:hover,
.card:not(.summary):hover .more > summary,
.more[open] > summary {
  color: var(--tungsten);
}
.more > summary::-webkit-details-marker { display: none; }
.more > summary .chev {
  flex: none;
  width: 0.42rem;
  height: 0.42rem;
  border-right: 1.7px solid currentColor;
  border-bottom: 1.7px solid currentColor;
  transform: rotate(45deg);
  margin-top: -0.15rem;
}
.more[open] > summary .chev {
  transform: rotate(-135deg);
  margin-top: 0.2rem;
}
.card-range {
  font-size: 0.7rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--tungsten);
  margin: 0 0 0.5rem;
  line-height: 1.55;
}
.card h2 {
  font-family: var(--serif);
  font-size: 1.05rem;
  font-weight: 600;
  margin: 0 0 0.75rem;
  color: var(--paper);
  line-height: 1.4;
  padding-right: 1.9rem;
}
.claim {
  margin: 0 0 0.85rem;
  padding-bottom: 0.85rem;
  border-bottom: 1px solid var(--hair);
}
.claim p {
  margin: 0;
  font-size: 0.92rem;
  line-height: 1.55;
}
.claim-text {
  color: var(--paper);
}
.claim .label {
  font-size: 0.68rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--mute);
  margin: 0.85rem 0 0.5rem;
  line-height: 1.55;
}
.claim ul {
  margin: 0.45rem 0 0;
  padding-left: 1.2rem;
  font-size: 0.92rem;
  line-height: 1.55;
}
.claim li + li { margin-top: 0.35rem; }
.claim .counters { color: #f0c4bd; }
.claim .counters li::marker { color: var(--counter); }
.claim-more {
  margin-top: 0.55rem;
}
.claim-more > summary {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  cursor: pointer;
  list-style: none;
  color: var(--mute);
  font-size: 0.78rem;
  font-weight: 500;
  user-select: none;
}
.claim-more > summary::-webkit-details-marker { display: none; }
.claim-more > summary:hover { color: var(--tungsten); }
.claim-more > summary .chev {
  width: 0.36rem;
  height: 0.36rem;
  border-right: 1.6px solid currentColor;
  border-bottom: 1.6px solid currentColor;
  transform: rotate(45deg);
  margin-top: -0.28rem;
}
.claim-more[open] > summary .chev {
  transform: rotate(-135deg);
  margin-top: 0.12rem;
}
.claim-more[open] > summary { margin-bottom: 0.35rem; }

.suggest {
  background: #1a1c22;
  padding: 0.85rem 0.9rem;
  border-radius: 2px;
  margin-top: 0.75rem;
}
.suggest .label {
  font-size: 0.68rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--tungsten);
  margin: 0 0 0.5rem;
  line-height: 1.55;
}
.suggest p {
  font-family: var(--serif);
  font-size: 0.95rem;
  line-height: 1.55;
  margin: 0 0 0.75rem;
  white-space: pre-wrap;
}
.edits {
  font-size: 0.86rem;
  color: var(--mute);
  margin: 0 0 0.85rem;
  line-height: 1.55;
}
.edits strong { color: var(--rail-text); }

.check {
  display: none;
  margin-top: 0.5rem;
  background: transparent;
  color: var(--tungsten);
  border: 1px solid color-mix(in srgb, var(--tungsten) 50%, transparent);
  font-weight: 500;
  padding: 0.3rem 0.55rem;
}
.check-out { margin-top: 0.5rem; font-size: 0.84rem; line-height: 1.4; }
.check-out .verdict {
  display: inline-block;
  font-size: 0.68rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-bottom: 0.3rem;
}
.check-out .verdict.holds { color: var(--holds); }
.check-out .verdict.shaky { color: var(--shaky); }
.check-out .verdict.fails { color: var(--fails); }
.check-out a { color: var(--tungsten); }

.retry {
  background: transparent;
  color: var(--tungsten);
  border: 1px dashed var(--tungsten);
}

.reason {
  margin: 0.5rem 0 0.8rem;
  font-size: 0.8rem;
  color: var(--mute);
}
.reason summary {
  cursor: pointer;
  color: var(--tungsten);
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.reason p {
  white-space: pre-wrap;
  margin: 0.4rem 0 0;
  line-height: 1.4;
  color: #cfcbc3;
}

.sheet-grab,
.sheet-dim { display: none; }

@media (max-width: 1099px) {
  .desk {
    display: block;
    position: relative;
    overflow: hidden;
  }
  .split { display: none; }
  .story {
    height: 100%;
    overflow: auto;
    padding-bottom: 5.5rem;
  }
  .rail {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 30;
    height: var(--sheet-h, 22vh);
    max-height: 96dvh;
    border-radius: 14px 14px 0 0;
    border-left: 0;
    box-shadow: 0 -12px 40px rgba(0, 0, 0, 0.45);
    padding-bottom: env(safe-area-inset-bottom, 0);
    transition: height 0.34s cubic-bezier(0.32, 0.72, 0, 1);
  }
  .desk.is-sheet-drag .rail { transition: none; }
  .card { scroll-margin: 2.4rem; }
  .sheet-grab {
    display: flex;
    justify-content: center;
    align-items: center;
    flex-shrink: 0;
    position: sticky;
    top: 0;
    z-index: 2;
    height: 1.35rem;
    background: var(--rail);
    cursor: grab;
    touch-action: none;
  }
  .sheet-grab::after {
    content: "";
    width: 36px;
    height: 5px;
    border-radius: 99px;
    background: rgba(255, 255, 255, 0.28);
  }
  .sheet-dim {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 25;
    background: rgba(0, 0, 0, 0.38);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.28s ease;
  }
  .sheet-dim.is-on {
    opacity: 1;
    pointer-events: auto;
  }
}

@keyframes bar-sheen {
  0% { background-position: 100% 0; }
  100% { background-position: -120% 0; }
}
@keyframes tick-pulse {
  0%, 100% { opacity: 0.35; }
  50% { opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
