/* ===== Anox Task — design system ===== */
:root {
  --bg: #eef1f6;
  --bg-tint: #e7ebf3;
  --surface: #ffffff;
  --surface-2: #f4f6fa;
  --ink: #151a23;
  --muted: #5f6b7e;
  --faint: #98a2b3;
  --line: #e3e7ef;
  --line-strong: #d3dae4;
  --accent: #4b5bf5;
  --accent-strong: #3b49d6;
  --accent-tint: #eef0ff;
  --todo: #64748b;
  --doing: #f59e0b;
  --done: #22c55e;
  --danger: #e5484d;
  /* dimension colors — persons vs projects, used by tags, filter chips, tokens */
  --person: #2f6df6;
  --project: #4b5bf5;
  --success-ink: #1a8a4f;
  --warn-ink: #a96a00;
  /* geometry */
  --radius-lg: 18px;   /* modals, auth card */
  --radius: 14px;      /* columns, panels, groups */
  --radius-md: 12px;   /* cards, banners */
  --radius-sm: 10px;   /* inputs, buttons */
  --radius-xs: 7px;    /* mini chips, code */
  --pill: 999px;
  --pill-h: 28px;      /* chips, status pills, tokens */
  --pill-h-sm: 22px;   /* badges */
  --dot: 9px;          /* status dots */
  --shadow-sm: 0 1px 2px rgba(20, 30, 60, .06), 0 1px 3px rgba(20, 30, 60, .05);
  --shadow-md: 0 6px 18px rgba(20, 30, 60, .10);
  --shadow-lg: 0 18px 50px rgba(20, 30, 60, .22);
  --shadow-accent: 0 4px 14px color-mix(in srgb, var(--accent) 32%, transparent);
  --ring: 0 0 0 3px var(--accent-tint);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
:root[data-theme="dark"] {
  --bg: #0e131d;
  --bg-tint: #151c29;
  --surface: #1a2231;
  --surface-2: #131a26;
  --ink: #e7ebf3;
  --muted: #9aa6bc;
  --faint: #6b7689;
  --line: #283143;
  --line-strong: #38445b;
  --accent: #6f7cff;
  --accent-strong: #8b95ff;
  --accent-tint: #1f2740;
  --person: #8fb4ff;
  --project: #8b95ff;
  --success-ink: #34d399;
  --warn-ink: #f0b429;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .35);
  --shadow-md: 0 8px 22px rgba(0, 0, 0, .45);
  --shadow-lg: 0 20px 55px rgba(0, 0, 0, .6);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
:root[data-theme="light"] body,
:root:not([data-theme="dark"]) body {
  background: radial-gradient(1200px 600px at 80% -10%, #f3f0ff 0%, transparent 60%), var(--bg);
}
button { font-family: inherit; cursor: pointer; }
input, textarea, select { font-family: inherit; }
::selection { background: var(--accent-tint); }
.grow { flex: 1; }

/* thin, theme-aware scrollbars everywhere (no chunky default bars) */
* { scrollbar-width: thin; scrollbar-color: var(--line-strong) transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--line-strong); border: 2px solid transparent; background-clip: padding-box; border-radius: var(--pill); }
::-webkit-scrollbar-thumb:hover { background: var(--faint); background-clip: padding-box; }

/* shared focus ring for every interactive control */
.btn:focus-visible, .chip:focus-visible, .tabs button:focus-visible,
.langtoggle button:focus-visible, .statuspills button:focus-visible, .mini:focus-visible,
.mic-btn:focus-visible, .send-btn:focus-visible, .col-tabs button:focus-visible,
.admin-nav button:focus-visible, .token button:focus-visible, .card:focus-visible,
.select-btn:focus-visible, .menu-item:focus-visible, .usermenu-btn:focus-visible,
.field input:focus-visible, .field textarea:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px;
}

/* ===== buttons ===== */
.btn {
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--ink);
  border-radius: var(--radius-sm);
  padding: 9px 14px;
  font-size: 14px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: background .15s, border-color .15s, transform .05s, box-shadow .15s;
}
.btn:hover { background: var(--surface-2); }
.btn:active { transform: translateY(1px); }
.btn.primary {
  background: var(--accent); border-color: var(--accent); color: #fff;
  box-shadow: var(--shadow-accent);
}
.btn.primary:hover { background: var(--accent-strong); border-color: var(--accent-strong); }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.ghost:hover { background: rgba(127, 137, 170, .14); }
.btn.danger { color: var(--danger); border-color: transparent; background: transparent; }
.btn.danger:hover { background: rgba(229, 72, 77, .12); }
.btn.sm { padding: 6px 10px; font-size: 12.5px; border-radius: var(--radius-xs); }
.btn.icon { padding: 8px; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.icon-svg { width: 18px; height: 18px; display: block; }

/* ===== avatar (account button + user table) ===== */
.avatar {
  border-radius: 50%; flex: none; display: grid; place-items: center;
  color: #fff; font-weight: 800;
  background: linear-gradient(135deg, var(--accent), var(--accent-strong));
}
.avatar.sm { width: 28px; height: 28px; font-size: 13px; }
.avatar.md { width: 36px; height: 36px; font-size: 15px; }

/* ===== topbar (board + admin share this) ===== */
.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: 12px;
  padding: 11px 18px;
  background: color-mix(in srgb, var(--surface) 82%, transparent);
  backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; letter-spacing: -.02em; font-size: 18px; flex: none; }
