/* Mentor Hub — design tokens and base styles.
 * Palette: TH Aschaffenburg colours (navy #152f4e, cyan #009ee0, mist #e8eff7,
 * paper #f8f8f8/#ffffff). Bricolage Grotesque for display type.
 * The one-field login is the hero: an underlined field whose underline
 * switches to the accent colour on focus. Everything else stays quiet. */

@font-face {
  font-family: "Bricolage Grotesque";
  src: url("/fonts/bricolage-grotesque-latin.woff2") format("woff2");
  font-weight: 300 800;
  font-display: swap;
}

:root {
  color-scheme: light dark;
  --paper: #f8f8f8;
  --surface: #ffffff;
  --mist: #e8eff7;
  --ink: #152f4e;
  --ink-soft: #4b6079;
  --line: #c9d5e3;
  --line-strong: #152f4e;
  --accent: #009ee0;

  --marker: #ddd5bd; /* "Neu" badge */

  --marker-ink: #152f4e;
  --danger: #b42318;
  --shadow: 0 1px 2px rgb(21 47 78 / 0.06), 0 12px 32px rgb(21 47 78 / 0.08);
  --radius: 6px;
  --font-display: "Bricolage Grotesque", "Segoe UI", system-ui, sans-serif;
  --font-body: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #0f2238;
    --surface: #152f4e;
    --mist: #1d3b5e;
    --ink: #eef3f8;
    --ink-soft: #a9b8c9;
    --line: #2b4664;
    --line-strong: #eef3f8;
    --accent: #2fb6f0;

    --marker: #ddd5bd; /* "Neu" badge */

    --marker-ink: #152f4e;
    --danger: #ff8a80;
    --shadow: 0 1px 2px rgb(0 0 0 / 0.4), 0 12px 32px rgb(0 0 0 / 0.45);
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html {
  height: 100%;
  -webkit-text-size-adjust: 100%;
  overscroll-behavior: none;
}
body {
  margin: 0;
  min-height: 100%;
  border-top: 3px solid var(--accent);
  font: 16px/1.5 var(--font-body);
  color: var(--ink);
  background: var(--paper);
  padding-inline: 20px;
  overscroll-behavior: none;
}

h1, h2 {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 640;
  letter-spacing: -0.02em;
  line-height: 1.05;
  font-variation-settings: "opsz" 96;
}
h1 { font-size: clamp(2.25rem, 5vw + 1rem, 3rem); }
h2 { font-size: 1.375rem; }
p { margin: 0 0 12px; }
a { color: var(--ink); text-underline-offset: 3px; }
a:hover { color: var(--accent); }
.muted { color: var(--ink-soft); }
.hint { color: var(--ink-soft); font-size: 0.8125rem; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
code { font-size: 0.875em; }

/* ---- Forms ------------------------------------------------------------- */
label { display: block; font-size: 0.8125rem; font-weight: 600; color: var(--ink-soft); margin: 14px 0 6px; }
input {
  width: 100%;
  font: inherit;
  padding: 12px 14px;
  border: 1.5px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
}
input::placeholder { color: var(--ink-soft); opacity: 1; }
input:focus-visible { outline: 2px solid var(--accent); outline-offset: 0; border-color: var(--accent); }

/* The one field: underline only, switches to the accent colour on focus */
.field-hero {
  display: block;
  padding: 14px 4px 12px;
  border: 0;
  border-bottom: 2px solid var(--line-strong);
  border-radius: 0;
  background-color: transparent;
  font-size: 1.25rem;
  letter-spacing: 0.02em;
}
.field-hero:focus {
  outline: none;
  border-bottom-color: var(--accent);
}
.field-hero::placeholder { letter-spacing: 0; }

/* Chrome/Android autofill paints its own yellow field background; force ours */
.field-hero:-webkit-autofill,
.field-hero:-webkit-autofill:focus {
  -webkit-box-shadow: 0 0 0 1000px var(--paper) inset;
  -webkit-text-fill-color: var(--ink);
  transition: background-color 9999s ease-out 0s;
}

/* ---- Buttons ----------------------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font: inherit;
  font-weight: 600;
  padding: 12px 18px;
  min-height: 46px;
  border-radius: var(--radius);
  border: 1.5px solid var(--line-strong);
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  text-decoration: none;
  transition: transform 120ms var(--ease), background-color 160ms var(--ease);
}
.btn:hover { background: color-mix(in srgb, var(--ink) 6%, transparent); }
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn:disabled { opacity: 0.55; cursor: wait; }
.btn-primary { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.btn-primary:hover { background: color-mix(in srgb, var(--ink) 82%, var(--accent)); }
.btn-small { padding: 8px 12px; min-height: 36px; font-size: 0.9rem; }
.btn-text { border-color: transparent; padding-inline: 10px; }

.error { color: var(--danger); font-size: 0.9rem; margin: 12px 0 0; }
.error[hidden] { display: none; }

/* ---- Login (also used by 404) ------------------------------------------ */
.page-login {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  min-height: 100dvh;
  overflow: hidden;
  overscroll-behavior: none;
  touch-action: none;
  display: flex;
  flex-direction: column;
}
.login { flex: 1; display: grid; place-items: center; padding-bottom: 8px; }
.card { width: min(100%, 380px); }
.card h1,
.card > .muted { text-align: center; }
.card h1 { margin-bottom: 6px; }
.card .muted { font-size: 0.95rem; margin-bottom: 24px; }
.card .field-hero { margin-bottom: 20px; }
.card .btn-primary { width: 100%; }

/* Load-in: the block settles into place, one moment, then nothing moves */
@media (prefers-reduced-motion: no-preference) {
  .card > * { animation: rise 520ms var(--ease) both; }
  .card > :nth-child(2) { animation-delay: 50ms; }
  .card > :nth-child(3) { animation-delay: 100ms; }
  .card > :nth-child(4) { animation-delay: 150ms; }
  .card > :nth-child(5) { animation-delay: 200ms; }
  @keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
}

/* ---- Dialogs ----------------------------------------------------------- */
.dialog {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 24px;
  width: min(100% - 32px, 440px);
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow);
}
.dialog::backdrop { background: rgb(22 33 58 / 0.55); }
.dialog h2 { margin-bottom: 8px; }
.actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 22px; }
.actions .btn-primary { width: auto; }
.info-list { margin: 8px 0 0; padding-left: 18px; font-size: 0.875rem; }
.info-list li { margin-bottom: 6px; }

