/* Hermes Hub design system: FrogeeSoft (the palette and rules of FgSNotes and FrogeeCode IDE).
   One file for the hub, its plugins and the apps agents build:
     <link rel="stylesheet" href="/hub-ui.css">   (on app subdomains: https://<hub-domain>/hub-ui.css)
   Rules: islands sit on a darker window; hover is a soft fill; the teal accent is only for the main action,
   selection, focus and links. Colours only through the tokens below. Light theme: <html data-theme="light">.
   Components: .btn .card .input .select .textarea .badge .tabs .md .row .col .grid .list-item .field */

:root {
  --raised: color-mix(in srgb, var(--text-color) 5%, var(--card-bg));
  --fill: color-mix(in srgb, var(--text-color) 8%, transparent);
  --fill-hover: color-mix(in srgb, var(--text-color) 12%, transparent);
  --separator: color-mix(in srgb, var(--text-color) 10%, transparent);
  --thumb: color-mix(in srgb, var(--text-color) 15%, var(--card-bg));
  --shadow-thumb: 0 0 0 .5px var(--separator), 0 1px 2px rgb(0 0 0 / .28);
  --shadow-float: 0 0 0 1px var(--separator), 0 2px 6px rgb(0 0 0 / .16), 0 16px 40px rgb(0 0 0 / .34);
  --ease-out: cubic-bezier(.2, 0, 0, 1);
  --radius-xs: 4px;
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;
  --gap: 4px;
  --ui-font: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Segoe UI Variable Text', 'Segoe UI', Inter, system-ui, sans-serif;
  --mono-font: 'JetBrains Mono', 'SF Mono', SFMono-Regular, Menlo, Consolas, monospace;

  /* Older hub names, kept so pages, plugins and agent apps written against them still work. */
  --bg: var(--card-bg);
  --bg-2: var(--raised);
  --bg-3: color-mix(in srgb, var(--text-color) 10%, var(--card-bg));
  --sidebar: var(--window-bg);
  --hover: var(--fill);
  --active: var(--fill-hover);
  --border: var(--border-color);
  --border-2: color-mix(in srgb, var(--text-color) 16%, transparent);
  --text: var(--text-color);
  --text-2: color-mix(in srgb, var(--text-color) 82%, var(--text-muted));
  --muted: var(--text-muted);
  --faint: var(--text-faint);
  --accent: var(--accent-color);
  --accent-soft: color-mix(in srgb, var(--accent-color) 16%, transparent);
  --blue: var(--link-color);
  --green: var(--success-color);
  --yellow: var(--warning-color);
  --red: var(--danger-color);
  --radius: var(--radius-md);
  --sans: var(--ui-font);
  --serif: var(--ui-font);
  --mono: var(--mono-font);
  --shadow: var(--shadow-float);
}

/* FrogeeSoft Dark: near-neutral greys with a faint green cast, one turquoise accent. */
:root, [data-theme="dark"] {
  color-scheme: dark;
  --window-bg: #0d0f0e;
  --card-bg: #141716;
  --header-bg: #111312;
  --editor-bg: #141716;
  --code-bg: #1b1e1d;
  --text-color: #f0f2f1;
  --text-muted: #9ba39e;
  --text-faint: #858d89; /* 5.30:1 on the island, 4.93:1 on code bg */
  --border-color: #252a28;
  /* Turquoise: oklch(0.78 0.13 180). 9.52:1 on the island, its label #03201d 9.04:1 on the fill. */
  --accent-color: #36d2ba;
  --accent-text: #03201d;
  --link-color: #36d2ba;
  --selection: #36d2ba45;
  --success-color: #7ce36f;
  --warning-color: #e6c07b;
  --danger-color: #ff6e66;
  --overlay: rgb(0 0 0 / .5);
  --syn-keyword: #5fd0df;
  --syn-string: #9bd28f;
  --syn-number: #e6c07b;
  --syn-comment: #737b77;
  --syn-function: #f0f2f1;
  --syn-type: #e6c07b;
  --syn-field: #b8c0bc;
  --syn-tag: #5fd0df;
  --syn-attr: #c7e3a7;
  --syn-annotation: #e6a07b;
  --syn-heading: #36d2ba;
  --syn-mark: #4d5450;
}

