:root {
  --paper: #fff;
  --ink: #202122;
  --dim: #54595d;
  --link: #0645ad;
  --link-visited: #0b0080;
  --border: #a2a9b1;
  --border-light: #eaecf0;
  --panel: #f8f9fa;
  --accent: #ab1f24;
  --accent2: #14866d;
  --score-low: #767676;
  --score-mid: #b8710a;
  --score-high: #ab1f24;
  --cork: #7a5a3a;
  --cork-dark: #5e4429;
  --paper-a: #fdf6e3;
  --paper-b: #f3ead2;
  --paper-c: #eee2c8;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: #f6f6f6;
  color: var(--ink);
  font-family: Georgia, "Linux Libertine", "Nimbus Roman No9 L", "Liberation Serif", serif;
}

a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }
a:visited { color: var(--link-visited); }

.chrome {
  background: var(--panel);
  border-bottom: 1px solid var(--border);
}
.chrome-inner {
  max-width: 960px;
  margin: 0 auto;
  padding: 0.55rem 1.25rem;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
}
.wordmark {
  font-weight: 700;
  font-size: 1rem;
  letter-spacing: 0.01em;
}
.chrome-tag {
  font-size: 0.75rem;
  color: var(--dim);
}

.page {
  max-width: 960px;
  margin: 0 auto;
  background: var(--paper);
  padding: 1.5rem 1.75rem 3rem;
  min-height: 70vh;
}

.titlebar h1 {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  font-weight: 400;
  font-size: 1.6rem;
  margin: 0 0 0.15rem;
  border-bottom: 1px solid var(--border);
  padding-bottom: 0.35rem;
  line-height: 1.3;
}
.subtag {
  font-size: 0.85rem;
  color: var(--dim);
  font-style: italic;
  margin-bottom: 1rem;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 1rem;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
}
.btn {
  font: inherit;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  font-size: 0.85rem;
  padding: 0.45rem 0.8rem;
  border-radius: 4px;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--ink);
  cursor: pointer;
}
.btn:hover:not(:disabled) { background: #eaecf0; }
.btn:disabled { opacity: 0.5; cursor: default; }
.btn.primary {
  background: var(--link);
  border-color: var(--link);
  color: #fff;
  font-weight: 600;
}
.btn.primary:hover:not(:disabled) { background: #053a82; }
.btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.toast {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  font-size: 0.8rem;
  color: var(--accent2);
  font-weight: 600;
}

.status {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  font-size: 0.9rem;
  color: var(--dim);
  padding: 1.5rem 0;
}
.status.error { color: var(--accent); }

.layout {
  display: flex;
  gap: 2rem;
  align-items: flex-start;
}

/* the "ransom note": a corkboard the clipped words get glued onto */
.article.ransom {
  flex: 1;
  min-width: 0;
  background: var(--cork);
  background-image:
    radial-gradient(rgba(0, 0, 0, 0.12) 1px, transparent 1.4px),
    radial-gradient(rgba(255, 255, 255, 0.05) 1px, transparent 1.4px);
  background-size: 9px 9px, 13px 13px;
  background-position: 0 0, 4px 6px;
  border: 10px solid var(--cork-dark);
  border-radius: 4px;
  box-shadow: inset 0 0 30px rgba(0, 0, 0, 0.35);
  padding: 1.25rem 1.5rem;
  font-size: 1.05rem;
  line-height: 2.3;
}
.article.ransom p {
  margin: 0 0 0.6rem;
}

.w {
  display: inline-block;
  padding: 0.12rem 0.42rem;
  margin: 0.1rem 0.1rem;
  background: var(--paper-a);
  border: 1px solid rgba(0, 0, 0, 0.2);
  border-radius: 2px;
  box-shadow: 1px 2px 3px rgba(0, 0, 0, 0.35);
  transform: rotate(var(--rot, 0deg));
  color: #1a1a1a;
  font-weight: 700;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.w:hover { transform: rotate(0deg) scale(1.06); box-shadow: 1px 3px 6px rgba(0, 0, 0, 0.45); }
.w.paper-1 { background: var(--paper-b); }
.w.paper-2 { background: var(--paper-c); }

body.stitches-on .w.score-low { outline: 2px solid var(--score-low); }
body.stitches-on .w.score-mid { outline: 2px solid var(--score-mid); }
body.stitches-on .w.score-high { outline: 2px solid var(--score-high); }

.stitch-mark {
  display: none;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  font-size: 0.65rem;
  font-weight: 700;
  margin-left: 0.05rem;
  cursor: default;
  vertical-align: super;
}
body.stitches-on .stitch-mark { display: inline; }
.stitch-mark a { color: #fff2d6; }
.stitch-mark.score-low a { color: #d8d0c0; }
.stitch-mark.score-mid a { color: #ffcf7a; }
.stitch-mark.score-high a { color: #ff9d9d; }

.infobox {
  width: 260px;
  flex-shrink: 0;
  border: 1px solid var(--border);
  background: var(--panel);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  font-size: 0.8rem;
}
.infobox-title {
  background: #eaecf0;
  font-weight: 700;
  font-size: 0.9rem;
  text-align: center;
  padding: 0.5rem;
  border-bottom: 1px solid var(--border);
}
.infobox table { width: 100%; border-collapse: collapse; }
.infobox td {
  padding: 0.4rem 0.6rem;
  border-top: 1px solid var(--border-light);
  vertical-align: top;
}
.infobox td.k { color: var(--dim); width: 44%; }
.infobox td.v { font-weight: 600; text-align: right; }
.infobox-caption {
  padding: 0.5rem 0.6rem 0.6rem;
  color: var(--dim);
  font-style: italic;
  font-size: 0.72rem;
  border-top: 1px solid var(--border-light);
}
.type-pill {
  display: inline-block;
  padding: 0.05rem 0.4rem;
  border-radius: 3px;
  background: #eaecf0;
  border: 1px solid var(--border);
  font-size: 0.7rem;
  font-weight: 600;
}

.stitch-notes {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  font-size: 0.82rem;
  border-top: 1px solid var(--border);
  margin-top: 1.5rem;
  padding: 1rem 0 0 1.4rem;
  color: var(--ink);
  column-width: 320px;
  column-gap: 2rem;
}
.stitch-notes li { margin-bottom: 0.65rem; line-height: 1.5; break-inside: avoid; }
.stitch-notes .breakdown { color: var(--dim); }
.stitch-notes .score-tag {
  font-weight: 700;
  padding: 0.02rem 0.35rem;
  border-radius: 3px;
  color: #fff;
}
.stitch-notes .score-tag.score-low { background: var(--score-low); }
.stitch-notes .score-tag.score-mid { background: var(--score-mid); }
.stitch-notes .score-tag.score-high { background: var(--score-high); }

.foot {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  font-size: 0.78rem;
  color: var(--dim);
  border-top: 1px solid var(--border);
  margin-top: 2rem;
  padding-top: 1rem;
  line-height: 1.6;
}

@media (max-width: 680px) {
  .layout { flex-direction: column; }
  .infobox { width: 100%; }
}