/* Tiny privacy trigger: the only other thing on the login page */
.info-btn {
  position: fixed;
  right: max(14px, env(safe-area-inset-right));
  bottom: max(14px, env(safe-area-inset-bottom));
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 1.5px solid var(--line);
  background: var(--surface);
  color: var(--ink-soft);
  font: 700 13px/1 var(--font-display);
  cursor: pointer;
}
.info-btn:hover { color: var(--accent); border-color: var(--accent); }
.info-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---- App shell (dashboard) --------------------------------------------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 0;
  border-bottom: 1px solid var(--line);
}
.topbar h1 { font-size: 1.375rem; white-space: nowrap; }
.topbar-right { display: flex; align-items: center; gap: 10px; }
.who {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--ink);
  background: var(--mist);
  padding: 4px 8px;
  border-radius: var(--radius);
  white-space: nowrap;
}
.who:empty { display: none; }
.container { max-width: 720px; margin: 0 auto; padding-block: 28px; }
.footer { text-align: center; color: var(--ink-soft); font-size: 0.75rem; padding: 16px 0 max(12px, env(safe-area-inset-bottom)); }

/* ---- Dashboard ---------------------------------------------------------- */
.page-app .container { padding-block: 20px 40px; }
.status { margin: 0 0 16px; padding: 10px 12px; border-radius: var(--radius); background: var(--mist); font-size: 0.9rem; }
.status[hidden] { display: none; }
.status-error { background: color-mix(in srgb, var(--danger) 12%, var(--surface)); color: var(--danger); }
.section { margin-bottom: 32px; }
.section-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 12px; margin-bottom: 12px; }
.admin-shell .card { width: 100%; max-width: none; }
.admin-overview { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); padding: 18px; }
.admin-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px; margin-top: 16px;
}
.admin-panel {
  border: 1px solid var(--line); border-radius: var(--radius); background: var(--mist);
  padding: 16px; min-height: 140px; display: flex; flex-direction: column; justify-content: center;
}
.admin-panel h3 { margin: 0 0 10px; font-size: 1.1rem; }
.admin-panel p { margin: 0; color: var(--ink-soft); }
.admin-card { padding: 18px; }
.admin-form { display: grid; gap: 10px; margin-bottom: 18px; }
.input {
  width: 100%; font: inherit; padding: 12px 14px; border: 1.5px solid var(--line); border-radius: var(--radius);
  background: var(--surface); color: var(--ink);
}
.admin-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.admin-item {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--surface);
}
.admin-item strong { display: block; }
.admin-item .muted { font-size: 0.8125rem; color: var(--ink-soft); }