.brand img { width: 28px; height: 28px; }
.brand .accent { color: var(--accent); }
.langtoggle { display: inline-flex; border: 1px solid var(--line-strong); border-radius: var(--pill); overflow: hidden; flex: none; }
.langtoggle button { border: 0; background: var(--surface); padding: 7px 12px; font-size: 12.5px; font-weight: 700; color: var(--muted); transition: background .15s, color .15s; }
.langtoggle button:hover:not(.active) { color: var(--ink); }
.langtoggle button.active { background: var(--accent); color: #fff; }

/* header search + new-ticket live in the topbar */
.topbar .searchbox {
  position: relative; display: flex; align-items: center; flex: 1;
  background: var(--surface); border: 1px solid var(--line-strong);
  border-radius: var(--pill); padding: 0 14px; min-width: 0; max-width: 460px;
  transition: border-color .15s, box-shadow .15s;
}
.topbar .searchbox:focus-within { border-color: var(--accent); box-shadow: var(--ring); }
.searchbox input { border: 0; outline: 0; background: transparent; padding: 9px 8px; width: 100%; font-size: 14px; color: var(--ink); }
.searchbox svg { color: var(--faint); flex: none; }
.btn.newticket { flex: none; }
#searchtoggle { display: none; }

/* account menu trigger */
.usermenu-btn {
  display: inline-flex; align-items: center; gap: 8px; flex: none;
  border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink);
  border-radius: var(--pill); padding: 4px 10px 4px 4px; font-weight: 700; font-size: 13.5px;
  transition: background .15s, border-color .15s, box-shadow .15s;
}
.usermenu-btn:hover { background: var(--surface-2); }
.usermenu-btn[aria-expanded="true"] { border-color: var(--accent); box-shadow: var(--ring); }
.usermenu-btn .uname { max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.usermenu-btn .chev { width: 15px; height: 15px; color: var(--faint); flex: none; transition: transform .18s; }
.usermenu-btn[aria-expanded="true"] .chev { transform: rotate(180deg); }

/* ===== popover menu (account menu + custom selects) ===== */
.menu-popover {
  position: fixed; z-index: 60; min-width: 224px; max-height: min(60vh, 420px); overflow: auto;
  padding: 6px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  opacity: 0; transform: translateY(-6px) scale(.98); transform-origin: top right;
  transition: opacity .14s ease, transform .14s ease;
}
.menu-popover.open { opacity: 1; transform: translateY(0) scale(1); }
.menu-item {
  display: flex; align-items: center; gap: 11px; width: 100%; text-align: left;
  border: 0; background: transparent; color: var(--ink); cursor: pointer;
  border-radius: 9px; padding: 10px 11px; font-size: 14px; font-weight: 600;
  transition: background .12s, color .12s;
}
.menu-item:hover, .menu-item:focus-visible { background: var(--surface-2); outline: none; }
.menu-item .mi-icon { display: inline-flex; color: var(--muted); flex: none; }
.menu-item .mi-icon .icon-svg { width: 18px; height: 18px; }
.menu-item .mi-label { flex: 1; }
.menu-item.danger { color: var(--danger); }
.menu-item.danger .mi-icon { color: var(--danger); }
.menu-item.danger:hover { background: rgba(229, 72, 77, .1); }
.menu-item.is-on { color: var(--accent-strong); }
.menu-item .mi-check { width: 16px; height: 16px; color: var(--accent); flex: none; }
.menu-sep { height: 1px; background: var(--line); margin: 5px 8px; }
/* embedded segmented control inside the menu (mobile language switch) */
.menu-seg { display: flex; gap: 4px; padding: 6px 8px; }
.menu-seg button { flex: 1; border: 1px solid var(--line-strong); background: var(--surface); color: var(--muted); border-radius: var(--radius-sm); padding: 8px; font-weight: 700; font-size: 13px; }
.menu-seg button.active { background: var(--accent); border-color: var(--accent); color: #fff; }

/* ===== layout ===== */
.wrap { max-width: 1280px; margin: 0 auto; padding: 18px; }

/* ===== filters ===== */
.filters { display: flex; flex-direction: column; gap: 10px; margin-bottom: 16px; }
.filterrow { display: flex; align-items: flex-start; gap: 12px; }
.filterrow .glabel { flex: none; width: 84px; padding-top: 7px; font-size: 11.5px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; flex: 1; min-width: 0; }
.filter-empty { color: var(--faint); font-size: 13px; padding: 6px 2px; }
/* Clear sits quietly at the right of the first row, only when a filter is active. */
.filters .clear { flex: none; align-self: flex-start; margin-left: auto; color: var(--muted); }
.filters .clear:hover { color: var(--ink); }
.chip {
  display: inline-flex; align-items: center; height: var(--pill-h); padding: 0 12px;
  border: 1px solid var(--line-strong); background: var(--surface); color: var(--muted);
  border-radius: var(--pill); font-size: 13px; font-weight: 600; transition: all .12s;
}
.chip:hover { border-color: var(--accent); color: var(--ink); }
.chip.person { color: var(--person); border-color: color-mix(in srgb, var(--person) 30%, var(--line-strong)); }
.chip.project { color: var(--project); border-color: color-mix(in srgb, var(--project) 30%, var(--line-strong)); }
.chip.person.active { background: var(--person); border-color: var(--person); color: #fff; }
.chip.project.active { background: var(--project); border-color: var(--project); color: #fff; }

/* ===== board ===== */
.board { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; align-items: start; }
.column { background: var(--bg-tint); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px; min-height: 120px; }
.column > .col-head { display: flex; align-items: center; gap: 8px; padding: 4px 6px 10px; font-weight: 700; }
.col-head .dot { width: 10px; height: 10px; border-radius: 50%; }
.col-head .count { margin-left: auto; font-size: 12px; color: var(--muted); background: var(--surface); border: 1px solid var(--line); border-radius: var(--pill); padding: 1px 9px; font-weight: 700; }
.col-clear { display: inline-flex; align-items: center; justify-content: center; width: 24px; height: 24px; padding: 0; border: 0; background: transparent; color: var(--muted); border-radius: var(--radius-xs); cursor: pointer; transition: color .12s, background .12s; }
.col-clear .icon-svg { width: 15px; height: 15px; }
.col-clear:hover, .col-clear:focus-visible { color: var(--danger); background: rgba(229, 72, 77, .12); }
.col-todo .dot { background: var(--todo); }
.col-doing .dot { background: var(--doing); }
.col-done .dot { background: var(--done); }
.cards { display: flex; flex-direction: column; gap: 9px; min-height: 44px; }
.col-empty { color: var(--faint); font-size: 13px; text-align: center; padding: 16px 6px; border: 1px dashed var(--line-strong); border-radius: var(--radius-sm); }

/* ===== card ===== */
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-md);
  padding: 11px 12px; box-shadow: var(--shadow-sm); position: relative;
  transition: box-shadow .15s, border-color .15s; cursor: pointer;
}
.card:hover { box-shadow: var(--shadow-md); border-color: var(--line-strong); }
.card:focus-visible { border-color: var(--accent); }
.card .title {
  font-weight: 700; font-size: 14.5px; letter-spacing: -.01em; padding-right: 22px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.card-del {
  position: absolute; top: 6px; right: 6px; width: 24px; height: 24px; padding: 0;
  display: inline-flex; align-items: center; justify-content: center;
  border: 0; background: transparent; color: var(--faint); border-radius: var(--radius-xs);
  cursor: pointer; opacity: 0; transition: opacity .12s, color .12s, background .12s;
}
.card-del .icon-svg { width: 15px; height: 15px; }
.card:hover .card-del, .card:focus-within .card-del { opacity: 1; }
.card-del:hover, .card-del:focus-visible { opacity: 1; color: var(--danger); background: rgba(229, 72, 77, .12); }
.card .preview {
  color: var(--muted); font-size: 13px; line-height: 1.45; margin-top: 4px;
  display: -webkit-box; -webkit-line-clamp: 2; line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.card .tags { display: flex; gap: 5px; margin-top: 9px; overflow: hidden; max-height: 23px; flex-wrap: wrap; }
.tag { font-size: 11.5px; font-weight: 600; border-radius: var(--pill); padding: 2px 9px; white-space: nowrap; }
.tag.person { background: color-mix(in srgb, var(--person) 15%, var(--surface)); color: var(--person); }
.tag.project { background: color-mix(in srgb, var(--project) 15%, var(--surface)); color: var(--accent-strong); }
.card .cardbar { display: flex; align-items: center; gap: 4px; margin-top: 9px; padding-top: 8px; border-top: 1px solid var(--line); opacity: 0; transition: opacity .12s; }
.card:hover .cardbar, .card:focus-within .cardbar { opacity: 1; }
.mini { border: 1px solid var(--line); background: var(--surface); border-radius: var(--radius-xs); padding: 4px 9px; color: var(--muted); display: inline-flex; align-items: center; }
.mini .icon-svg { width: 15px; height: 15px; }
.mini:hover:not(:disabled) { background: var(--surface-2); color: var(--ink); border-color: var(--line-strong); }
.mini:disabled { opacity: .35; cursor: not-allowed; }

/* drag: the clone must follow the cursor — never set `transform` here (Sortable
   uses transform:translate on the fallback clone to track the pointer). */
.sortable-ghost { opacity: .35; }
.sortable-drag { box-shadow: var(--shadow-lg); opacity: .98; cursor: grabbing; }

/* ===== auth / pending ===== */
.center-screen { min-height: 100dvh; display: grid; place-items: center; padding: 20px; }
.auth-card { width: 100%; max-width: 400px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); box-shadow: var(--shadow-md); padding: 26px; }
.auth-card .brand { justify-content: center; font-size: 22px; margin-bottom: 4px; }
.auth-sub { text-align: center; color: var(--muted); font-size: 13.5px; margin-bottom: 18px; }
.tabs { display: flex; background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--pill); padding: 4px; margin-bottom: 18px; }
.tabs button { flex: 1; border: 0; background: transparent; padding: 8px; border-radius: var(--pill); font-weight: 700; color: var(--muted); font-size: 14px; }
.tabs button.active { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-sm); }
.auth-card .btn.primary { width: 100%; justify-content: center; margin-top: 6px; padding: 12px; }
.form-msg { font-size: 13px; margin-top: 10px; min-height: 18px; text-align: center; }
.form-msg.err { color: var(--danger); }
.form-msg.ok { color: var(--success-ink); }
.pending-icon { font-size: 40px; text-align: center; }

/* ===== form fields (shared input recipe) ===== */
.field { margin-bottom: 12px; }
.field label { display: block; font-size: 12.5px; font-weight: 700; color: var(--muted); margin-bottom: 5px; }
.field input, .field textarea, .field select, .select-btn, .useredit input, .token-input, #sysprompt {
  width: 100%; border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
  background: var(--surface-2); color: var(--ink);
}
.field input, .field textarea, .field select { padding: 11px 12px; font-size: 14.5px; }
.field textarea { resize: vertical; line-height: 1.5; }
.field input:focus, .field textarea:focus, .field select:focus,
.useredit input:focus, #sysprompt:focus { outline: 2px solid var(--accent); outline-offset: 0; background: var(--surface); }