/* FrogeeSoft Light */
[data-theme="light"] {
  color-scheme: light;
  --window-bg: #eef1ea;
  --card-bg: #fbfcf9;
  --header-bg: #f6f8f3;
  --editor-bg: #fbfcf9;
  --code-bg: #f0f3ec;
  --text-color: #121713;
  --text-muted: #556058;
  --text-faint: #5c665e; /* 5.77:1 on the card, 5.21:1 on the window */
  --border-color: #dde3d8;
  /* Turquoise: oklch(0.50 0.085 182). 5.57:1 on the card, white label 5.73:1 on the fill. */
  --accent-color: #127367;
  --accent-text: #ffffff;
  --link-color: #127367;
  --selection: #1273672e;
  --success-color: #2e8a3c;
  --warning-color: #a35f00;
  --danger-color: #e8482c;
  --overlay: rgb(20 28 22 / .28);
  --thumb: #ffffff;
  --shadow-thumb: 0 0 0 .5px rgb(0 0 0 / .06), 0 1px 3px rgb(0 0 0 / .12);
  --shadow-float: 0 0 0 1px rgb(0 0 0 / .06), 0 2px 6px rgb(0 0 0 / .06), 0 16px 40px rgb(20 28 22 / .16);
  --syn-keyword: #0f6a7a;
  --syn-string: #2e7a3c;
  --syn-number: #a35f00;
  --syn-comment: #7d8a7f;
  --syn-function: #121713;
  --syn-type: #8a5a00;
  --syn-field: #3e4a40;
  --syn-tag: #0f6a7a;
  --syn-attr: #3f6b1f;
  --syn-annotation: #a3501f;
  --syn-heading: #127367;
  --syn-mark: #9aa69b;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--card-bg); color: var(--text-color); font: 13px/1.5 var(--ui-font);
  -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale;
}
button, input, textarea, select { font: inherit; color: inherit; }
a { color: var(--link-color); text-decoration-thickness: 1px; text-underline-offset: 3px; text-decoration: none; }
a:hover { text-decoration: underline; }
::selection { background: var(--selection); }
input::placeholder, textarea::placeholder { color: var(--text-muted); opacity: 1; }
input[type=checkbox], input[type=radio], input[type=range] { accent-color: var(--accent-color); }
:focus-visible { outline: 2px solid var(--accent-color); outline-offset: -2px; }
/* Thin rounded scrollbars that appear on hover, as in FgSNotes. */
* { scrollbar-width: thin; scrollbar-color: transparent transparent; }
*:hover { scrollbar-color: var(--fill-hover) transparent; }
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track, ::-webkit-scrollbar-corner { background: transparent; }
::-webkit-scrollbar-thumb { border-radius: 8px; background: transparent; }
:hover::-webkit-scrollbar-thumb { background: var(--fill-hover); }

