/* ============================================================================
   Imerwise · AI Tools — shared design system ("the theme")
   ----------------------------------------------------------------------------
   The single source of truth for the whole family. The hub uses it; every tool
   links it from the hub so one edit propagates:

       <link rel="stylesheet" href="https://imw-aitools.web.app/theme.css" />
       <script defer src="https://imw-aitools.web.app/theme.js"></script>

   A tool inherits ALL structural styling (neutrals, type, cards, buttons, chips,
   header, footer). It personalizes itself with exactly one variable:

       :root { --tool-accent: #a78bfa; --tool-accent-2: #818cf8; }

   Semantic colors (ok / warn) are shared and are NOT the accent.
   ============================================================================ */

:root {
  /* warm-graphite neutrals — light is the default theme */
  --ground:    #f4f1ec;
  --panel:     #fbfaf8;
  --panel-2:   #f0ece5;
  --hairline:  #e4ded4;
  --hairline-2:#d7d0c4;
  --ink:       #211d18;
  --ink-soft:  #4b453c;
  --muted:     #7a7266;
  --faint:     #a49b8d;

  /* family accent — a tool overrides these two (+ -ink for text-on-accent) */
  --tool-accent:   #c85a3a;
  --tool-accent-2: #dd6b4d;
  --accent-ink:    #fff6f1;
  --accent-wash:   rgba(200, 90, 58, .10);

  /* semantic — separate from accent, identical across every tool */
  --ok:        #4f8f63;
  --ok-wash:   rgba(79, 143, 99, .13);
  --warn:      #b07d1f;
  --warn-wash: rgba(176, 125, 31, .14);

  --radius: 14px;
  --radius-sm: 9px;
  --maxw: 1080px;

  --sans: "Söhne", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", "Menlo", "Consolas", monospace;

  --shadow: 0 1px 2px rgba(33, 29, 24, .05), 0 8px 24px -12px rgba(33, 29, 24, .18);
}

@media (prefers-color-scheme: dark) {
  :root {
    --ground:    #15120f;
    --panel:     #1d1915;
    --panel-2:   #24201a;
    --hairline:  #302a23;
    --hairline-2:#3d362d;
    --ink:       #ece7df;
    --ink-soft:  #c5bdb0;
    --muted:     #9d9487;
    --faint:     #6f675b;

    --tool-accent:   #e0764f;
    --tool-accent-2: #ec8a66;
    --accent-ink:    #1a1006;
    --accent-wash:   rgba(224, 118, 79, .13);

    --ok:        #6fbb84;
    --ok-wash:   rgba(111, 187, 132, .13);
    --warn:      #d6a24a;
    --warn-wash: rgba(214, 162, 74, .14);

    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 14px 34px -16px rgba(0, 0, 0, .6);
  }
}

/* Explicit toggle (theme.js stamps data-theme) must win over the media query
   in BOTH directions. Tools that override --tool-accent should do so AFTER this
   file loads so their accent survives the theme switch. */
:root[data-theme="light"] {
  --ground:#f4f1ec; --panel:#fbfaf8; --panel-2:#f0ece5; --hairline:#e4ded4; --hairline-2:#d7d0c4;
  --ink:#211d18; --ink-soft:#4b453c; --muted:#7a7266; --faint:#a49b8d;
  --accent-ink:#fff6f1; --accent-wash:rgba(200,90,58,.10);
  --ok:#4f8f63; --ok-wash:rgba(79,143,99,.13); --warn:#b07d1f; --warn-wash:rgba(176,125,31,.14);
  --shadow:0 1px 2px rgba(33,29,24,.05), 0 8px 24px -12px rgba(33,29,24,.18);
}
:root[data-theme="dark"] {
  --ground:#15120f; --panel:#1d1915; --panel-2:#24201a; --hairline:#302a23; --hairline-2:#3d362d;
  --ink:#ece7df; --ink-soft:#c5bdb0; --muted:#9d9487; --faint:#6f675b;
  --accent-ink:#1a1006; --accent-wash:rgba(224,118,79,.13);
  --ok:#6fbb84; --ok-wash:rgba(111,187,132,.13); --warn:#d6a24a; --warn-wash:rgba(214,162,74,.14);
  --shadow:0 1px 2px rgba(0,0,0,.3), 0 14px 34px -16px rgba(0,0,0,.6);
}

/* ---------------------------------------------------------------- base ---- */
* { box-sizing: border-box; }
html { color-scheme: light dark; }
body {
  margin: 0;
  background: var(--ground);
  color: var(--ink);
  font-family: var(--sans);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  min-height: 100vh;
}
a { color: inherit; text-decoration: none; }
code, .mono { font-family: var(--mono); }
::selection { background: var(--accent-wash); }

