/* ---------------------------------------------------------------------------
   Application styles
   A printed, workshop-like look: paper ground, ink type, hard offset shadows,
   one warm accent. No gradients, no glows.
--------------------------------------------------------------------------- */
:root {
  --paper: #f4f1ea;
  --card: #fffdf8;
  --card-2: #efebe1;
  --ink: #16140f;
  --ink-2: #3f3b33;
  --muted: #736d61;
  --line: #ddd6c7;
  --line-2: #c7bfad;
  --accent: #bf3f26;        /* vermillion */
  --accent-ink: #8f2f1c;
  --green: #2c6049;
  --blue: #2a4d7a;
  --gold: #a9762a;
  --radius: 6px;
  --radius-lg: 10px;
  --shadow: 3px 3px 0 var(--ink);
  --shadow-soft: 0 2px 10px rgba(22, 20, 15, .08);
  --font: 'IBM Plex Sans', system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  --display: 'Fraunces', Georgia, 'Times New Roman', serif;
  --mono: 'IBM Plex Mono', ui-monospace, Menlo, monospace;
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; font-family: var(--font); background: var(--paper); color: var(--ink); line-height: 1.55; -webkit-font-smoothing: antialiased; }
a { color: var(--accent-ink); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 2px; }
h1, h2, h3, h4 { font-family: var(--display); font-weight: 600; line-height: 1.12; margin: 0 0 .5em; letter-spacing: -.01em; }
h1 { font-size: 2.1rem; } h2 { font-size: 1.6rem; } h3 { font-size: 1.2rem; }
p { margin: 0 0 1em; }
code, pre { font-family: var(--mono); font-size: .88em; }
code { background: var(--card-2); padding: 1px 5px; border-radius: 4px; }
img { max-width: 100%; }
hr { border: 0; border-top: 1px solid var(--line); margin: 24px 0; }
.container { max-width: 1120px; margin: 0 auto; padding: 0 20px; }
.container-wide { max-width: 1600px; margin: 0 auto; padding: 0 20px; }
.page { padding-block: 34px 72px; min-height: 60vh; }
.muted { color: var(--muted); } .small { font-size: .86em; } .center { text-align: center; }
.mt { margin-top: 24px; } .mb { margin-bottom: 24px; } .mt-sm { margin-top: 12px; }
.grid { display: grid; gap: 18px; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(290px, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fill, minmax(262px, 1fr)); }
.grid-4 { grid-template-columns: repeat(auto-fill, minmax(215px, 1fr)); }
.row { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }
.row-between { justify-content: space-between; }
.spacer { flex: 1; }

