/* files402 — paper & charcoal with one green. Sleek and technical but
   readable: hard 1px rules, square corners, mono details, soft shadow on lift.
   No framework, no build step.

   Token roles:
   --accent     green for text: prices, links, paid states
   --accent-bg  green fill: primary buttons, the 402 badge, quota bars
   --accent-fg  text on green fills
   --accent-dim quiet green tint (drop-target, selected states)
   --btn / --btn-fg  neutral charcoal/paper fill (step numbers, secondary) */

:root {
  color-scheme: light;
  --bg: #faf9f7;
  --bg-soft: #ffffff;
  --fg: #26282b;
  --muted: #6b7076;
  --line: #dcdad4;
  --accent: #27754a;
  --accent-bg: #27865a;
  --accent-fg: #ffffff;
  --accent-dim: #e3efe7;
  --btn: #26282b;
  --btn-fg: #faf9f7;
  --ok: #27754a;
  --danger: #c2453a;
  --radius: 0;
  --shadow: 0 1px 2px rgba(24, 24, 22, .05), 0 4px 14px rgba(24, 24, 22, .06);
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Inter, sans-serif;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, monospace;
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #111111; --bg-soft: #1a1a19; --fg: #e9e9e6; --muted: #9c9c96;
  --line: #2c2c2a; --accent: #52b788; --accent-bg: #4aab7c; --accent-fg: #0d1811; --accent-dim: #1e3629;
  --btn: #e9e9e6; --btn-fg: #111111; --ok: #52b788; --danger: #d96f60;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 6px 20px rgba(0, 0, 0, .25);
}
@media (prefers-color-scheme: dark) {
  :root[data-theme="auto"] {
    color-scheme: dark;
    --bg: #111111; --bg-soft: #1a1a19; --fg: #e9e9e6; --muted: #9c9c96;
    --line: #2c2c2a; --accent: #52b788; --accent-bg: #4aab7c; --accent-fg: #0d1811; --accent-dim: #1e3629;
    --btn: #e9e9e6; --btn-fg: #111111; --ok: #52b788; --danger: #d96f60;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 6px 20px rgba(0, 0, 0, .25);
  }
}

* { box-sizing: border-box; }
/* `hidden` must win over display rules like `.ghost { display: inline-flex }`. */
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; font-family: var(--font); background: var(--bg); color: var(--fg);
  line-height: 1.55; letter-spacing: -0.011em;
  -webkit-font-smoothing: antialiased;
}
.mono { font-family: var(--mono); font-size: 0.92em; }
a { color: inherit; }

/* Top bar */
.bar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0.9rem clamp(1rem, 5vw, 2.5rem); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; background: var(--bg); z-index: 10;
}
.brand { display: inline-flex; align-items: center; gap: 0.55rem; font-weight: 700; text-decoration: none; font-size: 1.05rem; letter-spacing: -0.01em; }
.brand .mono {
  background: var(--accent-bg); color: var(--accent-fg); font-weight: 700;
  padding: 0.05rem 0.45rem; border-radius: 0; letter-spacing: 0.02em;
}
.dot { width: 8px; height: 8px; background: var(--accent-bg); }
.bar-actions { display: inline-flex; align-items: center; gap: 0.6rem; }
/* The wallet chip doubles as the sign-out button: hover turns it red. */
.wallet {
  font-family: var(--mono); font-size: 0.82rem; color: var(--muted);
  border: 1px solid var(--line); border-radius: var(--radius); padding: 0.3rem 0.6rem;
  background: transparent; cursor: pointer; transition: border-color .12s, color .12s;
}
.wallet::after { content: " ✕"; opacity: 0.5; }
.wallet:hover { border-color: var(--danger); color: var(--danger); }
.wallet:hover::after { opacity: 1; }

main { max-width: 60rem; margin: 0 auto; padding: clamp(1.5rem, 6vw, 5rem) clamp(1rem, 5vw, 2.5rem); }

/* Buttons — primary is the green; everything else stays neutral */
button, .ghost { font: inherit; cursor: pointer; }
.primary {
  background: var(--accent-bg); color: var(--accent-fg); border: 1px solid var(--accent-bg);
  font-weight: 600; padding: 0.7rem 1.15rem; border-radius: var(--radius);
  transition: transform .08s, box-shadow .12s, opacity .12s;
}
.primary:hover { transform: translateY(-1px); box-shadow: var(--shadow); }
.primary:active { transform: translateY(0); box-shadow: none; }
.ghost {
  background: transparent; color: var(--fg); border: 1px solid var(--line);
  padding: 0.7rem 1.1rem; border-radius: var(--radius); text-decoration: none;
  display: inline-flex; align-items: center; font-weight: 500;
  transition: border-color .12s, transform .08s, box-shadow .12s;
}
.ghost:hover { border-color: var(--muted); transform: translateY(-1px); box-shadow: var(--shadow); }
.ghost:active { transform: translateY(0); box-shadow: none; }
.danger { background: transparent; color: var(--danger); border: 1px solid var(--danger); border-radius: var(--radius); padding: 0.7rem 1.1rem; }
.danger:hover { background: var(--danger); color: var(--bg-soft); }
.sm { padding: 0.45rem 0.8rem; font-size: 0.9rem; }
.icon {
  background: transparent; border: 1px solid var(--line); border-radius: var(--radius);
  width: 2.2rem; height: 2.2rem; color: var(--fg); font-size: 1rem;
  display: inline-grid; place-items: center; padding: 0; line-height: 1;
}
.icon:hover { border-color: var(--muted); }
.link { color: var(--accent); cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 0; }

