/* AI Tools portal — single stylesheet, light + dark via prefers-color-scheme. */

:root {
  --bg: #f6f7fb;
  --bg-accent: radial-gradient(1200px 600px at 10% -10%, #e0e7ff 0%, transparent 60%),
               radial-gradient(900px 500px at 110% 0%, #fae8ff 0%, transparent 55%);
  --surface: #ffffff;
  --surface-2: #f3f4f8;
  --border: #e4e6ef;
  --border-strong: #d3d6e2;
  --text: #171a2c;
  --muted: #646a82;
  --primary: #5b5bd6;
  --primary-hover: #4a4ac4;
  --primary-soft: #ececfd;
  --on-primary: #fff;
  --danger: #dc3545;
  --danger-soft: #fdecee;
  --ok: #138a52;
  --ok-soft: #e5f6ed;
  --ring: 0 0 0 3px rgba(91, 91, 214, .25);
  --shadow-sm: 0 1px 2px rgba(20, 22, 50, .06);
  --shadow: 0 1px 2px rgba(20, 22, 50, .05), 0 6px 20px -6px rgba(20, 22, 50, .10);
  --shadow-lg: 0 2px 4px rgba(20, 22, 50, .04), 0 20px 40px -12px rgba(20, 22, 50, .22);
  --radius: 14px;
  --radius-sm: 9px;
  --topbar: rgba(255, 255, 255, .78);
  --font: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0d0f1a;
    --bg-accent: radial-gradient(1200px 600px at 10% -10%, rgba(99, 102, 241, .16) 0%, transparent 60%),
                 radial-gradient(900px 500px at 110% 0%, rgba(192, 38, 211, .12) 0%, transparent 55%);
    --surface: #151827;
    --surface-2: #1c2033;
    --border: #262a40;
    --border-strong: #343952;
    --text: #e8eaf5;
    --muted: #979cb6;
    --primary: #7c7cf0;
    --primary-hover: #9090f5;
    --primary-soft: rgba(124, 124, 240, .16);
    --on-primary: #0d0f1a;
    --danger: #f06272;
    --danger-soft: rgba(240, 98, 114, .14);
    --ok: #4ad295;
    --ok-soft: rgba(74, 210, 149, .13);
    --ring: 0 0 0 3px rgba(124, 124, 240, .35);
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .3);
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px -8px rgba(0, 0, 0, .5);
    --shadow-lg: 0 2px 4px rgba(0, 0, 0, .3), 0 24px 48px -12px rgba(0, 0, 0, .6);
    --topbar: rgba(13, 15, 26, .75);
  }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  font: 15px/1.55 var(--font);
  color: var(--text);
  background: var(--bg-accent), var(--bg);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { margin: 0; line-height: 1.25; letter-spacing: -.015em; }
h1 { font-size: clamp(1.5rem, 1.2rem + 1.2vw, 2rem); font-weight: 700; }
h2 { font-size: 1.05rem; font-weight: 650; }
p { margin: 0; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
code { font: .85em var(--mono); background: var(--surface-2); border: 1px solid var(--border); padding: .08em .38em; border-radius: 6px; }
small { font-size: .82rem; }
.muted { color: var(--muted); }
.right { text-align: right; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
[hidden] { display: none !important; }

.i { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  background: var(--topbar);
  backdrop-filter: saturate(1.6) blur(14px);
  -webkit-backdrop-filter: saturate(1.6) blur(14px);
  border-bottom: 1px solid var(--border);
}
.topbar-inner { max-width: 1120px; margin: 0 auto; padding: 10px 24px; display: flex; align-items: center; gap: 28px; }
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); font-weight: 700; letter-spacing: -.01em; font-size: 1.02rem; }
.brand:hover { text-decoration: none; }
.logo { width: 30px; height: 30px; flex: none; }
.mainnav { display: flex; gap: 4px; flex: 1; }
.mainnav a {
  display: flex; align-items: center; gap: 8px;
  padding: 7px 12px; border-radius: 999px;
  color: var(--muted); font-weight: 550; font-size: .93rem;
  transition: background .15s, color .15s;
}
.mainnav a:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.mainnav a[aria-current="page"] { background: var(--primary-soft); color: var(--primary); }

.avatar {
  display: inline-grid; place-items: center; flex: none;
  width: 34px; height: 34px; border-radius: 50%;
  background: linear-gradient(135deg, #818cf8, #c084fc);
  color: #fff; font-weight: 650; font-size: .8rem; letter-spacing: .02em;
}
.avatar.lg { width: 42px; height: 42px; font-size: .95rem; }
.avatar.xl { width: 64px; height: 64px; font-size: 1.35rem; box-shadow: var(--shadow); }

.usermenu { position: relative; }
.usermenu summary { list-style: none; cursor: pointer; border-radius: 50%; }
.usermenu summary::-webkit-details-marker { display: none; }
.usermenu summary:focus-visible { outline: none; box-shadow: var(--ring); }
.usermenu[open] summary .avatar { box-shadow: var(--ring); }
.menu {
  position: absolute; right: 0; top: calc(100% + 10px); width: 260px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow-lg); padding: 6px; animation: pop .14s ease-out;
}
.menu-head { display: flex; gap: 12px; align-items: center; padding: 10px 10px 12px; border-bottom: 1px solid var(--border); margin-bottom: 6px; }
.menu-head strong, .menu-head small { display: block; }
.menu-head small { color: var(--muted); }
.menu a, .menu button {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 9px 10px; border: 0; border-radius: var(--radius-sm);
  background: none; color: var(--text); font: inherit; text-align: left; cursor: pointer;
}
.menu a:hover, .menu button:hover { background: var(--surface-2); text-decoration: none; }
.menu form { margin: 0; }
@keyframes pop { from { opacity: 0; transform: translateY(-4px) scale(.98); } }

/* ---------- layout ---------- */
.container { max-width: 1120px; margin: 0 auto; padding: 36px 24px 80px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; margin-bottom: 26px; flex-wrap: wrap; }
.page-head p { margin-top: 6px; }
.identity { display: flex; align-items: center; gap: 18px; }
.backlink { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: .9rem; margin-bottom: 14px; }
.backlink .i { width: 16px; height: 16px; }
.backlink:hover { color: var(--text); text-decoration: none; }

.cards { display: grid; gap: 20px; }
.cards.two { grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: start; }
.span-2 { grid-column: span 2; }
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow-sm); padding: 24px;
}
.card h2 { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.card h2 .i { color: var(--primary); }
.card form h2:not(:first-of-type) { margin-top: 12px; padding-top: 22px; border-top: 1px solid var(--border); }
.card.flush { padding: 0; overflow: hidden; }
.danger-zone { border-color: color-mix(in srgb, var(--danger) 30%, var(--border)); }
.danger-zone h2 .i { color: var(--danger); }
.danger-zone .actions { margin-top: 14px; }

/* ---------- hero + app grid ---------- */
.hero { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; margin: 8px 0 30px; flex-wrap: wrap; }
.hero h1 { font-size: clamp(1.8rem, 1.3rem + 2vw, 2.6rem); letter-spacing: -.03em; }
.hero p.muted { margin-top: 8px; font-size: 1.05rem; }
.eyebrow { display: inline-flex; align-items: center; gap: 6px; color: var(--primary); font-weight: 650; font-size: .8rem; text-transform: uppercase; letter-spacing: .08em; margin-bottom: 10px; }
.eyebrow .i { width: 15px; height: 15px; }

.search { position: relative; display: block; width: min(320px, 100%); }
.search .i { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); color: var(--muted); }
.search input { padding-left: 40px; border-radius: 999px; }

