/* ==========================================================================
   Bevel tools — tools-assets.bevelthemes.com
   Hand-written, no framework, no build. The studio's type and colours, a
   slim header of its own. Tokens, base, shell (header / footer / index),
   then one block per tool.
   ========================================================================== */

@font-face { font-family: 'Geist'; src: url('../fonts/geist.woff2') format('woff2'); font-weight: 100 900; font-display: swap; unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: 'Geist'; src: url('../fonts/geist-ext.woff2') format('woff2'); font-weight: 100 900; font-display: swap; unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+1E00-1E9F, U+20A0-20AB, U+20AD-20C0, U+2113, U+A720-A7FF; }
@font-face { font-family: 'Geist Mono'; src: url('../fonts/geist-mono.woff2') format('woff2'); font-weight: 100 900; font-display: swap; }
@font-face { font-family: 'Instrument Serif'; src: url('../fonts/instrument-serif-italic.woff2') format('woff2'); font-weight: 400; font-style: italic; font-display: swap; }

/* ── Tokens ─────────────────────────────────────────────────────────────── */

:root {
  --font: 'Geist', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-serif: 'Instrument Serif', 'Iowan Old Style', Georgia, serif;
  --font-mono: 'Geist Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
  --wrap: 1320px;
  --gutter: clamp(16px, 4vw, 48px);
  --cut: 12px;
  --ease: cubic-bezier(.2, .7, .1, 1);

  --bg: #f6f5f1;
  --surface: #ffffff;
  --surface-2: #f2f1ec;
  --text: #121218;
  --muted: #5b5b6b;
  --line: rgb(18 18 24 / .09);
  --line-2: rgb(18 18 24 / .18);
  --accent: #5a3df0;
  --accent-ink: #ffffff;
  --danger: #b4232f;
  --ok: #1d7a46;
  /* the drawing over a photograph: paper and ink, fixed in both themes */
  --paper: #f6f4ef;
  --ink: #121218;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) {
    --bg: #0b0b10;
    --surface: #13131b;
    --surface-2: #1a1a24;
    --text: #ededf4;
    --muted: #9a9aae;
    --line: rgb(255 255 255 / .07);
    --line-2: rgb(255 255 255 / .15);
    --accent: #8f7dff;
    --accent-ink: #0b0b10;
    --danger: #ff8a93;
    --ok: #6fd69c;
    color-scheme: dark;
  }
}
:root[data-theme='dark'] {
  --bg: #0b0b10;
  --surface: #13131b;
  --surface-2: #1a1a24;
  --text: #ededf4;
  --muted: #9a9aae;
  --line: rgb(255 255 255 / .07);
  --line-2: rgb(255 255 255 / .15);
  --accent: #8f7dff;
  --accent-ink: #0b0b10;
  --danger: #ff8a93;
  --ok: #6fd69c;
  color-scheme: dark;
}