/* ---------------------------------------------------------------- controls
   Buttons as on macOS: the one main action is filled with the accent, the rest are a quiet grey fill. */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px; height: 30px; padding: 0 12px;
  border-radius: var(--radius-md); border: 1px solid transparent; background: var(--fill); color: var(--text-color);
  cursor: pointer; font-size: 13px; font-weight: 500; white-space: nowrap;
  transition: background-color .12s, color .12s, scale .15s var(--ease-out);
}
.btn:hover { background: var(--fill-hover); text-decoration: none; }
.btn:not(:disabled):active { scale: .96; }
.btn:disabled { opacity: .35; cursor: default; }
.btn.primary { background: var(--accent-color); color: var(--accent-text); }
.btn.primary:hover { background: color-mix(in srgb, var(--accent-color) 88%, var(--text-color)); }
.btn.ghost { background: transparent; color: var(--text-muted); }
.btn.ghost:hover { background: var(--fill); color: var(--text-color); }
.btn.danger { color: var(--danger-color); }
.btn.sm { height: 26px; padding: 0 9px; font-size: 12px; border-radius: var(--radius-sm); }
.btn.icon { width: 30px; padding: 0; }
.btn.sm.icon { width: 26px; }
.input, .textarea, .select {
  width: 100%; background: var(--code-bg); border: 1px solid var(--border-color); border-radius: var(--radius-md);
  padding: 6px 10px; min-height: 30px; outline: none; transition: border-color .12s, box-shadow .12s;
}
.input:focus, .textarea:focus, .select:focus { border-color: var(--accent-color); box-shadow: 0 0 0 3px var(--accent-soft); }
.textarea { resize: vertical; min-height: 80px; line-height: 1.5; }
.row { display: flex; align-items: center; gap: 8px; }
.row.wrap { flex-wrap: wrap; }
.col { display: flex; flex-direction: column; gap: 8px; }
.grow { flex: 1; min-width: 0; }
.muted { color: var(--text-muted); }
.faint { color: var(--text-faint); }
.small { font-size: 12px; }
.mono { font-family: var(--mono-font); font-size: 12px; }
.sep { height: 1px; background: var(--separator); margin: 16px 0; }
.badge {
  display: inline-flex; align-items: center; gap: 5px; height: 20px; padding: 0 7px; border-radius: var(--radius-sm);
  font-size: 11px; font-weight: 500; background: var(--fill); color: var(--text-muted); white-space: nowrap;
}
.badge.green { background: color-mix(in srgb, var(--success-color) 15%, transparent); color: var(--success-color); }
.badge.red { background: color-mix(in srgb, var(--danger-color) 15%, transparent); color: var(--danger-color); }
.badge.yellow { background: color-mix(in srgb, var(--warning-color) 15%, transparent); color: var(--warning-color); }
.badge.blue, .badge.accent { background: var(--accent-soft); color: var(--accent-color); }
.dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; flex: none; }
.dot.pulse { animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .3; } }
.spin { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.kbd { font: 11px var(--mono-font); padding: 1px 5px; border-radius: var(--radius-xs); background: var(--fill); color: var(--text-muted); }

/* Cards are grouped rows on an island: a step lighter, a hairline, never a glow. */
.card { background: var(--raised); border: 1px solid var(--separator); border-radius: var(--radius-lg); padding: 16px; }
.card.hover { cursor: pointer; transition: background-color .12s, border-color .12s; }
.card.hover:hover { background: color-mix(in srgb, var(--text-color) 8%, var(--card-bg)); }
.card h3 { margin: 0 0 10px; font-size: 12px; font-weight: 500; color: var(--text-muted); }
.grid { display: grid; gap: 12px; }
.grid.c2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.c3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.c4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid.auto { grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); }
.page-title { font: 600 24px/1.25 var(--ui-font); margin: 0 0 6px; letter-spacing: -.02em; }
.page-sub { color: var(--text-muted); margin: 0 0 22px; font-size: 13px; }
.empty { text-align: center; color: var(--text-muted); padding: 48px 16px; }
.empty svg { opacity: .5; margin-bottom: 10px; }
.empty h2, .empty .title { font-size: 15px; font-weight: 600; color: var(--text-color); margin: 0 0 6px; }
.list { display: flex; flex-direction: column; }
.list-item {
  display: flex; align-items: center; gap: 10px; min-height: 30px; padding: 5px 10px; border-radius: var(--radius-md);
  cursor: pointer; min-width: 0;
}
.list-item:hover { background: var(--fill); }
.list-item.active { background: var(--fill-hover); }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* Segmented switch (FgSNotes view switch): a grey track, the chosen option is a raised thumb. */
.tabs { display: inline-flex; align-items: center; gap: 2px; padding: 2px; border-radius: var(--radius-md); background: var(--fill); }
.tab {
  height: 26px; display: inline-flex; align-items: center; gap: 6px; border: 0; background: transparent; padding: 0 10px;
  border-radius: var(--radius-sm); cursor: pointer; color: var(--text-muted); font-size: 12px; white-space: nowrap;
  transition: background-color .15s var(--ease-out), color .12s;
}
.tab:hover { color: var(--text-color); }
.tab.active { background: var(--thumb); color: var(--text-color); box-shadow: var(--shadow-thumb); }

