:root {
  /* linen, thread red, and ink */
  --bg: #f6f1e9; --panel: #fffdf9; --panel2: #f2ebe0; --line: #e4dacb; --text: #221c16;
  --muted: #7a6c5b; --accent: #c2412d; --accent2: #a33420; --ok: #2f7d4f; --warn: #b7791f;
  --bad: #c0392b; --chip: #f7e4dc; --chipt: #9a3220; --stitch: #d9ccb8;
  --shadow: 0 1px 2px rgba(60,40,20,.06), 0 2px 6px rgba(60,40,20,.05);
  --radius: 14px; --mono: ui-monospace, SFMono-Regular, Menlo, monospace;
  --serif: "Fraunces", Georgia, "Times New Roman", serif;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #15120e; --panel: #1e1a15; --panel2: #28221b; --line: #3a3128; --text: #efe7da; --muted: #a89984;
    --accent: #e0674f; --accent2: #eb8671; --chip: #3b2119; --chipt: #f2b3a3; --stitch: #4a3f33;
    --ok: #5cb383; --warn: #e0a54a; --shadow: 0 1px 2px rgba(0,0,0,.45); }
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.5 Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; }
body { background-image: radial-gradient(color-mix(in srgb, var(--line) 55%, transparent) 1px, transparent 1px); background-size: 22px 22px; }
a { color: var(--accent); text-decoration: none; } a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; color: inherit; }
h1 { font-family: var(--serif); font-size: 30px; font-weight: 700; margin: 0 0 4px; letter-spacing: -.015em; }
h2 { font-family: var(--serif); font-size: 19px; font-weight: 600; margin: 0 0 10px; letter-spacing: -.005em; }
h3 { font-size: 14px; margin: 0 0 6px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.muted { color: var(--muted); } .small { font-size: 13px; } .tiny { font-size: 12px; }
.mono { font-family: var(--mono); font-size: 12.5px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.stack { display: flex; flex-direction: column; gap: 10px; }
.right { margin-left: auto; }

/* shell */
.shell { display: grid; grid-template-columns: 220px 1fr; min-height: 100vh; }
.side { background: var(--panel); border-right: 1.5px dashed var(--stitch); padding: 18px 14px; position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 4px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 18px; padding: 4px 8px 16px; }
.brand .logo { width: 30px; height: 30px; flex: none; }
.brand .word { font-family: var(--serif); font-size: 22px; font-weight: 700; letter-spacing: -.02em; }
.brand .word em { font-style: italic; color: var(--accent); font-weight: 600; }
.tagline { font-family: var(--serif); font-size: 20px; font-style: italic; margin: 0; color: var(--text); }
.nav a { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 8px; color: var(--text); font-weight: 500; }
.nav a:hover { background: var(--panel2); text-decoration: none; }
.nav a.active { background: var(--chip); color: var(--chipt); box-shadow: inset 3px 0 0 var(--accent); }
.nav .ic { width: 18px; text-align: center; opacity: .8; }
.side .foot { margin-top: auto; padding: 8px; font-size: 13px; color: var(--muted); }
.main { padding: 28px 32px 60px; max-width: 1240px; width: 100%; }
@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: static; height: auto; flex-direction: row; align-items: center; gap: 8px; padding: 10px 12px; border-right: 0; border-bottom: 1px solid var(--line); overflow-x: auto; }
  .brand { padding: 0 8px 0 0; } .nav { display: flex; gap: 4px; } .side .foot { display: none; }
  .main { padding: 18px 16px 60px; }
}