/* ── Base ───────────────────────────────────────────────────────────────── */

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--text);
  font: 400 16px/1.55 var(--font);
  -webkit-font-smoothing: antialiased;
  overflow-x: clip;
}
main { flex: 1; }
img, svg { display: block; max-width: 100%; }
a { color: inherit; }
p, h1, h2, h3, ul, ol, dl, dd, figure { margin: 0; padding: 0; }
ul, ol { list-style: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
code, kbd { font-family: var(--font-mono); font-size: .88em; }
code { padding: .1em .35em; background: var(--surface-2); border-radius: 3px; }
::selection { background: var(--accent); color: var(--accent-ink); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
[hidden] { display: none !important; }

.bt-wrap { width: min(100% - 2 * var(--gutter), var(--wrap)); margin-inline: auto; }
.bt-visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.bt-skip { position: fixed; left: 12px; top: -60px; z-index: 100; padding: 10px 14px; background: var(--text); color: var(--bg); }
.bt-skip:focus { top: 12px; }
.bt-serif { font-family: var(--font-serif); font-style: italic; font-weight: 400; }
.bt-eyebrow { font: 500 12px/1.4 var(--font-mono); letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }

/* ── Buttons & fields ───────────────────────────────────────────────────── */

.bt-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 40px; padding: 0 16px;
  border: 1px solid var(--line-2); border-radius: 0;
  background: var(--surface); color: var(--text);
  font-weight: 500; font-size: 14px; text-decoration: none;
  clip-path: polygon(0 0, calc(100% - 8px) 0, 100% 8px, 100% 100%, 0 100%);
  transition: background .15s, border-color .15s;
}
.bt-btn:hover { border-color: var(--text); }
.bt-btn--primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.bt-btn--primary:hover { border-color: var(--accent); filter: brightness(1.08); }
.bt-btn--small { min-height: 32px; padding: 0 10px; font-size: 13px; }
.bt-btn--danger { color: var(--danger); }
.bt-btn:disabled { opacity: .45; cursor: not-allowed; }
.bt-btn[aria-pressed='true'] { background: var(--text); color: var(--bg); border-color: var(--text); }

.bt-field { display: grid; gap: 4px; }
.bt-field > span, .bt-legend { font-size: 13px; color: var(--muted); }
.bt-input {
  width: 100%; min-height: 36px; padding: 6px 10px;
  border: 1px solid var(--line-2); border-radius: 0;
  background: var(--surface); color: var(--text); font-size: 14px;
}
.bt-input:focus-visible { outline-offset: 0; border-color: var(--accent); }
.bt-input--mono { font-family: var(--font-mono); font-size: 13px; }
textarea.bt-input { resize: vertical; line-height: 1.5; }
.bt-hint { font-size: 13px; color: var(--muted); }

/* ── Header / footer ────────────────────────────────────────────────────── */

.bt-header { border-bottom: 1px solid var(--line); background: var(--bg); }
.bt-header__bar { display: flex; align-items: center; gap: 24px; min-height: 60px; }
.bt-brand { display: inline-flex; align-items: center; gap: 10px; text-decoration: none; font-weight: 600; letter-spacing: -.01em; }
.bt-mark { width: 22px; height: 22px; }
.bt-mark__body { fill: var(--accent); }
.bt-mark__face { fill: #fff; fill-opacity: .45; }
.bt-brand__sub { color: var(--muted); font-weight: 400; }
.bt-nav { display: flex; gap: 20px; margin-inline-start: auto; font-size: 14px; }
.bt-nav a { text-decoration: none; color: var(--muted); }
.bt-nav a:hover, .bt-nav a[aria-current='page'] { color: var(--text); }
.bt-theme-btn { display: inline-grid; place-items: center; width: 36px; height: 36px; border: 1px solid var(--line-2); background: none; color: var(--text); }
.bt-theme-btn svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.6; }
.bt-icon--moon { display: none; }
:root[data-theme='dark'] .bt-icon--sun { display: none; }
:root[data-theme='dark'] .bt-icon--moon { display: block; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) .bt-icon--sun { display: none; }
  :root:not([data-theme='light']) .bt-icon--moon { display: block; }
}

.bt-footer { border-top: 1px solid var(--line); margin-top: 64px; padding: 24px 0; font-size: 13px; color: var(--muted); }
.bt-footer__bar { display: flex; flex-wrap: wrap; gap: 8px 24px; justify-content: space-between; }

/* ── Index ──────────────────────────────────────────────────────────────── */

.bt-hero { padding: 64px 0 40px; display: grid; gap: 12px; max-width: 720px; }
.bt-hero h1 { font-size: clamp(34px, 5vw, 52px); line-height: 1.05; font-weight: 500; letter-spacing: -.025em; }
.bt-hero p { color: var(--muted); font-size: 18px; }
.bt-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 320px), 1fr)); gap: 16px; }
.bt-card {
  position: relative; display: grid; gap: 10px; align-content: start;
  padding: 24px; min-height: 220px;
  background: var(--surface); border: 1px solid var(--line);
  clip-path: polygon(0 0, calc(100% - var(--cut)) 0, 100% var(--cut), 100% 100%, 0 100%);
  text-decoration: none;
  transition: border-color .15s;
}
a.bt-card:hover { border-color: var(--line-2); }
a.bt-card:hover .bt-card__paper { fill: var(--paper); stroke: none; }
.bt-card__ink { fill: var(--ink); stroke: none; }
.bt-card__go { color: var(--accent); }
.bt-card h2 { font-size: 20px; font-weight: 500; letter-spacing: -.01em; }
.bt-card p { color: var(--muted); font-size: 15px; }
.bt-card__art { height: 64px; margin-bottom: 6px; color: var(--text); }
.bt-card__go { margin-top: auto; font-size: 14px; font-weight: 500; }
.bt-card--soon { background: transparent; border-style: dashed; }
.bt-card--soon h2 { color: var(--muted); }