.wrap { max-width: var(--maxw); margin: 0 auto; padding: 0 24px; }

/* ambient warm light — cheap, fixed, non-interactive */
body::before {
  content: ""; position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background:
    radial-gradient(70% 50% at 82% -8%, var(--accent-wash), transparent 60%),
    radial-gradient(50% 40% at 0% 0%, rgba(120, 110, 95, .06), transparent 55%);
}

/* -------------------------------------------------------------- header ---- */
header {
  position: sticky; top: 0; z-index: 20;
  backdrop-filter: saturate(1.4) blur(10px);
  background: color-mix(in srgb, var(--ground) 82%, transparent);
  border-bottom: 1px solid var(--hairline);
}
.bar { display: flex; align-items: center; justify-content: space-between; height: 60px; }
.brand { display: inline-flex; align-items: center; gap: 11px; font-weight: 640; letter-spacing: -.01em; font-size: 16px; }
.brand small { color: var(--muted); font-weight: 500; }
.glyph {
  width: 26px; height: 26px; border-radius: 8px; flex: none;
  background: linear-gradient(150deg, var(--tool-accent-2), var(--tool-accent));
  display: grid; place-items: center; box-shadow: inset 0 1px 0 rgba(255, 255, 255, .25);
}
.glyph i { width: 9px; height: 9px; border-radius: 50%; border: 2.4px solid var(--accent-ink); display: block; }

nav { display: flex; align-items: center; gap: 4px; }
nav a {
  font-size: 14px; color: var(--muted); padding: 7px 12px; border-radius: 8px;
  transition: color .15s, background .15s;
}
nav a:hover { color: var(--ink); background: var(--panel-2); }
nav a.acct {
  color: var(--ink); border: 1px solid var(--hairline-2); font-weight: 560;
  font-family: var(--mono); font-size: 12.5px;
}
nav a.acct:hover { border-color: var(--tool-accent); color: var(--tool-accent); background: transparent; }

.theme-btn {
  margin-left: 6px; width: 34px; height: 34px; border-radius: 8px; cursor: pointer;
  border: 1px solid var(--hairline-2); background: var(--panel); color: var(--ink-soft);
  display: grid; place-items: center; font-size: 15px; transition: border-color .15s, color .15s;
}
.theme-btn:hover { color: var(--tool-accent); border-color: var(--tool-accent); }

/* ------------------------------------------------ shared auth menu widget --- */
/* The one sign-in / account control every tool mounts (authmenu.js). Signed-out
   trigger reads like a plain nav link; signed-in trigger takes the .acct pill. */
.authmenu { position: relative; display: inline-flex; }
.authmenu-trigger {
  display: inline-flex; align-items: center; gap: 6px; cursor: pointer;
  font: 500 14px/1 var(--sans); color: var(--muted);
  padding: 7px 12px; border-radius: 8px; border: 1px solid transparent; background: transparent;
  transition: color .15s, background .15s, border-color .15s;
}
.authmenu-trigger:hover { color: var(--ink); background: var(--panel-2); }
.authmenu[data-state="in"] .authmenu-trigger {
  color: var(--ink); border-color: var(--hairline-2); font-weight: 560;
  font-family: var(--mono); font-size: 12.5px;
}
.authmenu[data-state="in"] .authmenu-trigger:hover { border-color: var(--tool-accent); color: var(--tool-accent); background: transparent; }
.authmenu-trigger .caret { width: 12px; height: 12px; opacity: .7; transition: transform .15s; }
.authmenu[data-open="1"] .authmenu-trigger .caret { transform: rotate(180deg); }

.authmenu-pop {
  position: absolute; top: calc(100% + 8px); right: 0; z-index: 40;
  min-width: 250px; padding: 6px; display: flex; flex-direction: column; gap: 2px;
  background: var(--panel); border: 1px solid var(--hairline-2);
  border-radius: 13px; box-shadow: var(--shadow);
}
.authmenu-pop[hidden] { display: none; }
.authmenu-head { padding: 8px 10px 6px; }
.authmenu-back-head { display: flex; align-items: center; gap: 6px; padding-left: 4px; }
.authmenu-back {
  width: 24px; height: 24px; flex: none; display: grid; place-items: center; cursor: pointer;
  border: 0; background: transparent; color: var(--muted); border-radius: 7px; font-size: 20px; line-height: 1;
}
.authmenu-back:hover { background: var(--panel-2); color: var(--ink); }
.authmenu-title { font-family: var(--mono); font-size: 11px; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); }
.authmenu-email { font-size: 13.5px; font-weight: 560; color: var(--ink); word-break: break-all; margin-top: 3px; padding: 0 10px; }
.authmenu-head .authmenu-email { padding: 0; }
.authmenu-sep { height: 1px; background: var(--hairline); margin: 5px 2px; }
.authmenu-note { font-size: 12px; color: var(--muted); padding: 4px 10px 2px; }
.authmenu-err { font-size: 12.5px; color: var(--warn); padding: 4px 10px; }