/* Header ------------------------------------------------------------------ */
.topbar { position: sticky; top: 0; z-index: 50; background: var(--paper); border-bottom: 1px solid var(--line-2); }
.topbar-inner { display: flex; align-items: center; justify-content: space-between; height: 62px; gap: 16px; }
.brand { display: inline-flex; align-items: center; gap: 9px; font-family: var(--display); font-weight: 700; font-size: 1.12rem; color: var(--ink); letter-spacing: -.02em; white-space: nowrap; }
.brand:hover { text-decoration: none; }
.brand-mark { width: 26px; height: 26px; flex: none; }
.nav { display: flex; gap: 2px; align-items: center; }
.nav > a { color: var(--ink-2); padding: 7px 11px; border-radius: var(--radius); font-weight: 500; font-size: .93rem; }
.nav > a:hover { color: var(--ink); background: var(--card-2); text-decoration: none; }
.nav > a.btn { color: #fff; }
.nav-user { display: inline-flex; align-items: center; gap: 8px; }
.nav-user img { width: 24px; height: 24px; border-radius: 3px; border: 1px solid var(--line-2); }
.nav-toggle { display: none; background: var(--card); border: 1px solid var(--line-2); color: var(--ink); border-radius: var(--radius); padding: 5px 10px; font-size: 1.05rem; }
@media (max-width: 880px) {
  .nav { display: none; position: absolute; top: 62px; left: 0; right: 0; background: var(--card); border-bottom: 1px solid var(--line-2); flex-direction: column; align-items: stretch; padding: 10px 20px; box-shadow: var(--shadow-soft); }
  body.nav-open .nav { display: flex; }
  .nav-toggle { display: block; }
}

/* Buttons ----------------------------------------------------------------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 10px 18px; border-radius: var(--radius); border: 1.5px solid var(--ink); background: var(--card); color: var(--ink); font-family: inherit; font-weight: 600; font-size: .93rem; cursor: pointer; transition: transform .1s, box-shadow .1s, background .1s; white-space: nowrap; }
.btn:hover { text-decoration: none; background: #fff; transform: translate(-1px, -1px); box-shadow: 2px 2px 0 var(--ink); }
.btn:active { transform: translate(0, 0); box-shadow: none; }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none; box-shadow: none; }
.btn-primary { background: var(--accent); border-color: var(--accent-ink); color: #fff; }
.btn-primary:hover { background: var(--accent-ink); box-shadow: 2px 2px 0 var(--ink); }
.btn-ghost { border-color: var(--line-2); background: transparent; font-weight: 500; }
.btn-ghost:hover { box-shadow: none; transform: none; background: var(--card-2); }
.btn-danger { border-color: var(--accent-ink); color: var(--accent-ink); background: #fff; }
.btn-success { border-color: var(--green); color: #fff; background: var(--green); }
.btn-sm { padding: 6px 12px; font-size: .84rem; border-width: 1px; }
.btn-lg { padding: 14px 26px; font-size: 1.02rem; }
.btn-block { width: 100%; }

/* Surfaces ---------------------------------------------------------------- */
.card { background: var(--card); border: 1px solid var(--line-2); border-radius: var(--radius-lg); padding: 22px; }
.card-sm { padding: 15px; }
.card h2, .card h3 { margin-top: 0; }
.stat { background: var(--card); border: 1px solid var(--line-2); border-radius: var(--radius-lg); padding: 16px 18px; }
.stat .value { font-family: var(--display); font-size: 1.65rem; font-weight: 600; line-height: 1.1; }
.stat .label { color: var(--muted); font-size: .83rem; }
.badge { display: inline-block; padding: 2px 8px; border-radius: 3px; font-size: .74rem; font-weight: 600; background: var(--card-2); border: 1px solid var(--line-2); color: var(--ink-2); letter-spacing: .02em; }
.badge-success { background: #e4efe6; color: var(--green); border-color: #bcd6c3; }
.badge-warn { background: #f6ead2; color: var(--gold); border-color: #e2cda3; }
.badge-danger { background: #f7e2dd; color: var(--accent-ink); border-color: #e5bfb4; }
.badge-accent { background: #ece6f0; color: var(--blue); border-color: #c9d3e2; }

/* Forms ------------------------------------------------------------------- */
label { display: block; font-size: .83rem; color: var(--ink-2); margin-bottom: 5px; font-weight: 600; letter-spacing: .01em; }
.field { margin-bottom: 16px; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=url], input[type=search], input[type=file], select, textarea {
  width: 100%; background: #fff; border: 1px solid var(--line-2); color: var(--ink); border-radius: var(--radius); padding: 10px 12px; font-size: .94rem; font-family: inherit; transition: border-color .12s, box-shadow .12s;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--ink); box-shadow: 2px 2px 0 var(--line-2); }
input:disabled, select:disabled, textarea:disabled { background: var(--card-2); color: var(--muted); }
textarea { min-height: 104px; resize: vertical; }
select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%23736d61' stroke-width='1.6' fill='none'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; padding-right: 32px; }
.check { display: flex; gap: 9px; align-items: flex-start; font-size: .93rem; color: var(--ink); cursor: pointer; font-weight: 400; }
.check input { margin-top: 4px; accent-color: var(--accent); }
.help { font-size: .8rem; color: var(--muted); margin-top: 5px; font-weight: 400; }
.form-narrow { max-width: 440px; margin: 0 auto; }

/* Flash ------------------------------------------------------------------- */
.flash { padding: 11px 15px; border-radius: var(--radius); margin-bottom: 16px; border: 1px solid; border-left-width: 4px; font-size: .93rem; }
.flash-success { background: #e8f1ea; border-color: #9cc0a8; color: #1f4a38; }
.flash-error { background: #fae9e4; border-color: #d6a294; color: var(--accent-ink); }
.flash-info { background: #eeeae2; border-color: var(--line-2); color: var(--ink-2); }

/* Tables ------------------------------------------------------------------ */
.table { width: 100%; border-collapse: collapse; font-size: .9rem; background: var(--card); }
.table th, .table td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table th { color: var(--muted); font-weight: 600; font-size: .76rem; text-transform: uppercase; letter-spacing: .06em; background: var(--card-2); }
.table tr:hover td { background: #fffefb; }
.table-wrap { overflow-x: auto; border: 1px solid var(--line-2); border-radius: var(--radius-lg); }

/* Tool cards -------------------------------------------------------------- */
.tool-card { display: block; background: var(--card); border: 1px solid var(--line-2); border-radius: var(--radius-lg); padding: 18px; color: var(--ink); transition: transform .12s, box-shadow .12s; }
.tool-card:hover { text-decoration: none; transform: translate(-2px, -2px); box-shadow: var(--shadow); }
.tool-card-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.tool-icon { font-size: 1.6rem; line-height: 1; width: 46px; height: 46px; display: inline-flex; align-items: center; justify-content: center; background: var(--card-2); border: 1px solid var(--line); border-radius: var(--radius); }
.tool-icon-lg { font-size: 2.6rem; width: 78px; height: 78px; border-radius: var(--radius-lg); }
.tool-price { font-weight: 700; font-size: .88rem; color: var(--accent-ink); font-variant-numeric: tabular-nums; }
.tool-price.free { color: var(--green); }
.tool-card h3 { margin: 0 0 3px; font-size: 1.05rem; }
.tool-card p { color: var(--muted); font-size: .88rem; margin: 0 0 10px; min-height: 2.5em; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.tool-card-meta { display: flex; justify-content: space-between; align-items: center; font-size: .82rem; }
.tool-card-author { margin-top: 5px; }
.stars { color: var(--gold); letter-spacing: 1px; }

/* Plans ------------------------------------------------------------------- */
.plans { display: grid; grid-template-columns: repeat(auto-fit, minmax(225px, 1fr)); gap: 18px; }
.plan { background: var(--card); border: 1px solid var(--line-2); border-radius: var(--radius-lg); padding: 24px; position: relative; display: flex; flex-direction: column; }
.plan.highlight { border: 1.5px solid var(--ink); box-shadow: var(--shadow); }
.plan .plan-badge { position: absolute; top: -11px; left: 22px; background: var(--ink); color: var(--paper); font-size: .7rem; font-weight: 600; padding: 3px 10px; border-radius: 3px; letter-spacing: .06em; text-transform: uppercase; }
.plan h3 { font-size: 1.15rem; }
.plan .price { font-family: var(--display); font-size: 2.1rem; font-weight: 600; margin: 6px 0 2px; font-variant-numeric: tabular-nums; }
.plan .price small { font-size: .85rem; font-weight: 400; color: var(--muted); font-family: var(--font); }
.plan ul { list-style: none; padding: 0; margin: 16px 0 20px; color: var(--ink-2); font-size: .9rem; flex: 1; }
.plan li { padding: 5px 0 5px 20px; position: relative; border-bottom: 1px solid var(--line); }
.plan li::before { content: '·'; position: absolute; left: 4px; color: var(--accent); font-weight: 700; font-size: 1.3em; line-height: 1; }

/* Tabs -------------------------------------------------------------------- */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line-2); margin-bottom: 20px; overflow-x: auto; }
.tabs a, .tabs button { background: none; border: 0; border-bottom: 2px solid transparent; color: var(--muted); padding: 9px 13px; font-weight: 600; font-size: .9rem; cursor: pointer; white-space: nowrap; font-family: inherit; }
.tabs a.active, .tabs button.active { color: var(--ink); border-bottom-color: var(--accent); }
.tabs a:hover { text-decoration: none; color: var(--ink); }

/* Runner ------------------------------------------------------------------ */
.runner-frame { width: 100%; height: 72vh; min-height: 470px; border: 1px solid var(--line-2); border-radius: var(--radius-lg); background: #fff; }

/* Type chooser ------------------------------------------------------------ */
.type-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 16px; }
.type-card { font-weight: 400; color: var(--ink); position: relative; display: block; background: var(--card); border: 1px solid var(--line-2); border-radius: var(--radius-lg); padding: 20px; cursor: pointer; transition: transform .12s, box-shadow .12s, border-color .12s; }
.type-card:hover { transform: translate(-2px, -2px); box-shadow: var(--shadow); }
.type-card input { position: absolute; opacity: 0; pointer-events: none; }
.type-card .t-glyph { width: 44px; height: 44px; margin-bottom: 12px; }
.type-card h3 { font-size: 1.08rem; margin-bottom: 4px; }
.type-card p { color: var(--muted); font-size: .88rem; margin: 0 0 10px; font-weight: 400; }
.type-card ul { margin: 0; padding-left: 17px; color: var(--ink-2); font-size: .84rem; font-weight: 400; }
.type-card li { padding: 1px 0; }
.type-card.selected { border: 1.5px solid var(--ink); box-shadow: var(--shadow); }
.type-card.locked { opacity: .62; cursor: not-allowed; }
.type-card.locked:hover { transform: none; box-shadow: none; }
.type-card .t-tick { position: absolute; top: 14px; right: 14px; width: 20px; height: 20px; border: 1px solid var(--line-2); border-radius: 50%; background: #fff; }
.type-card.selected .t-tick { background: var(--accent); border-color: var(--accent-ink); }
.type-card.selected .t-tick::after { content: '✓'; color: #fff; font-size: .75rem; display: grid; place-items: center; height: 100%; }
.steps-bar { display: flex; gap: 10px; align-items: center; color: var(--muted); font-size: .82rem; margin-bottom: 18px; letter-spacing: .02em; }
.steps-bar b { color: var(--ink); font-weight: 600; }

/* Builder ----------------------------------------------------------------- */
.mismatch { border-color: var(--accent); border-left: 3px solid var(--accent); }
.mismatch ul { margin: 0 0 10px; padding-left: 18px; color: var(--ink-2); }
.mismatch li { padding: 2px 0; }

.builder { display: grid; grid-template-columns: 335px 1fr; gap: 16px; height: calc(100vh - 62px - 40px); min-height: 620px; }
.builder-side { display: flex; flex-direction: column; gap: 10px; min-height: 0; }
.builder-main { display: flex; flex-direction: column; min-height: 0; gap: 10px; }
.builder-tabs { display: flex; gap: 3px; align-items: center; flex-wrap: wrap; }
.builder-tabs button { background: var(--card); border: 1px solid var(--line-2); color: var(--ink-2); padding: 6px 12px; border-radius: var(--radius); font-weight: 600; font-size: .84rem; cursor: pointer; font-family: inherit; }
.builder-tabs button:hover { background: #fff; }
.builder-tabs button.active { background: var(--ink); border-color: var(--ink); color: var(--paper); }
.builder-pane { flex: 1; min-height: 0; display: none; }
.builder-pane.active { display: flex; flex-direction: column; }
.builder-pane textarea.code { flex: 1; width: 100%; min-height: 0; resize: none; font-family: var(--mono); font-size: 13px; line-height: 1.6; tab-size: 2; white-space: pre; background: #fffdf8; border-radius: var(--radius-lg); }
.builder-pane iframe { flex: 1; width: 100%; border: 1px solid var(--line-2); border-radius: var(--radius-lg); background: #fff; }
.chat { flex: 1; min-height: 0; overflow-y: auto; display: flex; flex-direction: column; gap: 9px; padding: 13px; background: var(--card); border: 1px solid var(--line-2); border-radius: var(--radius-lg); }
.msg { padding: 9px 12px; border-radius: var(--radius); font-size: .87rem; white-space: pre-wrap; word-break: break-word; max-width: 100%; }
.msg-user { background: var(--ink); color: var(--paper); align-self: flex-end; border-bottom-right-radius: 2px; }
.msg-ai { background: var(--card-2); border: 1px solid var(--line); align-self: flex-start; border-bottom-left-radius: 2px; }
.msg-sys { color: var(--accent-ink); background: #fae9e4; border: 1px solid #e5bfb4; font-size: .84rem; }
.chat-form textarea { min-height: 76px; font-size: .9rem; }
.chat-empty { color: var(--muted); font-size: .87rem; }
.chat-empty ul { padding-left: 0; margin: 10px 0 0; list-style: none; }
.chat-empty li { cursor: pointer; padding: 6px 10px; border: 1px dashed var(--line-2); border-radius: var(--radius); margin-bottom: 6px; color: var(--ink-2); }
.chat-empty li:hover { border-style: solid; background: #fff; color: var(--ink); }
.typing::after { content: ''; animation: dots 1.4s steps(4, end) infinite; }
@keyframes dots { 0% { content: ''; } 25% { content: '.'; } 50% { content: '..'; } 75% { content: '...'; } }
.build-progress { height: 4px; background: var(--card-2); border-radius: 2px; overflow: hidden; margin-top: 8px; }
.build-progress span { display: block; height: 100%; width: 30%; background: var(--accent); animation: slide 1.6s ease-in-out infinite; }
@keyframes slide { 0% { margin-left: -30%; } 100% { margin-left: 100%; } }
@media (max-width: 980px) {
  .builder { grid-template-columns: 1fr; height: auto; }
  .builder-side { order: 2; }
  .builder-main { min-height: 68vh; }
  .chat { max-height: 38vh; }
}

/* Footer ------------------------------------------------------------------ */
.footer { border-top: 1px solid var(--line-2); padding: 26px 0; color: var(--muted); font-size: .86rem; background: var(--card-2); }
.footer-inner { display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.footer-links { display: flex; gap: 15px; flex-wrap: wrap; }
.footer-links a { color: var(--muted); }

/* Misc -------------------------------------------------------------------- */
.hero-small { padding: 18px 0 6px; }
.hero-small h1 { font-size: 2.3rem; }
.breadcrumbs { font-size: .83rem; color: var(--muted); margin-bottom: 12px; }
pre.code-block { background: #fffdf8; border: 1px solid var(--line-2); border-radius: var(--radius); padding: 13px; overflow-x: auto; font-size: .83rem; }
.progress { height: 7px; background: var(--card-2); border: 1px solid var(--line); border-radius: 4px; overflow: hidden; }
.progress span { display: block; height: 100%; background: var(--accent); }
.filters { display: flex; gap: 9px; flex-wrap: wrap; margin-bottom: 16px; }
.filters input, .filters select { width: auto; }
.chips { display: flex; gap: 7px; flex-wrap: wrap; margin-bottom: 20px; }
.chip { padding: 5px 11px; border-radius: 3px; border: 1px solid var(--line-2); background: var(--card); color: var(--ink-2); font-size: .84rem; }
.chip.active { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.chip:hover { text-decoration: none; border-color: var(--ink); }