/* ── Tool page shell ────────────────────────────────────────────────────── */

.bt-toolhead { padding: 36px 0 24px; display: grid; gap: 8px; }
.bt-toolhead h1 { font-size: clamp(28px, 3.4vw, 40px); line-height: 1.1; font-weight: 500; letter-spacing: -.02em; }
.bt-toolhead p { color: var(--muted); max-width: 760px; }
.bt-small-screen { display: none; padding: 24px; border: 1px solid var(--line-2); background: var(--surface); }
@media (max-width: 899px) {
  .bt-small-screen { display: block; }
  .bt-needs-large { display: none !important; }
}

/* ── Dimension lines tool ───────────────────────────────────────────────── */

.dl { display: grid; grid-template-columns: minmax(0, 1fr) 400px; gap: 24px; align-items: start; }
.dl-panel { display: grid; gap: 16px; position: sticky; top: 16px; }
.dl-box { background: var(--surface); border: 1px solid var(--line); padding: 16px; display: grid; gap: 12px; }
.dl-box h2 { font-size: 15px; font-weight: 600; display: flex; align-items: center; justify-content: space-between; gap: 8px; }

/* photos strip */
.dl-photos { display: flex; flex-wrap: wrap; gap: 8px; align-items: stretch; }
.dl-thumb { position: relative; display: grid; gap: 4px; width: 92px; }
.dl-thumb__pick {
  position: relative; display: block; width: 92px; height: 92px; padding: 0;
  border: 1px solid var(--line-2); background: var(--surface-2); overflow: hidden;
}
.dl-thumb__pick img { width: 100%; height: 100%; object-fit: cover; }
.dl-thumb__pick[aria-pressed='true'] { outline: 2px solid var(--accent); outline-offset: 1px; }
.dl-thumb__num {
  position: absolute; left: 4px; top: 4px; padding: 0 5px;
  background: var(--paper); color: var(--ink); font: 500 11px/18px var(--font-mono);
}
.dl-thumb__empty { display: grid; place-items: center; height: 100%; font-size: 11px; color: var(--muted); padding: 6px; text-align: center; }
.dl-thumb__tools { display: flex; gap: 2px; }
.dl-thumb__tools button {
  flex: 1; min-height: 26px; padding: 0; border: 1px solid var(--line); background: var(--surface); font-size: 12px;
}
.dl-thumb__tools button:disabled { opacity: .35; cursor: not-allowed; }
.dl-add-photo {
  display: grid; place-items: center; width: 92px; height: 92px;
  border: 1px dashed var(--line-2); background: transparent; font-size: 12px; color: var(--muted); text-align: center; padding: 6px;
}
.dl-add-photo:hover { color: var(--text); border-color: var(--text); }

/* stage */
.dl-stagebar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; margin-bottom: 10px; font-size: 14px; }
.dl-stagebar__dir { display: inline-flex; gap: 0; }
.dl-stagebar__dir .bt-btn { clip-path: none; }
.dl-stagebar__dir .bt-btn + .bt-btn { margin-inline-start: -1px; }
.dl-stage {
  position: relative; display: grid; place-items: center;
  min-height: 420px; padding: 16px;
  background: var(--surface-2); border: 1px solid var(--line);
}
.dl-stage.is-drop { outline: 2px dashed var(--accent); outline-offset: -8px; }
.dl-frame { position: relative; max-width: 100%; user-select: none; -webkit-user-select: none; touch-action: none; }
.dl-frame img { max-height: 76vh; width: auto; max-width: 100%; pointer-events: none; }
.dl-frame__ph {
  display: grid; place-items: center; width: min(560px, 100%); aspect-ratio: 4 / 5;
  background: repeating-linear-gradient(135deg, var(--surface), var(--surface) 10px, var(--surface-2) 10px, var(--surface-2) 20px);
  color: var(--muted); text-align: center; padding: 24px; font-size: 14px;
}
.dl-empty { display: grid; gap: 12px; justify-items: center; text-align: center; padding: 48px 24px; color: var(--muted); }
.dl-empty strong { color: var(--text); font-size: 18px; font-weight: 500; }
.dl-overlay { position: absolute; inset: 0; cursor: crosshair; }
.dl-overlay svg { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }

/* the drawing: a paper halo under a fine ink line, "/" end slashes,
   extension lines toward the object, a small paper label in mono */