.authmenu-item {
  display: flex; align-items: center; gap: 10px; width: 100%; text-align: left; cursor: pointer;
  padding: 9px 10px; border-radius: 8px; border: 0; background: transparent;
  color: var(--ink); font: 500 14px/1 var(--sans);
}
.authmenu-item:hover { background: var(--panel-2); }
.authmenu-item.danger { color: var(--warn); }
.authmenu-item .ico { width: 16px; height: 16px; flex: none; color: var(--muted); }
.authmenu-item.danger .ico { color: var(--warn); }
.authmenu-item .chev { width: 14px; height: 14px; margin-left: auto; opacity: .55; }

.authmenu-oauth {
  display: flex; align-items: center; gap: 11px; width: 100%; cursor: pointer;
  padding: 10px 12px; border-radius: 9px; margin-top: 2px;
  border: 1px solid var(--hairline-2); background: var(--ground); color: var(--ink);
  font: 500 14px/1 var(--sans); transition: border-color .15s, background .15s;
}
.authmenu-oauth:hover { border-color: var(--tool-accent); }
.authmenu-oauth:disabled { opacity: .55; cursor: default; }
.authmenu-oauth svg { width: 17px; height: 17px; flex: none; }

.authmenu-prov { display: flex; align-items: center; gap: 10px; padding: 8px 10px; font-size: 13.5px; }
.authmenu-prov svg { width: 17px; height: 17px; flex: none; }
.authmenu-prov .state { margin-left: auto; display: inline-flex; align-items: center; gap: 5px; font: 500 12px/1 var(--mono); color: var(--ok); }
.authmenu-prov .connect {
  margin-left: auto; cursor: pointer; font: 500 12px/1 var(--sans); padding: 7px 12px; border-radius: 7px;
  border: 1px solid var(--hairline-2); background: transparent; color: var(--ink); transition: border-color .15s, color .15s;
}
.authmenu-prov .connect:hover { border-color: var(--tool-accent); color: var(--tool-accent); }
.authmenu-prov .connect:disabled { opacity: .55; cursor: default; }

/* ---------------------------------------------------------------- hero ---- */
.hero { padding: 66px 0 30px; max-width: 720px; }
.eyebrow {
  font-family: var(--mono); font-size: 12px; letter-spacing: .04em; text-transform: uppercase;
  color: var(--tool-accent); display: inline-flex; align-items: center; gap: 8px; margin-bottom: 18px;
}
.eyebrow::before { content: ""; width: 22px; height: 1px; background: var(--tool-accent); opacity: .6; }
h1 {
  font-size: clamp(34px, 5.4vw, 52px); line-height: 1.04; letter-spacing: -.033em;
  margin: 0 0 18px; font-weight: 680; text-wrap: balance;
}
h1 em { font-style: normal; color: var(--tool-accent); }
.lead { font-size: clamp(16px, 2vw, 18.5px); color: var(--ink-soft); max-width: 560px; margin: 0; }
.sub { color: var(--muted); }

.hero-meta {
  display: flex; flex-wrap: wrap; gap: 22px; margin-top: 30px;
  font-family: var(--mono); font-size: 12.5px; color: var(--muted);
}
.hero-meta b { color: var(--ink); font-weight: 600; }
.hero-meta span { display: inline-flex; align-items: center; gap: 8px; }
.hero-meta span::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--tool-accent); }

/* ------------------------------------------------------- section header --- */
.sec-head {
  display: flex; align-items: baseline; justify-content: space-between; gap: 16px;
  margin: 54px 0 18px; padding-bottom: 12px; border-bottom: 1px solid var(--hairline);
}
.sec-head h2 { font-size: 21px; font-weight: 640; margin: 0; letter-spacing: -.02em; }
.sec-head .count { font-family: var(--mono); font-size: 12px; color: var(--faint); text-align: right; }