/* native select → custom chevron, roomy */
.field select { appearance: none; -webkit-appearance: none; padding-right: 38px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2398a2b3' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center; }

/* custom select (admin LLM models) — opens the app's own roomy popover */
.select-btn { display: inline-flex; align-items: center; gap: 10px; padding: 11px 12px; font-size: 14px; font-weight: 600; font-family: var(--mono); color: var(--ink); text-align: left; transition: border-color .15s, box-shadow .15s; }
.select-btn .sb-val { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.select-btn .chev { width: 16px; height: 16px; color: var(--faint); flex: none; }
.select-btn:hover { background: var(--surface); }
.select-btn[aria-expanded="true"] { border-color: var(--accent); box-shadow: var(--ring); }
.select-pop .menu-item { font-family: var(--mono); font-size: 13px; }
.select-pop .menu-item .mi-label { white-space: normal; word-break: break-all; }

/* ===== modal ===== */
.modal-backdrop { position: fixed; inset: 0; background: rgba(10, 14, 24, .5); backdrop-filter: blur(2px); display: grid; place-items: center; z-index: 50; padding: 16px; }
.modal { width: 100%; max-width: 560px; max-height: 90dvh; overflow: auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); padding: 22px; }
.modal.wide { max-width: 680px; }
.modal h2 { margin: 0 0 4px; font-size: 19px; letter-spacing: -.01em; }
.modal .sub, .admin-panel .sub { color: var(--muted); font-size: 13px; margin-bottom: 16px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; }
.section-title { font-size: 12px; font-weight: 800; text-transform: uppercase; letter-spacing: .06em; color: var(--faint); margin: 18px 0 8px; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.actions-end { display: flex; justify-content: flex-end; margin-top: 10px; }

/* ===== ticket sheet (compose + detail): roomy on desktop, fullscreen on mobile ===== */
.modal.sheet {
  max-width: 920px; width: 100%; max-height: 92dvh;
  padding: 0; display: flex; flex-direction: column; overflow: hidden;
}
.sheet-head {
  display: flex; align-items: center; gap: 10px; flex: none;
  padding: 14px 20px; border-bottom: 1px solid var(--line); background: var(--surface);
}
.sheet-head h2 { margin: 0; font-size: 19px; letter-spacing: -.01em; }
.sheet-head .detail-title { flex: 1; margin: 0; }
.sheet-body { flex: 1; min-height: 0; overflow: auto; padding: 20px; }
.sheet-foot {
  display: flex; align-items: center; gap: 10px; flex: none;
  padding: 13px 20px; border-top: 1px solid var(--line); background: var(--surface);
}
/* Single-column, content-first sheet: the body reads at a comfortable width
   (no squeezed column next to a half-empty rail). */
.sheet-main { width: 100%; max-width: 760px; margin: 0 auto; min-width: 0; }
/* Personen & Projekte as a compact side-by-side meta row (not a tall rail);
   minmax(0,…) lets the token editors wrap instead of overflowing. */
.sheet-side { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 12px; margin-top: 18px; }
.meta-group { min-width: 0; background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; }
.field-label { font-size: 12px; font-weight: 800; text-transform: uppercase; letter-spacing: .06em; color: var(--faint); margin: 0 0 9px; }

/* editable title that still reads like a heading */
.detail-title {
  width: 100%; border: 1px solid transparent; border-radius: var(--radius-sm);
  padding: 7px 10px; font-size: 20px; font-weight: 800; letter-spacing: -.01em;
  background: transparent; color: var(--ink); font-family: inherit;
}
.detail-title:hover { background: var(--surface-2); }
.detail-title:focus { outline: 2px solid var(--accent); background: var(--surface); }

/* status pills */
.statuspills { display: inline-flex; flex-wrap: wrap; gap: 6px; }
.statuspills button { display: inline-flex; align-items: center; gap: 6px; height: var(--pill-h); border: 1px solid var(--line-strong); background: var(--surface); border-radius: var(--pill); padding: 0 13px; font-size: 12.5px; font-weight: 700; color: var(--muted); }
.statuspills button .dot { width: var(--dot); height: var(--dot); border-radius: 50%; }
.statuspills button:hover { color: var(--ink); }
.statuspills button.active { color: var(--ink); border-color: var(--ink); background: var(--surface-2); }

/* content view + inline editor (shared by compose preview + detail) */
.detail-content { margin-top: 8px; }
.content-edit { width: 100%; min-height: 220px; border: 1px solid var(--line-strong); border-radius: var(--radius-sm); padding: 12px; font-size: 14.5px; line-height: 1.6; background: var(--surface-2); color: var(--ink); resize: vertical; }
.content-edit:focus { outline: 2px solid var(--accent); background: var(--surface); }

/* prompt bar — unified input for compose + re-prompt, with mic/send affordances */
.prompt-bar {
  display: flex; align-items: flex-end; gap: 8px;
  border: 1px solid var(--line-strong); border-radius: var(--radius); padding: 8px;
  background: var(--surface-2); transition: border-color .15s, background .15s;
}
.prompt-bar:focus-within { border-color: var(--accent); background: var(--surface); }
.prompt-bar textarea {
  flex: 1; border: 0; outline: 0; background: transparent; resize: none;
  font-size: 14.5px; line-height: 1.5; color: var(--ink); padding: 6px; min-height: 26px; max-height: 200px;
}
/* compose: roomy auto-growing textarea; mic floats top-right (out of the way) */
.prompt-bar.tall { position: relative; align-items: stretch; padding: 12px; }
.prompt-bar.tall textarea { max-height: none; min-height: 200px; padding-right: 38px; }
.prompt-bar.tall .mic-btn { position: absolute; top: 8px; right: 8px; }
.mic-btn, .send-btn {
  flex: none; width: 38px; height: 38px; border-radius: var(--radius-sm);
  display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid var(--line-strong); background: var(--surface); color: var(--muted);
  transition: background .15s, color .15s, border-color .15s;
}
.mic-btn:hover { color: var(--ink); background: var(--surface-2); }
.send-btn { background: var(--accent); border-color: var(--accent); color: #fff; }
.send-btn:hover { background: var(--accent-strong); border-color: var(--accent-strong); }
.mic-btn .icon-svg, .send-btn .icon-svg { width: 18px; height: 18px; }
.mic-btn.recording { background: var(--danger); border-color: var(--danger); color: #fff; animation: pulse 1.2s infinite; }
.mic-btn:disabled, .send-btn:disabled { opacity: .6; cursor: default; }
.prompt-hint { font-size: 12px; color: var(--faint); margin: 8px 2px 0; line-height: 1.45; }
@keyframes pulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(229, 72, 77, .5); } 50% { box-shadow: 0 0 0 8px rgba(229, 72, 77, 0); } }

/* draft / preview banner */
.draft-banner {
  display: flex; align-items: center; gap: 9px; margin-top: 14px;
  background: var(--accent-tint); color: var(--accent-strong);
  border: 1px solid var(--line); border-radius: var(--radius-md); padding: 9px 12px; font-size: 13px; font-weight: 600;
}
.draft-banner .icon-svg { width: 18px; height: 18px; flex: none; }
.draft-banner.warn { background: color-mix(in srgb, var(--doing) 14%, var(--surface)); color: var(--warn-ink); border-color: color-mix(in srgb, var(--doing) 30%, var(--line)); }

/* token editor */
.token-input { display: flex; flex-wrap: wrap; gap: 6px; padding: 7px; background: var(--surface); transition: border-color .15s, box-shadow .15s; }
.token-input:focus-within { border-color: var(--accent); box-shadow: var(--ring); }
.token-input input { border: 0; outline: 0; background: transparent; flex: 1; min-width: 60px; padding: 4px; font-size: 14px; color: var(--ink); }
.token { display: inline-flex; align-items: center; gap: 4px; height: var(--pill-h); background: var(--accent-tint); color: var(--accent-strong); border-radius: var(--pill); padding: 0 6px 0 11px; font-size: 12.5px; font-weight: 700; }
.token button { border: 0; background: transparent; color: inherit; line-height: 0; cursor: pointer; padding: 4px; border-radius: 50%; opacity: .7; display: inline-flex; }
.token button .icon-svg { width: 13px; height: 13px; }
.token button:hover { opacity: 1; background: color-mix(in srgb, var(--accent) 18%, transparent); }

/* ===== admin view ===== */
.admin-badge {
  display: inline-flex; align-items: center; gap: 7px; flex: none;
  background: var(--accent-tint); color: var(--accent-strong);
  border: 1px solid color-mix(in srgb, var(--accent) 30%, var(--line)); border-radius: var(--pill); padding: 5px 12px 5px 10px;
  font-size: 12.5px; font-weight: 800; letter-spacing: .01em;
}
.admin-badge .icon-svg { width: 16px; height: 16px; }
.btn.adminback .icon-svg { width: 17px; height: 17px; }
.admin-wrap { max-width: 1320px; }
.admin-layout { display: grid; grid-template-columns: 244px 1fr; gap: 20px; align-items: start; }
.admin-nav { display: flex; flex-direction: column; gap: 4px; position: sticky; top: 80px; }
.admin-nav button {
  display: flex; align-items: center; gap: 11px;
  text-align: left; border: 1px solid transparent; background: transparent; color: var(--muted);
  border-radius: var(--radius-sm); padding: 11px 13px; font-weight: 700; font-size: 14px;
  transition: background .12s, color .12s; min-width: 0;
}
.admin-nav button .icon-svg { width: 18px; height: 18px; opacity: .9; flex: none; }
.admin-nav button .lbl { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.admin-nav button:hover { background: var(--surface-2); color: var(--ink); }
.admin-nav button.active { background: var(--accent-tint); color: var(--accent-strong); border-color: color-mix(in srgb, var(--accent) 22%, var(--line)); }
.admin-panel {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow-sm); padding: 22px; min-height: 360px;
}
.panel-head { margin-bottom: 16px; }
.panel-head .section-title { margin: 0; }
.panel-head .sub { margin: 5px 0 0; }
.panel-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 16px; }
#sysprompt {
  display: block; height: clamp(320px, calc(100dvh - 280px), 1400px);
  font-family: var(--mono); font-size: 13px; line-height: 1.55; padding: 14px; resize: vertical;
}