/* ---- Admin ---------------------------------------------------------------- */
.tabs { position: sticky; top: 0; z-index: 2; background: var(--paper); padding: 12px 0 10px; margin-bottom: 8px; }
.tabs .segment { grid-template-columns: repeat(5, minmax(0, 1fr)); margin: 0; background: var(--surface); }
.tabs .segment-btn { font-size: 0.8125rem; padding: 10px 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tabs .segment-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.panel[hidden] { display: none; }
.sub { margin: 32px 0 12px; }
.toolbar { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 10px; margin-bottom: 14px; }
.toolbar .field { flex: 1 1 150px; min-width: 0; }
.toolbar .field-wide { flex-basis: 220px; }
.toolbar label { margin: 0 0 6px; }
.toolbar .btn { flex: 0 0 auto; }
.check { display: inline-flex; align-items: center; gap: 8px; font-size: 0.9rem; font-weight: 500; color: var(--ink); margin: 0; min-height: 46px; }
.check input { width: auto; margin: 0; accent-color: var(--accent); }
.rows { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--line); }
.rows:empty { border-top: 0; }
.row { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; padding: 10px 4px; border-bottom: 1px solid var(--line); }
.row-main { flex: 1 1 220px; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.row-title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-title .pill { margin-left: 8px; }
.row-meta { font-size: 0.8125rem; color: var(--ink-soft); overflow-wrap: anywhere; }
.row-actions { display: flex; flex-wrap: wrap; gap: 2px; margin-left: auto; }
.pill { display: inline-block; font-size: 0.6875rem; font-weight: 700; letter-spacing: 0.04em; padding: 2px 6px; border-radius: 4px; background: var(--mist); color: var(--ink); vertical-align: 1px; white-space: nowrap; }
.pill-quiet { background: transparent; color: var(--ink-soft); border: 1px solid var(--line); }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 0.8125rem; }
.secret { display: block; margin: 12px 0 4px; padding: 14px; text-align: center; user-select: all; overflow-wrap: anywhere; font: 600 1.25rem/1.3 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; letter-spacing: 0.04em; border: 1.5px dashed var(--line-strong); border-radius: var(--radius); background: var(--mist); }
.rows .empty { border-bottom: 1px solid var(--line); }
.audit-item { align-items: flex-start; }
.badge-good { background: color-mix(in srgb, var(--success) 12%, var(--surface)); color: var(--success); }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.section-head .muted { font-size: 0.875rem; margin: 0; }
.who-btn { cursor: pointer; border: 0; font: inherit; font-size: 0.8125rem; font-weight: 600; max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
.who-btn:hover { background: color-mix(in srgb, var(--accent) 18%, var(--mist)); }
.who-btn::after { content: " ▾"; color: var(--ink-soft); }
/* Phones: title + team choice share the first line; account controls get their own row. */
.page-app .topbar { flex-wrap: wrap; row-gap: 8px; }
.page-app .topbar .who-btn { margin-left: auto; }
.page-app .topbar-right {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px; flex-basis: 100%; justify-content: flex-end; min-width: 0;
}
.who-btn:focus-visible, .group-head:focus-visible, .choice-list:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: var(--radius); }

.groups { display: flex; flex-direction: column; border-top: 1px solid var(--line); }
.group { border-bottom: 1px solid var(--line); }
.group-head {
  display: grid; grid-template-columns: minmax(0, 1fr) auto auto; align-items: center; gap: 12px;
  padding: 14px 4px; cursor: pointer; list-style: none;
}
.group-head::-webkit-details-marker { display: none; }
.group-head::after { content: "+"; width: 1rem; text-align: center; font: 600 1.25rem/1 var(--font-display); color: var(--ink-soft); }
.group[open] > .group-head::after { content: "–"; }
.group-name { font-family: var(--font-display); font-weight: 600; font-size: 1.0625rem; letter-spacing: -0.01em; }
.group-mine .group-name::before { content: ""; display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); margin-right: 8px; vertical-align: 2px; }
.group-meta { display: grid; grid-template-columns: 6.5rem auto; align-items: center; justify-items: end; gap: 8px; min-width: 8.5rem; font-size: 0.8125rem; color: var(--ink-soft); white-space: nowrap; }
.group-count { text-align: right; }
.badge-new { background: var(--marker); color: var(--marker-ink); font-weight: 700; font-size: 0.6875rem; letter-spacing: 0.04em; padding: 2px 6px; border-radius: 4px; }
.group-body { padding: 0 4px 16px; }
.group-tools { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 36px; padding-bottom: 8px; margin-bottom: 8px; border-bottom: 1px solid var(--line); }
.group-tools-label { color: var(--ink-soft); font-size: 0.8125rem; }