/* cards */
.card { position: relative; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; box-shadow: var(--shadow); }
.card::before { content: ""; position: absolute; inset: 5px; border: 1.5px dashed var(--stitch); border-radius: calc(var(--radius) - 5px); pointer-events: none; }
.card > * { position: relative; }
.cards { display: grid; gap: 16px; }
.cards.two { grid-template-columns: 1fr 1fr; } .cards.three { grid-template-columns: repeat(3, 1fr); }
.cards.four { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 1000px) { .cards.four { grid-template-columns: 1fr 1fr; } .cards.three { grid-template-columns: 1fr; } }
@media (max-width: 760px) { .cards.two, .cards.four { grid-template-columns: 1fr; } }
.stat { display: flex; flex-direction: column; gap: 2px; }
.stat .v { font-family: var(--serif); font-size: 32px; font-weight: 700; letter-spacing: -.02em; }
.stat .l { color: var(--muted); font-size: 13px; }

/* forms */
label.f { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); font-weight: 500; }
input[type=text], input[type=email], input[type=password], input[type=url], select, textarea {
  width: 100%; padding: 9px 11px; border: 1px solid var(--line); border-radius: 9px; background: var(--panel); color: var(--text); outline: none; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent); }
textarea { resize: vertical; min-height: 64px; line-height: 1.45; }
textarea.auto { overflow: hidden; resize: none; }
.check { display: inline-flex; align-items: center; gap: 8px; padding: 8px 12px; border: 1px solid var(--line); border-radius: 9px; cursor: pointer; user-select: none; background: var(--panel); }
.check input { accent-color: var(--accent); }
.check.on { border-color: var(--accent); background: var(--chip); color: var(--chipt); }
.btn { display: inline-flex; align-items: center; gap: 8px; padding: 9px 14px; border-radius: 9px; border: 1px solid var(--line); background: var(--panel); cursor: pointer; font-weight: 500; white-space: nowrap; }
.btn:hover { background: var(--panel2); } .btn:disabled { opacity: .5; cursor: default; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; outline: 1.5px dashed rgba(255,255,255,.55); outline-offset: -5px; }
.btn.primary:hover { background: var(--accent2); }
.btn.danger { color: var(--bad); } .btn.sm { padding: 5px 10px; font-size: 13px; } .btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--panel2); }

/* chips, pills, progress */
.chip { display: inline-block; padding: 2px 9px; border-radius: 999px; background: var(--chip); color: var(--chipt); font-size: 12.5px; margin: 2px 4px 2px 0; }
.chip.miss { background: color-mix(in srgb, var(--warn) 15%, transparent); color: var(--warn); }
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px; font-size: 12.5px; font-weight: 600; background: var(--panel2); }
.pill.done { color: var(--ok); background: color-mix(in srgb, var(--ok) 14%, transparent); }
.pill.running, .pill.queued { color: var(--accent); background: var(--chip); }
.pill.failed { color: var(--bad); background: color-mix(in srgb, var(--bad) 12%, transparent); }
.pill .dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.pill.running .dot { animation: pulse 1.2s infinite; }
@keyframes pulse { 0%, 100% { opacity: .35; } 50% { opacity: 1; } }
.bar { height: 8px; background: var(--panel2); border-radius: 999px; overflow: hidden; }
.bar > i { display: block; height: 100%; border-radius: 999px; transition: width .6s ease;
  background: repeating-linear-gradient(90deg, var(--accent) 0 10px, var(--accent2) 10px 14px); }
.bar.indet > i { width: 30% !important; animation: slide 1.4s infinite linear; }
@keyframes slide { from { transform: translateX(-100%); } to { transform: translateX(400%); } }
.score { font-family: var(--serif); font-size: 34px; font-weight: 700; letter-spacing: -.02em; }
.score.g { color: var(--ok); } .score.y { color: var(--warn); } .score.r { color: var(--bad); }

/* tables/lists */
.list { display: flex; flex-direction: column; }
.list .item { display: grid; grid-template-columns: 1fr auto; gap: 10px; padding: 12px 4px; border-top: 1px solid var(--line); align-items: center; }
.list .item:first-child { border-top: 0; }
.list .item:hover { background: var(--panel2); border-radius: 8px; }
.item .t { font-weight: 600; } .item .s { color: var(--muted); font-size: 13px; }