/* --------------------------------------------------------------- cards ---- */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 16px; }
.card {
  position: relative; background: var(--panel); border: 1px solid var(--hairline);
  border-radius: var(--radius); padding: 22px 22px 20px; display: flex; flex-direction: column;
  transition: border-color .18s, transform .18s, box-shadow .18s; overflow: hidden;
}
.card::before {
  content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px;
  background: var(--card-accent, var(--tool-accent)); opacity: 0; transition: opacity .18s;
}
.card:hover { border-color: var(--hairline-2); transform: translateY(-2px); box-shadow: var(--shadow); }
.card:hover::before { opacity: 1; }
/* the whole card is a link — keep keyboard focus visible and drive the inner
   affordance button from the card's hover */
a.card:focus-visible { outline: 2px solid var(--tool-accent); outline-offset: 2px; }
.card:hover .btn:not(.primary):not(.ghost-accent) { border-color: var(--tool-accent); color: var(--tool-accent); }
.card:hover .btn.primary { filter: brightness(1.06); }

/* the "Your tool" invitation — visibly an offer, not a shipped tool: a dashed
   accent frame, accent wash, corner tag, outlined mark, ghost-accent CTA */
.card.enterprise {
  border: 1.5px dashed color-mix(in srgb, var(--tool-accent) 48%, transparent);
  background:
    radial-gradient(130% 90% at 100% 0%, var(--accent-wash), transparent 58%),
    var(--panel);
}
.card.enterprise::before { display: none; }
.card.enterprise:hover {
  border-color: var(--tool-accent);
  background:
    radial-gradient(130% 100% at 100% 0%, color-mix(in srgb, var(--tool-accent) 15%, transparent), transparent 60%),
    var(--panel);
}
.card.enterprise .tool-mark {
  background: var(--accent-wash); color: var(--tool-accent);
  box-shadow: inset 0 0 0 1.5px color-mix(in srgb, var(--tool-accent) 40%, transparent);
}
.card.enterprise h3 { color: var(--tool-accent); }
.btn.ghost-accent {
  color: var(--tool-accent); background: transparent;
  border-color: color-mix(in srgb, var(--tool-accent) 45%, transparent);
}
.card.enterprise:hover .btn.ghost-accent {
  background: var(--tool-accent); color: var(--accent-ink); border-color: transparent;
}

.card-top { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.tool-mark {
  width: 40px; height: 40px; border-radius: 11px; flex: none; display: grid; place-items: center;
  color: #fff; box-shadow: inset 0 1px 0 rgba(255, 255, 255, .22);
  background: linear-gradient(150deg, var(--card-accent, var(--tool-accent-2)), var(--card-accent, var(--tool-accent)));
}
.tool-mark svg { width: 22px; height: 22px; }
.card h3 { margin: 0; font-size: 17px; letter-spacing: -.015em; }
.id-tag {
  font-family: var(--mono); font-size: 11px; color: var(--muted);
  background: var(--panel-2); border: 1px solid var(--hairline); padding: 1px 7px; border-radius: 6px;
  display: inline-block; margin-top: 3px;
}
.card p { margin: 0 0 18px; color: var(--muted); font-size: 14px; flex: 1; }
.card-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; }

/* pricing (plan cards) */
.price { font-size: 30px; font-weight: 680; letter-spacing: -.02em; margin: 8px 0 2px; }
.price small { font-size: 13px; color: var(--muted); font-weight: 500; letter-spacing: 0; }

/* --------------------------------------------------------------- chips ---- */
.chip {
  font-family: var(--mono); font-size: 11.5px; font-weight: 600; letter-spacing: .01em;
  padding: 4px 9px; border-radius: 999px; display: inline-flex; align-items: center; gap: 6px;
  white-space: nowrap;
}
.chip::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.chip.active { color: var(--ok); background: var(--ok-wash); }
.chip.perreq { color: var(--warn); background: var(--warn-wash); }
.chip.free   { color: var(--muted); background: var(--panel-2); }
.chip.none   { color: var(--faint); background: var(--panel-2); }
.chip.brand  { color: var(--tool-accent); background: var(--accent-wash); }

/* ------------------------------------------------------------- buttons ---- */
.btn {
  display: inline-flex; align-items: center; gap: 7px; font-family: var(--sans);
  font-size: 13.5px; font-weight: 580; padding: 9px 15px; border-radius: var(--radius-sm);
  border: 1px solid var(--hairline-2); background: var(--panel); color: var(--ink);
  cursor: pointer; transition: border-color .15s, color .15s, background .15s, filter .15s, transform .1s;
}
.btn:hover { border-color: var(--tool-accent); color: var(--tool-accent); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: default; pointer-events: none; }
.btn svg { width: 14px; height: 14px; }
.btn.primary {
  background: linear-gradient(180deg, var(--tool-accent-2), var(--tool-accent));
  color: var(--accent-ink); border-color: transparent;
}
.btn.primary:hover { filter: brightness(1.06); color: var(--accent-ink); }
.btn:focus-visible { outline: 2px solid var(--tool-accent); outline-offset: 2px; }