/* ---------------------------------------------------------------- markdown (FgSNotes preview) */
.md { line-height: 1.7; overflow-wrap: anywhere; font-size: 14px; }
.md > :first-child { margin-top: 0; }
.md > :last-child { margin-bottom: 0; }
.md h1, .md h2, .md h3, .md h4 { font-weight: 600; line-height: 1.3; letter-spacing: -.01em; margin: 1.5em 0 .65em; }
.md h1 { font-size: 2em; margin-bottom: .7em; }
.md h2 { font-size: 1.45em; padding-bottom: .4em; border-bottom: 1px solid var(--border-color); }
.md h3 { font-size: 1.15em; }
.md p { margin: .8em 0; }
.md ul, .md ol { padding-left: 1.5em; margin: .8em 0; }
.md li { padding-left: .25em; margin: .3em 0; }
.md li::marker { color: var(--text-muted); }
.md li:has(> input[type=checkbox]) { list-style: none; margin-left: -1.3em; }
.md li > input[type=checkbox] { margin-right: 8px; }
.md code { font-family: var(--mono-font); font-size: .88em; background: var(--code-bg); padding: .12em .4em; border-radius: var(--radius-sm); }
.md pre { background: var(--code-bg); border-radius: var(--radius-lg); padding: 14px 16px; overflow: auto; line-height: 1.6; }
.md pre code { background: none; padding: 0; font-size: 12.5px; }
.md blockquote { margin: 1.4em 0; padding: 4px 16px; background: var(--code-bg); color: var(--text-muted); border-radius: var(--radius-md); }
.md table { width: 100%; margin: 1.2em 0; border-collapse: separate; border-spacing: 0; font-size: .9em; border: 1px solid var(--border-color); border-radius: var(--radius-lg); overflow: hidden; display: table; }
.md th, .md td { border-bottom: 1px solid var(--border-color); border-right: 1px solid var(--border-color); padding: 8px 12px; text-align: left; }
.md th:last-child, .md td:last-child { border-right: 0; }
.md tr:last-child td { border-bottom: 0; }
.md th { background: var(--code-bg); font-weight: 600; }
.md hr { margin: 2em 0; border: 0; border-top: 1px solid var(--border-color); }
.md img { display: block; max-width: 100%; height: auto; border-radius: var(--radius-md); }
.md a { color: var(--link-color); text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 3px; }

/* ---------------------------------------------------------------- shared patterns */
.page-pad { padding: 28px 32px 60px; max-width: 1180px; margin: 0 auto; }
.field {
  display: flex; align-items: center; gap: 7px; background: var(--code-bg); border: 1px solid var(--border-color);
  border-radius: var(--radius-md); padding: 0 9px; min-width: 0; transition: border-color .12s, box-shadow .12s;
}
.field:focus-within { border-color: var(--accent-color); box-shadow: 0 0 0 3px var(--accent-soft); }
.field input { border: 0; background: none; outline: none; height: 28px; width: 100%; font-size: 13px; min-width: 0; }
.field svg { color: var(--text-faint); flex: none; }
.inline-input { flex: 1; min-width: 0; border: 0; background: none; outline: none; font-size: 15px; padding: 6px 4px; }
.section-label { font-size: 11px; color: var(--text-muted); font-weight: 600; margin: 20px 0 8px; display: flex; align-items: center; justify-content: space-between; }
.icon-accent { color: var(--accent-color); flex: none; }
.compact-input { height: 26px; min-height: 26px; padding: 2px 8px; font-size: 12px; }
@media (max-width: 860px) { .page-pad { padding: 20px 16px 60px; } }

/* plugin pages / widgets rendered inside the hub */
body.hub-plugin { min-height: 100vh; background: var(--card-bg); }
body.hub-widget { background: transparent; min-height: 0; padding: 0; }

/* Overlays keep their own scroll. */
.modal-body, .menu, .palette .list { overscroll-behavior: contain; }

/* A theme change recolours everything in one frame (theme.ts adds the class for two frames). */
.theme-switching, .theme-switching *, .theme-switching *::before, .theme-switching *::after { transition: none !important; }

/* Reduced motion: no travel, no scaling, no pulsing; state still changes, instantly. */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
  .btn:not(:disabled):active { scale: 1; }
}

/* iOS zooms the page when an input's text is under 16px. */
@media (max-width: 860px) and (pointer: coarse) {
  .input, .select, .textarea, .field input, .composer textarea, .palette input, .inline-input { font-size: 16px; }
}