/* user management — aligned grid table */
.usertable { display: flex; flex-direction: column; }
.usertable .uhead, .userrow { display: grid; grid-template-columns: minmax(0, 1fr) 132px auto; gap: 14px; align-items: center; }
.usertable .uhead { padding: 0 6px 8px; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--faint); }
.userrow { padding: 10px 6px; border-top: 1px solid var(--line); border-radius: var(--radius-sm); }
.userrow:hover { background: var(--surface-2); }
.uidentity { display: flex; align-items: center; gap: 11px; min-width: 0; }
.uidentity .umeta { min-width: 0; }
.userrow .uname { font-weight: 700; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.userrow .umail { color: var(--muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.uactions { display: flex; gap: 6px; justify-content: flex-end; flex-wrap: wrap; }
.userrow.editing { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.useredit { display: flex; flex-wrap: wrap; gap: 8px; flex: 1; align-items: center; }
.useredit input { flex: 1; min-width: 140px; padding: 8px 10px; font-size: 13.5px; }

/* uniform status badge */
.badge {
  display: inline-flex; align-items: center; gap: 6px; height: var(--pill-h-sm);
  padding: 0 10px 0 9px; border-radius: var(--pill); border: 1px solid;
  font-size: 11.5px; font-weight: 700; line-height: 1; letter-spacing: .01em;
}
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.pending { color: var(--warn-ink); background: color-mix(in srgb, var(--doing) 13%, var(--surface)); border-color: color-mix(in srgb, var(--doing) 32%, var(--line)); }
.badge.approved { color: var(--success-ink); background: color-mix(in srgb, var(--done) 13%, var(--surface)); border-color: color-mix(in srgb, var(--done) 32%, var(--line)); }
.badge.admin { color: var(--accent-strong); background: var(--accent-tint); border-color: color-mix(in srgb, var(--accent) 28%, var(--line)); }

/* ===== markdown ===== */
.md { font-size: 14.5px; line-height: 1.6; color: var(--ink); word-break: break-word; }
.md > :first-child { margin-top: 0; }
.md > :last-child { margin-bottom: 0; }
.md h1, .md h2, .md h3 { margin: .7em 0 .3em; line-height: 1.25; }
.md h1 { font-size: 1.25em; } .md h2 { font-size: 1.15em; } .md h3 { font-size: 1.04em; }
.md p { margin: .5em 0; }
.md ul, .md ol { margin: .4em 0; padding-left: 1.4em; }
.md li { margin: .2em 0; }
.md code { background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius-xs); padding: 1px 5px; font-size: .9em; font-family: var(--mono); }
.md pre { background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 12px; overflow: auto; }
.md pre code { background: none; border: 0; padding: 0; }
.md blockquote { border-left: 3px solid var(--line-strong); margin: .5em 0; padding: .1em .9em; color: var(--muted); }
.md a { color: var(--accent); }
.md strong { font-weight: 700; }

/* ===== mobile column tabs ===== */
.col-tabs { display: none; gap: 6px; margin-bottom: 12px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--pill); padding: 5px; box-shadow: var(--shadow-sm); }
.col-tabs button { flex: 1; border: 0; background: transparent; padding: 9px; border-radius: var(--pill); font-weight: 700; font-size: 13.5px; color: var(--muted); display: inline-flex; align-items: center; justify-content: center; gap: 7px; }
.col-tabs button .dot { width: var(--dot); height: var(--dot); border-radius: 50%; }
.col-tabs button.active { background: var(--surface-2); color: var(--ink); box-shadow: var(--shadow-sm); }

/* ===== toast ===== */
#toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(20px); z-index: 100; opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; }
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
#toast .toast-inner { background: var(--ink); color: var(--surface); padding: 11px 18px; border-radius: var(--pill); font-size: 13.5px; font-weight: 600; box-shadow: var(--shadow-lg); display: inline-flex; align-items: center; }
#toast.err .toast-inner { background: var(--danger); color: #fff; }
.toast-undo { pointer-events: auto; margin-left: 14px; padding: 0; background: transparent; border: 0; color: inherit; font: inherit; font-weight: 800; text-decoration: underline; text-underline-offset: 2px; cursor: pointer; }
.toast-undo:hover { opacity: .8; }

.spinner { width: 16px; height: 16px; border: 2px solid rgba(127, 137, 170, .35); border-top-color: var(--accent); border-radius: 50%; animation: spin .7s linear infinite; }
.btn.primary .spinner { border-color: rgba(255, 255, 255, .4); border-top-color: #fff; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ===== responsive ===== */
@media (max-width: 860px) {
  .wrap { padding: 12px; }
  .col-tabs { display: flex; }
  .board { grid-template-columns: 1fr; gap: 0; }
  .column { display: none; background: transparent; border: 0; padding: 0; }
  .column.active { display: block; }
  .topbar { gap: 8px; padding: 9px 12px; flex-wrap: wrap; }
  .topbar .searchbox { max-width: none; }
  .filterrow .glabel { width: 72px; }
  /* always-visible move arrows where there is no hover / no drag */
  .card .cardbar { opacity: 1; }
  /* admin nav: one clean full-width row of equal thirds */
  .admin-layout { grid-template-columns: 1fr; }
  .admin-nav { flex-direction: row; position: static; }
  .admin-nav button { flex: 1 1 0; justify-content: center; }
  #sysprompt { height: clamp(280px, calc(100dvh - 320px), 900px); }
  /* 16px inputs prevent iOS focus-zoom */
  .field input, .field textarea, .field select, .prompt-bar textarea, .content-edit,
  .searchbox input, .token-input input, .useredit input, #sysprompt, .select-btn { font-size: 16px; }
  /* roomier touch targets */
  .statuspills { width: 100%; }
  .statuspills button { flex: 1; justify-content: center; height: 42px; }
  .col-tabs button { min-height: 42px; }
  .mini { padding: 7px 11px; }
}
/* coarse pointer: reveal card move arrows + delete affordance even without :hover */
@media (pointer: coarse) { .card .cardbar, .card-del { opacity: 1; } }

/* phone: header collapses search to an icon; theme + language fold into the account menu */
@media (max-width: 640px) {
  .topbar .langtoggle, .topbar #themebtn { display: none; }
  #searchtoggle { display: inline-flex; }
  .topbar .searchbox { display: none; order: 10; flex-basis: 100%; }
  .topbar.searching .searchbox { display: flex; }
  .topbar.searching #searchtoggle { border-color: var(--accent); color: var(--accent); }
  .btn.newticket .lbl { display: none; }
  .btn.newticket { padding: 8px; }
  .admin-badge .lbl, .btn.adminback .lbl { display: none; }
  .admin-badge { padding: 5px 9px; }
  /* admin section switch: a horizontal scroll strip keeps full labels + one-tap access */
  .admin-nav { flex-wrap: nowrap; overflow-x: auto; gap: 6px; margin: 0 -2px 4px; padding: 2px; }
  .admin-nav button { flex: 0 0 auto; }
  /* sheets go fullscreen */
  .modal-backdrop.sheet-back { padding: 0; }
  .modal.sheet { max-width: none; width: 100vw; height: 100dvh; max-height: none; border-radius: 0; border: 0; }
  .sheet-head, .sheet-foot { padding-left: 16px; padding-right: 16px; }
  .sheet-head .btn.icon { padding: 11px; }
  .sheet-body { padding: 16px; }
  .sheet-side { grid-template-columns: 1fr; }
  .sheet-foot { gap: 8px; }
  .sheet-foot .btn { padding: 11px 13px; }
  .content-edit { min-height: 46dvh; }
  /* user list becomes a stacked card per user */
  .usertable .uhead { display: none; }
  .userrow { grid-template-columns: 1fr; gap: 9px; padding: 12px 6px; }
  .uactions { justify-content: flex-start; }
}