/* --------------------------------------------------------- feature band --- */
.band {
  margin: 52px 0 8px; border: 1px solid var(--hairline); border-radius: var(--radius);
  background: linear-gradient(180deg, var(--panel), var(--panel-2));
  padding: 30px 28px; display: grid; grid-template-columns: 1.3fr 1fr; gap: 28px; align-items: center;
}
.band h3 { margin: 0 0 8px; font-size: 20px; letter-spacing: -.02em; }
.band p { margin: 0; color: var(--muted); font-size: 14.5px; max-width: 46ch; }
.flow { display: flex; flex-direction: column; gap: 10px; font-family: var(--mono); font-size: 12.5px; }
.flow-row {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px;
  background: var(--panel); border: 1px solid var(--hairline); border-radius: 9px; color: var(--ink-soft);
}
.flow-row b { color: var(--tool-accent); font-weight: 600; }
.flow-row .k { color: var(--muted); }
.flow-row svg { width: 13px; height: 13px; color: var(--faint); flex: none; }

/* --------------------------------------------------------------- footer --- */
footer { margin-top: 48px; border-top: 1px solid var(--hairline); }
.foot {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 26px 0; color: var(--muted); font-size: 13px; flex-wrap: wrap;
}
.foot .mono { font-family: var(--mono); font-size: 12px; color: var(--faint); }
.foot a:hover { color: var(--tool-accent); }

/* ---------------------------------------------------------------- forms --- */
.form-card {
  background: var(--panel); border: 1px solid var(--hairline);
  border-radius: var(--radius); padding: 26px;
}
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.field { display: flex; flex-direction: column; gap: 7px; }
.field.full { grid-column: 1 / -1; }
.field label {
  font-family: var(--mono); font-size: 11px; letter-spacing: .05em; text-transform: uppercase;
  color: var(--muted);
}
.field input, .field select, .field textarea {
  width: 100%; font-family: var(--sans); font-size: 14.5px; color: var(--ink);
  background: var(--ground); border: 1px solid var(--hairline-2); border-radius: var(--radius-sm);
  padding: 11px 13px; transition: border-color .15s, box-shadow .15s;
}
.field textarea { resize: vertical; min-height: 108px; line-height: 1.5; }
.field select { cursor: pointer; appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 18px) 51%, calc(100% - 13px) 51%; background-size: 5px 5px, 5px 5px; background-repeat: no-repeat;
}
.field input::placeholder, .field textarea::placeholder { color: var(--faint); }
.field input:focus, .field select:focus, .field textarea:focus {
  outline: none; border-color: var(--tool-accent);
  box-shadow: 0 0 0 3px var(--accent-wash);
}
.check {
  display: flex; align-items: flex-start; gap: 10px; margin-top: 4px;
  font-size: 13px; color: var(--muted); cursor: pointer;
}
.check input { width: 17px; height: 17px; margin-top: 1px; accent-color: var(--tool-accent); flex: none; cursor: pointer; }
.form-note {
  font-size: 13.5px; border-radius: var(--radius-sm); padding: 12px 14px;
  display: flex; align-items: center; gap: 9px;
}
.form-note.ok  { color: var(--ok);   background: var(--ok-wash); }
.form-note.err { color: var(--warn); background: var(--warn-wash); }
.spinner {
  width: 16px; height: 16px; border-radius: 50%; flex: none;
  display: inline-block; vertical-align: middle;
  border: 2px solid color-mix(in srgb, currentColor 30%, transparent);
  border-top-color: currentColor; animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 560px) { .form-grid { grid-template-columns: 1fr; } }

/* --------------------------------------------------- account / centered --- */
.stack { display: flex; flex-direction: column; gap: 16px; }
.centered { max-width: 520px; margin: 0 auto; padding: 96px 24px; text-align: center; }
.centered h1 { font-size: clamp(28px, 5vw, 38px); }
.centered .btn { margin-top: 8px; }
.notice { color: var(--muted); font-size: 14px; }
.account-actions {
  margin-top: 26px; display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  padding-top: 22px; border-top: 1px solid var(--hairline);
}

/* --------------------------------------------------------- responsive ----- */
@media (max-width: 720px) {
  .band { grid-template-columns: 1fr; }
  nav a.hide-sm { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