/* log */
.log { background: var(--panel2); border-radius: 10px; padding: 10px 12px; max-height: 260px; overflow: auto; font-family: var(--mono); font-size: 12.5px; line-height: 1.5; }
.log .step { color: var(--accent); font-weight: 600; margin-top: 4px; } .log .warn { color: var(--warn); } .log .error { color: var(--bad); font-weight: 600; }
.log .t { color: var(--muted); margin-right: 8px; }

/* tabs */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 16px; }
.tabs button { background: none; border: 0; padding: 10px 14px; cursor: pointer; color: var(--muted); font-weight: 600; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs button.active { color: var(--text); border-bottom-color: var(--accent); }

/* editor */
.editor { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 18px; }
@media (max-width: 1100px) { .editor { grid-template-columns: 1fr; } }
.preview { position: sticky; top: 16px; height: calc(100vh - 32px); min-height: 520px; }
.preview iframe { width: 100%; height: 100%; border: 1px solid var(--line); border-radius: 10px; background: #fff; }
@media (max-width: 1100px) { .preview { position: static; height: 720px; } }
.sec { border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; margin-bottom: 12px; background: var(--panel); }
.sec .head { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 8px; }
.bullet { display: grid; grid-template-columns: 22px 1fr auto; gap: 8px; align-items: start; padding: 6px 0; }
.bullet .n { color: var(--muted); padding-top: 9px; font-size: 13px; text-align: right; }
.bullet .fit { font-size: 11px; color: var(--muted); margin-top: 3px; }
.bullet .fit.good { color: var(--ok); } .bullet .fit.short { color: var(--warn); }
.bullet .tools { display: flex; flex-direction: column; gap: 2px; }
.bullet .tools button { padding: 3px 7px; }
.dirty { position: sticky; bottom: 12px; z-index: 5; display: flex; gap: 10px; align-items: center; padding: 10px 14px; background: var(--panel); border: 1px solid var(--accent); border-radius: 10px; box-shadow: var(--shadow); }
.para { margin-bottom: 10px; }
.para textarea { min-height: 90px; }

/* misc */
.empty { padding: 30px; text-align: center; color: var(--muted); }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 4px 14px; font-size: 13.5px; }
.kv b { color: var(--muted); font-weight: 500; }
.hr { height: 1px; background: var(--line); margin: 14px 0; }
.auth { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.auth .card { width: 100%; max-width: 440px; padding: 28px 30px; }
.checklist .item { grid-template-columns: 26px 1fr auto; }
.checklist .ok { color: var(--ok); } .checklist .todo { color: var(--muted); }
#toasts { position: fixed; right: 16px; bottom: 16px; display: flex; flex-direction: column; gap: 8px; z-index: 100; }
.toast { padding: 10px 14px; border-radius: 10px; background: var(--text); color: var(--bg); box-shadow: var(--shadow); max-width: 380px; font-size: 14px; animation: fade .2s ease; }
.toast.bad { background: var(--bad); color: #fff; } .toast.ok { background: var(--ok); color: #fff; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } }
details summary { cursor: pointer; color: var(--muted); font-weight: 500; }
.tag { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; background: var(--panel2); border-radius: 999px; font-size: 12px; margin: 2px 3px 2px 0; }
.tag button { border: 0; background: none; cursor: pointer; color: var(--muted); padding: 0 2px; }
.spin { width: 14px; height: 14px; border: 2px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: rot .8s linear infinite; display: inline-block; }
@keyframes rot { to { transform: rotate(360deg); } }
.note { padding: 10px 14px; border-radius: 10px; background: var(--panel2); font-size: 13.5px; }
.note.warn { background: color-mix(in srgb, var(--warn) 12%, transparent); }
.note.bad { background: color-mix(in srgb, var(--bad) 12%, transparent); }