.dl-halo { stroke: var(--paper); stroke-opacity: .85; stroke-width: 5; stroke-linecap: round; fill: none; }
.dl-ink { stroke: var(--ink); stroke-width: 1.25; stroke-linecap: round; fill: none; }
.dl-seg.is-selected .dl-ink { stroke-width: 2.25; }
.dl-hit { stroke: transparent; stroke-width: 16; fill: none; cursor: pointer; pointer-events: stroke; }
.dl-label {
  position: absolute; z-index: 2; transform: translate(-50%, -50%);
  padding: 3px 7px; background: var(--paper); color: var(--ink);
  font: 400 12px/1.35 var(--font-mono); white-space: nowrap; cursor: move;
}
.dl-label.is-selected { box-shadow: 0 0 0 1.5px var(--accent); }
.dl-label__key { color: #6b6a66; margin-inline-end: 6px; }
.dl-handle { fill: var(--paper); stroke: var(--accent); stroke-width: 2; cursor: grab; }
.dl-handle--ext { fill: var(--accent); }
.dl-handle:hover { fill: var(--accent); }

/* segment list */
.dl-list { display: grid; gap: 4px; }
.dl-row { display: flex; gap: 4px; }
.dl-row__pick {
  flex: 1; display: flex; align-items: center; gap: 10px; min-height: 40px; padding: 6px 10px; text-align: start;
  border: 1px solid var(--line); background: var(--surface); font-size: 14px;
}
.dl-row__pick[aria-pressed='true'] { border-color: var(--accent); box-shadow: inset 3px 0 0 var(--accent); }
.dl-row__tag { flex: none; max-width: 45%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font: 500 11px/18px var(--font-mono); padding: 0 6px; background: var(--paper); color: var(--ink); border: 1px solid var(--line); }
.dl-row__meta { flex: none; margin-inline-start: auto; color: var(--muted); font: 400 12px var(--font-mono); }
.dl-row__del { width: 40px; border: 1px solid var(--line); background: var(--surface); color: var(--danger); font-size: 18px; line-height: 1; }
.dl-list__empty { font-size: 14px; color: var(--muted); }

/* editor */
.dl-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.dl-grid--4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.dl-span { grid-column: 1 / -1; }
.dl-radios { display: flex; gap: 0; }
.dl-radios label { flex: 1; }
.dl-radios input { position: absolute; opacity: 0; pointer-events: none; }
.dl-radios span {
  display: grid; place-items: center; min-height: 36px; border: 1px solid var(--line-2); font-size: 14px; cursor: pointer;
}
.dl-radios label + label span { margin-inline-start: -1px; }
.dl-radios input:checked + span { background: var(--text); color: var(--bg); border-color: var(--text); }
.dl-radios input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }

/* output */
.dl-json { min-height: 200px; max-height: 360px; font-size: 12px; white-space: pre-wrap; word-break: break-word; overflow: auto; }
.dl-status { font-size: 13px; }
.dl-status.is-ok { color: var(--ok); }
.dl-status.is-bad { color: var(--danger); }
.dl-status ul { margin-top: 4px; padding-inline-start: 18px; list-style: disc; }
.dl-actions { display: flex; flex-wrap: wrap; gap: 8px; }

/* help */
.dl-help { margin-top: 32px; display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 16px; }
.dl-help .dl-box { align-content: start; }
.dl-help ol { list-style: decimal; padding-inline-start: 20px; display: grid; gap: 6px; font-size: 15px; }
.dl-help ul { list-style: disc; padding-inline-start: 20px; display: grid; gap: 6px; font-size: 15px; }
.dl-help p { font-size: 15px; color: var(--muted); }
.dl-help pre { margin: 0; padding: 12px; overflow: auto; background: var(--surface-2); font: 12px/1.5 var(--font-mono); }

/* import dialog */
.dl-dialog { width: min(640px, 100% - 32px); padding: 0; border: 1px solid var(--line-2); background: var(--surface); color: var(--text); }
.dl-dialog::backdrop { background: rgb(0 0 0 / .45); }
.dl-dialog form { display: grid; gap: 12px; padding: 20px; }
.dl-dialog h2 { font-size: 18px; font-weight: 600; }
.dl-dialog textarea { min-height: 260px; }

@media (max-width: 1180px) {
  .dl { grid-template-columns: minmax(0, 1fr) 340px; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