.row { display: flex; flex-wrap: wrap; gap: 0.7rem; align-items: center; }
.status { min-height: 1.3rem; color: var(--muted); font-size: 0.9rem; margin: 1rem 0 0; font-family: var(--mono); }
.status.err { color: var(--danger); }
.status.ok { color: var(--ok); }
.muted { color: var(--muted); }
.sm.muted, .muted.sm { font-size: 0.85rem; }

/* Landing */
.landing h1 { font-size: clamp(2.2rem, 6.5vw, 3.6rem); line-height: 1.05; margin: 0 0 1.2rem; letter-spacing: -0.03em; font-weight: 750; }
.sub { font-size: 1.18rem; color: var(--muted); max-width: 36ch; margin: 0 0 1.8rem; }
.sub strong { color: var(--fg); }
.price, .sub strong.price {
  color: var(--accent); font-weight: 700;
  font-size: 1.2em; letter-spacing: -0.01em;
  font-family: var(--mono); white-space: nowrap;
}
.how { display: grid; gap: 0; margin-top: 4rem; grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr)); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.how > div { border-right: 1px solid var(--line); padding: 1.4rem; background: var(--bg-soft); }
.how > div:last-child { border-right: none; }
@media (max-width: 48rem) {
  .how > div { border-right: none; border-bottom: 1px solid var(--line); }
  .how > div:last-child { border-bottom: none; }
}
.how p { margin: 0.7rem 0 0; color: var(--muted); }
.how strong { color: var(--fg); }
.step { display: inline-grid; place-items: center; width: 1.9rem; height: 1.9rem; border-radius: 0; background: var(--btn); color: var(--btn-fg); font-family: var(--mono); font-weight: 600; }

/* Examples gallery */
.examples { margin-top: 4.5rem; }
.examples-head h2 { margin: 0 0 0.35rem; font-size: 1.6rem; letter-spacing: -0.02em; font-weight: 750; }
.examples-head p { margin: 0; max-width: 46ch; }
.ex-grid { display: grid; gap: 1.4rem; margin-top: 1.8rem; grid-template-columns: repeat(auto-fill, minmax(19rem, 1fr)); }
.ex-card {
  border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; background: var(--bg-soft);
  display: flex; flex-direction: column;
  transition: border-color .12s, transform .08s, box-shadow .12s;
}
.ex-card:hover { border-color: var(--muted); transform: translateY(-2px); box-shadow: var(--shadow); }
.ex-frame { position: relative; }
/* Each iframe is its own viewport: a live but non-interactive preview showing the
   top of the page. Demos are responsive, so a card-width viewport reads cleanly. */
.ex-iframe {
  width: 100%; height: 16rem; border: 0; display: block;
  background: var(--bg); pointer-events: none;
}
.ex-meta { display: flex; align-items: flex-start; justify-content: space-between; gap: 0.8rem; padding: 0.95rem 1.05rem 1.1rem; border-top: 1px solid var(--line); }
.ex-meta h3 { margin: 0 0 0.2rem; font-size: 1.02rem; }
.ex-meta p { margin: 0; }
.ex-meta .ghost { flex: none; }

/* Sell + Pricing + Agents (landing) */
.green { color: var(--accent); }
.sell, .pricing, .agents { margin-top: 4.5rem; }
.sell h2, .pricing h2, .agents h2 { margin: 0 0 0.35rem; font-size: 1.6rem; letter-spacing: -0.02em; font-weight: 750; }
.sell > p, .pricing > p, .agents > p { margin: 0 0 0.4rem; max-width: 52ch; }
.wire {
  margin: 1.2rem 0; padding: 1rem 1.2rem; border: 1px solid var(--line); background: var(--bg-soft);
  font-size: 0.82rem; line-height: 1.6; overflow-x: auto; color: var(--fg);
}
.sell-grid { margin-top: 1.8rem; }
.pricing-grid { margin-top: 1.8rem; grid-template-columns: repeat(auto-fit, minmax(10rem, 1fr)); }
.pricing .row { margin-top: 1.8rem; }
.pricing > .sm { margin-top: 1rem; }