.doc-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
/* Phones: manage actions sit in a row under the title so it keeps its width; inline on the right from 640px up. */
.doc { display: flex; flex-wrap: wrap; align-items: stretch; gap: 0 8px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.doc-main { flex: 1; display: flex; align-items: center; gap: 12px; padding: 10px 12px; min-width: 0; text-decoration: none; color: inherit; }
.doc-main:hover .doc-title { color: var(--accent); }
.doc-main:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; border-radius: var(--radius); }
.doc-kind {
  flex: 0 0 44px; height: 44px; display: grid; place-items: center;
  border-radius: var(--radius); background: var(--mist); color: var(--ink);
  font: 700 0.6875rem/1 var(--font-body); letter-spacing: 0.06em;
}
.doc-kind-thumb { overflow: hidden; background: var(--line); }
.doc-thumb { width: 100%; height: 100%; object-fit: cover; }
.doc-text { display: flex; flex-direction: column; min-width: 0; }
.doc-title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.doc-meta { font-size: 0.8125rem; color: var(--ink-soft); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.doc-actions { display: flex; flex: 1 0 100%; justify-content: flex-end; align-items: center; gap: 4px; padding: 0 6px 6px; }
.btn-danger-text { color: var(--danger); }
.btn-danger { background: var(--danger); border-color: var(--danger); color: var(--paper); }
.empty { color: var(--ink-soft); font-size: 0.9rem; padding: 12px 4px; }

.choice-list { display: flex; flex-direction: column; gap: 2px; max-height: 50vh; overflow: auto; margin-top: 12px; }
.choice {
  display: flex; align-items: center; gap: 10px; margin: 0; padding: 8px; border-radius: var(--radius);
  font-size: 1rem; font-weight: 500; color: var(--ink); cursor: pointer;
}
.choice:hover { background: var(--mist); }
.choice:has(input:checked) { background: var(--mist); font-weight: 600; }
.choice input { width: auto; margin: 0; accent-color: var(--accent); border-radius: 50%; outline-offset: 2px; }

@media (min-width: 640px) {
  .page-app .topbar-right { flex-basis: auto; }
  .doc { flex-wrap: nowrap; }
  .doc-actions { flex: 0 0 auto; padding: 0 6px 0 0; }
}

/* ---- Upload sheet -------------------------------------------------------- */
.select { width: 100%; font: inherit; padding: 12px 14px; border: 1.5px solid var(--line); border-radius: var(--radius); background: var(--surface); color: var(--ink); }
.segment { display: grid; grid-template-columns: 1fr 1fr; border: 1.5px solid var(--line); border-radius: var(--radius); overflow: hidden; margin: 16px 0 8px; }
.segment-btn { font: inherit; font-weight: 600; padding: 10px; border: 0; background: transparent; color: var(--ink-soft); cursor: pointer; }
.segment-btn.is-active { background: var(--ink); color: var(--paper); }
.pane[hidden] { display: none; }
input[type="file"] { padding: 10px; }
input[type="file"]::file-selector-button { font: inherit; font-weight: 600; padding: 8px 12px; margin-right: 12px; border: 1.5px solid var(--line-strong); border-radius: var(--radius); background: transparent; color: var(--ink); cursor: pointer; }
.field-label { font-size: 0.8125rem; font-weight: 600; color: var(--ink-soft); margin: 14px 0 6px; }
.targets .choice-list { margin-top: 4px; padding-left: 12px; border-left: 2px solid var(--line); max-height: 30vh; }
.targets .choice-list[hidden] { display: none; }
.progress { width: 100%; height: 6px; margin-top: 12px; accent-color: var(--accent); }
.progress[hidden] { display: none; }
@media (max-width: 480px) {
  .dialog { width: 100%; max-width: none; margin: auto 0 0; border-radius: var(--radius) var(--radius) 0 0; max-height: 92vh; overflow: auto; }
}