.app-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 16px; }
.app-card {
  position: relative; display: flex; align-items: center; gap: 16px;
  padding: 18px; min-height: 96px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  color: var(--text); box-shadow: var(--shadow-sm);
  transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease;
}
.app-card:hover { text-decoration: none; transform: translateY(-2px); box-shadow: var(--shadow-lg); border-color: var(--border-strong); }
.app-card:focus-visible { outline: none; box-shadow: var(--ring), var(--shadow); }
.app-body { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1; }
.app-body strong { font-size: 1.02rem; font-weight: 650; }
.app-body .muted { font-size: .88rem; line-height: 1.4; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.app-go { color: var(--muted); opacity: 0; transform: translate(-4px, 4px); transition: all .18s ease; }
.app-card:hover .app-go { opacity: 1; transform: none; color: var(--primary); }

.app-icon {
  display: grid; place-items: center; flex: none;
  width: 56px; height: 56px; border-radius: 16px;
  font-size: 1.65rem; font-weight: 700; color: #fff; line-height: 1;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .25), 0 6px 14px -6px var(--tint-shadow, rgba(0,0,0,.3));
}
.app-icon.sm { width: 38px; height: 38px; border-radius: 11px; font-size: 1.15rem; }
.app-icon.lg { width: 64px; height: 64px; border-radius: 18px; font-size: 1.9rem; }

.tint-indigo  { background: linear-gradient(140deg, #818cf8, #4f46e5); --tint-shadow: rgba(79, 70, 229, .55); }
.tint-violet  { background: linear-gradient(140deg, #c084fc, #7c3aed); --tint-shadow: rgba(124, 58, 237, .55); }
.tint-pink    { background: linear-gradient(140deg, #f9a8d4, #db2777); --tint-shadow: rgba(219, 39, 119, .5); }
.tint-rose    { background: linear-gradient(140deg, #fda4af, #e11d48); --tint-shadow: rgba(225, 29, 72, .5); }
.tint-orange  { background: linear-gradient(140deg, #fdba74, #ea580c); --tint-shadow: rgba(234, 88, 12, .5); }
.tint-amber   { background: linear-gradient(140deg, #fcd34d, #d97706); --tint-shadow: rgba(217, 119, 6, .5); }
.tint-emerald { background: linear-gradient(140deg, #6ee7b7, #059669); --tint-shadow: rgba(5, 150, 105, .5); }
.tint-teal    { background: linear-gradient(140deg, #5eead4, #0d9488); --tint-shadow: rgba(13, 148, 136, .5); }
.tint-sky     { background: linear-gradient(140deg, #7dd3fc, #0284c7); --tint-shadow: rgba(2, 132, 199, .5); }
.tint-slate   { background: linear-gradient(140deg, #94a3b8, #475569); --tint-shadow: rgba(71, 85, 105, .5); }

.empty, .status-page {
  display: flex; flex-direction: column; align-items: center; text-align: center; gap: 10px;
  padding: 64px 24px; margin: 12px auto; max-width: 520px;
}
.empty { background: var(--surface); border: 1px dashed var(--border-strong); border-radius: var(--radius); max-width: none; }
.empty p { max-width: 460px; }
.empty .btn, .status-page .btn { margin-top: 12px; }
.empty-art { display: grid; grid-template-columns: repeat(2, 30px); gap: 8px; margin-bottom: 12px; transform: rotate(-8deg); }
.empty-art span { width: 30px; height: 30px; border-radius: 9px; opacity: .9; }
.empty-art span:nth-child(2) { transform: translateY(6px); }
.empty-art span:nth-child(3) { transform: translateY(-6px); }
.status-page { padding-top: 90px; }
.status-icon { display: grid; place-items: center; width: 72px; height: 72px; border-radius: 22px; color: #fff; margin-bottom: 10px; }
.status-icon .i { width: 32px; height: 32px; }

/* ---------- forms ---------- */
.stack { display: flex; flex-direction: column; gap: 16px; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; border: 0; padding: 0; margin: 0; }
.field > span, .field legend { font-weight: 600; font-size: .88rem; }
.field legend { margin-bottom: 8px; padding: 0; }
.field small { color: var(--muted); }
input:not([type=checkbox]):not([type=radio]), select, textarea {
  width: 100%; font: inherit; color: var(--text);
  background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  padding: 9px 12px; transition: border-color .15s, box-shadow .15s;
}
input::placeholder { color: color-mix(in srgb, var(--muted) 70%, transparent); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); box-shadow: var(--ring); }
.input-group { display: flex; gap: 8px; }
.input-group input { flex: 1; min-width: 0; font-family: var(--mono); font-size: .92rem; }
.input-group.prefix { gap: 0; }
.input-group.prefix span {
  display: flex; align-items: center; padding: 0 10px; font: .9rem var(--mono); color: var(--muted);
  background: var(--surface-2); border: 1px solid var(--border-strong); border-right: 0;
  border-radius: var(--radius-sm) 0 0 var(--radius-sm);
}
.input-group.prefix input { border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }
.actions { display: flex; justify-content: flex-end; gap: 10px; flex-wrap: wrap; }
.note { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: .9rem; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 9px 16px; border-radius: var(--radius-sm);
  font: inherit; font-weight: 600; font-size: .92rem; white-space: nowrap;
  color: var(--text); background: var(--surface); border: 1px solid var(--border-strong);
  box-shadow: var(--shadow-sm); cursor: pointer;
  transition: background .15s, border-color .15s, box-shadow .15s, transform .05s;
}
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: none; box-shadow: var(--ring); }
.btn .i { width: 17px; height: 17px; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
.btn.primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
.btn.danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 40%, transparent); }
.btn.danger:hover { background: var(--danger); color: #fff; }
.btn.ghost { background: transparent; border-color: transparent; box-shadow: none; color: var(--muted); }
.btn.ghost:hover { background: var(--surface-2); color: var(--text); }
.btn.sm { padding: 5px 11px; font-size: .85rem; }
.btn.block { width: 100%; padding: 11px 16px; }

/* toggle switches built on a real checkbox */
.toggles { display: flex; flex-direction: column; gap: 4px; }
.toggle { display: flex; align-items: flex-start; gap: 14px; padding: 10px 12px; margin: 0 -12px; border-radius: var(--radius-sm); cursor: pointer; }
.toggle:hover { background: var(--surface-2); }
.toggle input { position: absolute; opacity: 0; pointer-events: none; }
.toggle strong, .toggle small { display: block; }
.toggle small { color: var(--muted); }
.switch { position: relative; flex: none; width: 40px; height: 23px; margin-top: 1px; border-radius: 999px; background: var(--border-strong); transition: background .18s; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 17px; height: 17px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.25); transition: transform .18s; }
.toggle input:checked + .switch { background: var(--primary); }
.toggle input:checked + .switch.danger { background: var(--danger); }
.toggle input:checked + .switch::after { transform: translateX(17px); }
.toggle input:focus-visible + .switch { box-shadow: var(--ring); }

.app-picks { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 10px; }
.app-pick {
  display: flex; align-items: center; gap: 12px; padding: 10px 12px;
  border: 1px solid var(--border); border-radius: var(--radius-sm); cursor: pointer;
  transition: border-color .15s, background .15s;
}
.app-pick:hover { border-color: var(--border-strong); background: var(--surface-2); }
.app-pick:has(input:checked) { border-color: var(--primary); background: var(--primary-soft); }
.app-pick:has(input:disabled) { cursor: default; }
.app-pick.off { opacity: .6; }
.app-pick strong, .app-pick small { display: block; }
.app-pick input { accent-color: var(--primary); width: 16px; height: 16px; margin: 0; }

.swatches { display: flex; flex-wrap: wrap; gap: 10px; }
.swatch { position: relative; width: 34px; height: 34px; border-radius: 10px; cursor: pointer; transition: transform .12s; }
.swatch:hover { transform: scale(1.08); }
.swatch input { position: absolute; opacity: 0; }
.swatch:has(input:checked) { box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--text); }
.swatch:has(input:focus-visible) { box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--primary); }

/* ---------- alerts, badges, tables ---------- */
.alert { display: flex; align-items: center; gap: 10px; padding: 11px 14px; border-radius: var(--radius-sm); margin-bottom: 20px; font-weight: 500; font-size: .93rem; animation: pop .18s ease-out; transition: opacity .4s; }
.alert.ok { background: var(--ok-soft); color: var(--ok); }
.alert.err { background: var(--danger-soft); color: var(--danger); }
.alert.fade { opacity: 0; }

.badge { display: inline-flex; align-items: center; gap: 6px; padding: 2px 9px; border-radius: 999px; font-size: .78rem; font-weight: 600; background: var(--surface-2); color: var(--muted); border: 1px solid var(--border); white-space: nowrap; }
.badge.dot::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.violet { color: #7c3aed; background: color-mix(in srgb, #7c3aed 10%, transparent); border-color: transparent; }
.badge.emerald { color: var(--ok); background: var(--ok-soft); border-color: transparent; }
.badge.rose { color: var(--danger); background: var(--danger-soft); border-color: transparent; }
.badge.sky { color: #0284c7; background: color-mix(in srgb, #0284c7 11%, transparent); border-color: transparent; }
@media (prefers-color-scheme: dark) {
  .badge.violet { color: #c4a5fd; }
  .badge.sky { color: #7dd3fc; }
}

.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-size: .75rem; font-weight: 650; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); padding: 12px 20px; background: var(--surface-2); border-bottom: 1px solid var(--border); }
.table td { padding: 14px 20px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.rowlink { cursor: pointer; transition: background .12s; }
.rowlink:hover { background: color-mix(in srgb, var(--surface-2) 60%, transparent); }
.who { display: flex; align-items: center; gap: 12px; }
.who strong, .who small { display: block; }

.code { margin: 14px 0 0; padding: 16px 18px; background: #11131f; color: #d7dbf2; border-radius: var(--radius-sm); overflow-x: auto; font: .85rem/1.6 var(--mono); }
.code code { background: none; border: 0; padding: 0; font-size: inherit; color: inherit; }

/* ---------- login ---------- */
.bare-main { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login-wrap { position: relative; width: 100%; max-width: 400px; }
.login-glow { position: absolute; inset: -80px -60px; z-index: -1; background: radial-gradient(closest-side, rgba(129, 140, 248, .35), transparent), radial-gradient(closest-side at 80% 70%, rgba(192, 38, 211, .22), transparent); filter: blur(30px); }
.login-card { background: var(--surface); border: 1px solid var(--border); border-radius: 20px; box-shadow: var(--shadow-lg); padding: 36px 32px 32px; }
.login-brand { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 8px; margin-bottom: 26px; }
.login-brand .logo { width: 54px; height: 54px; margin-bottom: 6px; filter: drop-shadow(0 8px 16px rgba(99, 102, 241, .35)); }
.login-brand h1 { font-size: 1.6rem; }
.login-brand p { color: var(--muted); }
.login-card .btn.block { margin-top: 6px; }
.login-foot { text-align: center; color: var(--muted); font-size: .85rem; margin-top: 18px; }

/* ---------- responsive ---------- */
@media (max-width: 820px) {
  .cards.two, .grid-2 { grid-template-columns: 1fr; }
  .span-2 { grid-column: auto; }
  .hide-sm { display: none; }
}
@media (max-width: 640px) {
  .topbar-inner { padding: 8px 14px; gap: 10px; }
  .brand span { display: none; }
  .mainnav a { padding: 8px 10px; }
  .mainnav a span { display: none; }
  .mainnav a[aria-current="page"] span { display: inline; }
  .container { padding: 24px 14px 60px; }
  .card { padding: 18px; }
  .table th, .table td { padding: 12px 14px; }
  .table td.right { display: none; }
  .table th:last-child { display: none; }
  .identity { gap: 14px; }
  .avatar.xl, .app-icon.lg { width: 52px; height: 52px; font-size: 1.4rem; }
  .app-grid { grid-template-columns: 1fr; }
  .app-go { opacity: 1; transform: none; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