/* Dashboard */
.dash-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.dash-head h2 { margin: 0; font-size: 1.5rem; font-weight: 750; letter-spacing: -0.02em; }
.folders { display: grid; gap: 1rem; margin-top: 1.5rem; grid-template-columns: repeat(auto-fill, minmax(18rem, 1fr)); }
.card {
  border: 1px solid var(--line); border-radius: var(--radius); padding: 1.15rem; background: var(--bg-soft);
  cursor: pointer; display: grid; gap: 0.6rem;
  transition: border-color .12s, transform .08s, box-shadow .12s;
}
.card:hover { border-color: var(--muted); transform: translateY(-2px); box-shadow: var(--shadow); }
.card h3 { margin: 0; font-size: 1.1rem; }
.card .url { color: var(--accent); font-size: 0.82rem; word-break: break-all; }
.card-meta { display: flex; justify-content: space-between; font-size: 0.82rem; color: var(--muted); font-family: var(--mono); }
.tag { font-size: 0.72rem; padding: 0.12rem 0.5rem; border: 1px solid var(--line); border-radius: 0; font-family: var(--mono); }
.tag.paid { color: var(--accent); border-color: var(--accent); }
.tag.lapsed { color: var(--danger); border-color: var(--danger); }
.empty { color: var(--muted); margin-top: 2rem; }

.quota { height: 6px; background: var(--line); overflow: hidden; }
.quota-fill { height: 100%; width: 0; background: var(--accent-bg); transition: width .3s; }

/* Tier picker */
.modal-title { margin: 0; flex: 1; font-size: 1.25rem; font-weight: 750; }
.seg { margin-top: 0.9rem; gap: 0; }
.seg .ghost { border-radius: 0; }
.seg .ghost + .ghost { border-left: none; }
.seg-on { border-color: var(--accent) !important; color: var(--accent); font-weight: 600; }
.seg .seg-on + .ghost { border-left: 1px solid var(--line); }
select#f-period { font: inherit; font-size: 0.9rem; padding: 0.45rem 0.5rem; border: 1px solid var(--line); background: var(--bg-soft); color: var(--fg); border-radius: 0; }
.tier-grid { display: grid; gap: 0.7rem; margin-top: 1rem; grid-template-columns: repeat(auto-fit, minmax(9rem, 1fr)); }
.tier-opt {
  display: grid; gap: 0.15rem; justify-items: start; text-align: left;
  padding: 0.9rem 1rem; border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--bg-soft); color: var(--fg); cursor: pointer;
  transition: border-color .12s, transform .08s, box-shadow .12s;
}
.tier-opt:hover { border-color: var(--accent); transform: translateY(-2px); box-shadow: var(--shadow); }
.tier-price { color: var(--accent); font-weight: 700; font-size: 1.2rem; font-family: var(--mono); }
.tier-price em { font-style: normal; font-weight: 500; font-size: 0.8rem; color: var(--muted); }
select#f-tier { font: inherit; padding: 0.55rem 0.7rem; border: 1px solid var(--line); border-radius: var(--radius); background: var(--bg-soft); color: var(--fg); }

/* Modal / file manager */
dialog {
  border: 1px solid var(--line); border-radius: 0; padding: 1.5rem;
  width: min(38rem, 92vw); background: var(--bg-soft); color: var(--fg);
  box-shadow: var(--shadow);
}
dialog::backdrop { background: rgba(15, 16, 14, .45); }
.modal-head { display: flex; align-items: center; gap: 0.6rem; }
.name-input { flex: 1; font-size: 1.25rem; font-weight: 650; border: none; background: transparent; color: var(--fg); padding: 0.2rem 0; border-bottom: 1px solid transparent; }
.name-input:hover, .name-input:focus { border-bottom-color: var(--line); outline: none; }
.url-line { display: flex; align-items: center; gap: 0.5rem; margin: 0.4rem 0 1rem; }
.url { flex: 1; color: var(--accent); word-break: break-all; text-decoration: none; }

.drop { border: 1px dashed var(--line); border-radius: var(--radius); padding: 1.6rem; text-align: center; color: var(--muted); margin: 1rem 0; transition: border-color .12s, background .12s; }
.drop.over { border-color: var(--accent); border-style: solid; background: var(--accent-dim); color: var(--fg); }
.files { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.35rem; max-height: 15rem; overflow: auto; }
.files li { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; padding: 0.5rem 0.7rem; border: 1px solid var(--line); border-radius: var(--radius); font-size: 0.9rem; background: var(--bg); }
.files .fname { font-family: var(--mono); font-size: 0.85rem; word-break: break-all; }
.files .fdel { background: transparent; border: none; color: var(--danger); cursor: pointer; font-size: 1rem; }

.settings { margin-top: 1.2rem; border-top: 1px solid var(--line); padding-top: 0.8rem; }
.modal-actions { margin-top: 1.2rem; }
.settings summary { cursor: pointer; color: var(--muted); font-size: 0.92rem; }
.field { display: grid; gap: 0.3rem; margin: 0.9rem 0; }
.field span { font-size: 0.85rem; color: var(--muted); }
.field input { font: inherit; padding: 0.55rem 0.7rem; border: 1px solid var(--line); border-radius: var(--radius); background: var(--bg-soft); color: var(--fg); }
.field input:focus { outline: none; border-color: var(--accent); }

footer { max-width: 60rem; margin: 0 auto; padding: 2rem clamp(1rem, 5vw, 2.5rem); color: var(--muted); font-size: 0.9rem; border-top: 1px solid var(--line); }
footer .mono { color: var(--accent); }

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