/*
  Glass — das einzige Erscheinungsbild (FA-20). Werte aus der Verfassung; Hell auf :root,
  Dunkel über data-theme="dark" bzw. data-theme="system" mit dunklem Gerät (FA-21, research E9).
  Keine Schriften, Bilder oder Bibliotheken aus dem Netz (FA-41).
*/

:root {
  --bg: #f2f2f7;
  --surface: #ffffff;
  --text: #1c1c1e;
  --divider: rgba(60, 60, 67, 0.18);
  --accent: #1d6b45;
  --accent-600: #17583a;
  --accent-700: #175c3b;
  --late: #d70015;
  --seg-on: #c7c7cc;
  --grey-btn: #e5e5ea;
  --grey-btn-h: #d8d8de;
  --neutral-200: #e2e2e7;
  --on-accent: #ffffff;

  --muted: color-mix(in srgb, var(--text) 60%, transparent);
  --r-btn: 999px;
  --r-card: 14px;
  --r-sm: 6px;
  --r-in: 10px;
  --r-seg: 10px;
  --r-seg-in: 8px;
  --r-sheet: 22px;
  --font-body: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", system-ui, sans-serif;
  --font-heading: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", system-ui, sans-serif;
  --glass-bg: color-mix(in srgb, var(--surface) 66%, transparent);
  --glass-blur: blur(22px) saturate(180%);
  --side-bg: color-mix(in srgb, var(--surface) 55%, transparent);
  color-scheme: light;
}

:root[data-theme="dark"] {
  --bg: #000000;
  --surface: #1c1c1e;
  --text: #f5f5f7;
  --divider: rgba(120, 120, 128, 0.38);
  --accent: #2f8a5c;
  --accent-600: #38a06b;
  --accent-700: #7cd3a1;
  --late: #ff6961;
  --seg-on: #636366;
  --grey-btn: #2c2c2e;
  --grey-btn-h: #3a3a3c;
  --neutral-200: #101012;
  color-scheme: dark;
}

@media (prefers-color-scheme: dark) {
  :root[data-theme="system"] {
    --bg: #000000;
    --surface: #1c1c1e;
    --text: #f5f5f7;
    --divider: rgba(120, 120, 128, 0.38);
    --accent: #2f8a5c;
    --accent-600: #38a06b;
    --accent-700: #7cd3a1;
    --late: #ff6961;
    --seg-on: #636366;
    --grey-btn: #2c2c2e;
    --grey-btn-h: #3a3a3c;
    --neutral-200: #101012;
    color-scheme: dark;
  }
}

/* Grundlagen */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.4;
}
h1, h2, h3 { font-family: var(--font-heading); font-weight: 700; margin: 0; }
a { color: var(--accent); text-decoration: none; }
button, input, textarea, select { font: inherit; color: inherit; }
input::placeholder, textarea::placeholder { color: var(--muted); }
svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

.muted { color: var(--muted); }
.small { font-size: 13px; }
.note { color: var(--muted); font-size: 13px; margin-top: 24px; }
.empty { color: var(--muted); padding: 14px 16px; background: var(--surface); border-radius: var(--r-card); }
.stack { display: flex; flex-direction: column; gap: 10px; }
.large-title { font-size: 34px; margin: 4px 0 12px; }
.form-error { color: var(--late); margin: 0; font-size: 14px; }
.kicker { display: block; color: var(--accent-700); font-size: 12px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; margin-bottom: 6px; }

/* Eingaben und Knöpfe */
.field {
  width: 100%;
  min-height: 44px;
  padding: 10px 14px;
  background: var(--surface);
  border: 1px solid var(--divider);
  border-radius: var(--r-in);
}
.field:focus { outline: 2px solid var(--accent); outline-offset: 0; }
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 10px 20px;
  border: 0;
  border-radius: var(--r-btn);
  font-weight: 600;
  cursor: pointer;
  text-align: center;
}
.btn-primary { background: var(--accent); color: var(--on-accent); }
.btn-primary:hover { background: var(--accent-600); }
.btn-grey { background: var(--grey-btn); color: var(--text); }
.btn-grey:hover { background: var(--grey-btn-h); }
.icon-btn {
  width: 36px; height: 36px;
  display: grid; place-items: center;
  border: 1px solid var(--divider);
  border-radius: var(--r-btn);
  background: var(--glass-bg);
  color: var(--text);
}
.divider { display: flex; align-items: center; gap: 12px; color: var(--muted); margin: 16px 0; font-size: 13px; }
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: var(--divider); }

/* Segmentschalter */
.segments {
  display: flex;
  gap: 2px;
  padding: 2px;
  background: color-mix(in srgb, var(--text) 7%, transparent);
  border-radius: var(--r-seg);
}
.segments button {
  flex: 1;
  min-height: 36px;
  border: 0;
  background: transparent;
  border-radius: var(--r-seg-in);
  font-weight: 500;
  cursor: pointer;
}
.segments button[aria-pressed="true"] { background: var(--seg-on); font-weight: 700; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12); }

/* Gruppierte Liste */
.group {
  background: var(--surface);
  border-radius: var(--r-card);
  padding: 4px 16px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}
.section-title { font-size: 13px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); margin: 24px 0 8px; font-weight: 600; }

/* Person */
.avatar {
  display: inline-grid; place-items: center;
  width: 36px; height: 36px; flex: none;
  border-radius: 50%;
  background: var(--accent);
  color: var(--on-accent);
  font-size: 13px; font-weight: 700;
}
.avatar-large { width: 52px; height: 52px; font-size: 18px; }
.person-card { display: flex; align-items: center; gap: 14px; padding: 14px 16px; }
.person-main { flex: 1; min-width: 0; }
.person-name { font-weight: 700; overflow-wrap: anywhere; }
.inline-edit { display: flex; gap: 8px; }
.inline-edit .field { flex: 1; min-width: 0; }
.link-list { margin-top: 16px; padding: 0 16px; }
.link-row { display: flex; align-items: center; justify-content: space-between; min-height: 48px; color: var(--text); }
.link-row + .link-row { border-top: 1px solid var(--divider); }
.link-row svg { color: var(--muted); width: 18px; height: 18px; }
.logout { margin-top: 32px; }

/* Anmeldeseiten (FR-002): Bildfläche am Telefon oben, breit links 46 % */
.account { min-height: 100vh; display: flex; flex-direction: column; }
.account-poster {
  flex: 0 0 210px;
  display: flex; flex-direction: column; justify-content: flex-end; gap: 6px;
  padding: 24px;
  margin: 12px 12px 0;
  border-radius: 28px;
  background: linear-gradient(160deg, var(--accent), var(--accent-600));
  color: var(--on-accent);
}
.account-kicker { font-size: 12px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; opacity: 0.85; }
.account-title { font-family: var(--font-heading); font-size: 44px; font-weight: 700; line-height: 1.05; hyphens: manual; }
.account-panel { flex: 1; padding: 24px; max-width: 460px; width: 100%; }
.account-panel h1 { font-size: 28px; margin-bottom: 6px; }
.account-panel .muted { margin: 0 0 16px; }
.account-panel .btn { width: 100%; }

/* Gerüst (FA-22): eine Grenze bei 768 px */
.shell { min-height: 100vh; }
.content { padding: 12px 20px 160px; max-width: 820px; }
.sidebar { display: none; }
.phone-only { display: inline-flex; }
.page-top { display: flex; align-items: center; justify-content: space-between; min-height: 44px; }
.page-top-actions { gap: 8px; align-items: center; }
.date-line { color: var(--muted); font-size: 13px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; }
.avatar-link { color: var(--on-accent); }
.back-link { align-items: center; gap: 2px; min-height: 44px; font-weight: 500; }
.back-link svg { width: 20px; height: 20px; }

.tabbar {
  position: fixed;
  left: 14px; right: 14px; bottom: 20px;
  height: 64px;
  padding: 5px;
  display: flex;
  gap: 2px;
  background: var(--glass-bg);
  -webkit-backdrop-filter: var(--glass-blur);
  backdrop-filter: var(--glass-blur);
  border-radius: 32px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.16), inset 0 0 0 0.5px rgba(255, 255, 255, 0.4);
  z-index: 20;
}
.tab {
  flex: 1;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  margin: 0 2px;
  border-radius: 27px;
  color: var(--text);
  font-size: 11px; font-weight: 600;
}
.tab.active { color: var(--accent); background: color-mix(in srgb, var(--text) 9%, transparent); }

/* Meldung (FR-020): am Telefon über der Tab-Leiste */
.toast {
  position: fixed;
  left: 14px; right: 14px; bottom: 98px;
  display: flex; align-items: center; gap: 12px;
  padding: 12px 16px;
  background: var(--text);
  color: var(--bg);
  border-radius: var(--r-card);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
  z-index: 50;
}
.toast-text { flex: 1; }
.toast-undo { border: 0; background: transparent; color: var(--bg); font-weight: 700; cursor: pointer; padding: 6px; }

/* Blatt (FR-019): am Telefon von unten */
.sheet-backdrop { position: fixed; inset: 0; background: rgba(0, 0, 0, 0.32); z-index: 30; }
.sheet {
  position: fixed;
  left: 0; right: 0; bottom: 0; top: 40px;
  display: flex; flex-direction: column;
  background: var(--bg);
  border-radius: var(--r-sheet) var(--r-sheet) 0 0;
  z-index: 40;
  overflow: hidden;
}
.sheet-head {
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 8px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--divider);
}
.sheet-cancel { justify-self: start; border: 0; background: transparent; color: var(--accent); font-weight: 500; cursor: pointer; min-height: 44px; }
.sheet-title { font-weight: 700; text-align: center; }
.sheet-primary { justify-self: end; min-height: 36px; padding: 6px 16px; }
.sheet-primary:disabled { opacity: 0.45; cursor: default; }
.sheet-body { flex: 1; overflow: auto; padding: 16px; }

@media (min-width: 768px) {
  .toast { left: auto; right: 24px; bottom: 24px; width: 380px; }
  .sheet { left: 50%; top: 50%; right: auto; bottom: auto; width: 560px; max-height: 90%; transform: translate(-50%, -50%); border-radius: var(--r-sheet); }
  .account { flex-direction: row; }
  .account-poster { flex: 0 0 46%; margin: 12px; padding: 48px 56px; }
  .account-title { font-size: 64px; }
  .account-panel { align-self: center; padding: 48px 56px; }

  .shell { display: flex; }
  .tabbar, .phone-only { display: none; }
  .sidebar {
    display: flex; flex-direction: column;
    position: sticky; top: 0;
    width: 260px; height: 100vh; flex: none;
    padding: 20px 12px;
    background: var(--side-bg);
    -webkit-backdrop-filter: var(--glass-blur);
    backdrop-filter: var(--glass-blur);
    border-right: 1px solid var(--divider);
  }
  .sidebar-title { font-family: var(--font-heading); font-weight: 700; font-size: 17px; padding: 4px 10px 16px; }
  .sidebar-nav { display: flex; flex-direction: column; gap: 2px; }
  .nav-item { padding: 8px 10px; border-radius: 8px; color: var(--text); font-weight: 500; }
  .nav-item.active { background: color-mix(in srgb, var(--accent) 12%, transparent); color: var(--accent-700); font-weight: 600; }
  .sidebar-section { display: block; margin-top: 20px; padding: 6px 10px; font-size: 12px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); border-radius: 8px; }
  .sidebar-section.active { color: var(--accent-700); }
  .sidebar-empty { margin: 0; padding: 4px 10px; font-size: 13px; color: var(--muted); }
  .sidebar-person { margin-top: auto; display: flex; align-items: center; gap: 10px; padding: 8px 10px; color: var(--text); border-radius: 10px; }
  .sidebar-person:hover { background: color-mix(in srgb, var(--text) 5%, transparent); }
  .sidebar-person-text { display: flex; flex-direction: column; min-width: 0; }
  .sidebar-person-name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .sidebar-person-sub { font-size: 12px; color: var(--muted); }
  .content { flex: 1; padding: 16px 32px 40px; }
  .large-title { font-size: 30px; }
}

/* ---- 002 Bereiche und Projekte ---- */

/* Kürzel-Marke in der Bereichsfarbe (FA-12): heller Farbton, dunkle Schrift für Kontrast */
.area-badge {
  display: inline-grid; place-items: center;
  min-width: 34px; height: 22px; padding: 0 6px; flex: none;
  border-radius: var(--r-sm);
  background: oklch(0.74 0.14 var(--hue));
  color: #111;
  font-size: 11px; font-weight: 700; letter-spacing: 0.04em;
}
.area-badge-large { min-width: 52px; height: 34px; font-size: 15px; border-radius: 9px; }

.btn-small { min-height: 34px; padding: 6px 14px; font-size: 14px; }
.btn-danger { background: var(--late); color: #fff; }
.btn-danger-text { background: transparent; color: var(--late); padding-left: 0; padding-right: 0; justify-content: flex-start; }
.field-label { font-size: 13px; font-weight: 600; color: var(--muted); margin-top: 6px; }
.field-label-row { display: flex; align-items: baseline; justify-content: space-between; margin-top: 6px; }
.area-code-input { text-transform: uppercase; }
.area-code-input::placeholder { text-transform: none; }

.phone-profile { width: 100%; margin: 4px 0 8px; }

/* Leerer Zustand auf Heute (US1/AC1) */
.empty-state { background: var(--surface); border-radius: var(--r-card); padding: 20px; display: flex; flex-direction: column; gap: 8px; align-items: flex-start; }
.empty-state-title { font-size: 20px; }
.empty-state .muted { margin: 0 0 6px; }

/* Bereiche (FR-010) */
.area-list { padding: 0 16px; }
.area-row { display: flex; align-items: center; gap: 12px; min-height: 60px; color: var(--text); }
.area-row + .area-row { border-top: 1px solid var(--divider); }
.area-row svg { color: var(--muted); width: 18px; height: 18px; margin-left: auto; flex: none; }
.area-row-text { display: flex; flex-direction: column; min-width: 0; }
.area-row-name { font-weight: 600; overflow-wrap: anywhere; }
.add-area { width: 100%; margin-top: 12px; }
.trash-link { color: var(--text); }

/* Bereichsansicht (FR-012, FR-016) */
.area-head {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 20px;
  border-radius: var(--r-sheet);
  background: linear-gradient(140deg, oklch(0.80 0.12 var(--hue)), oklch(0.68 0.14 var(--hue)));
  color: #111;
  margin: 4px 0 14px;
}
.area-head-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.area-head-code { font-family: var(--font-heading); font-size: 34px; font-weight: 800; letter-spacing: 0.02em; line-height: 1.05; }
.area-head-name { font-size: 18px; overflow-wrap: anywhere; }
.area-head-line { font-size: 13px; opacity: 0.75; }
.area-head .icon-btn { background: rgba(255, 255, 255, 0.55); border-color: rgba(0, 0, 0, 0.08); color: #111; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.chip {
  display: inline-flex; align-items: center; gap: 4px;
  min-height: 34px; padding: 6px 14px;
  border: 1px solid var(--divider); border-radius: var(--r-btn);
  background: var(--surface); cursor: pointer; font-weight: 500;
  max-width: 100%; overflow-wrap: anywhere;
}
.chip[aria-pressed="true"] { background: var(--text); color: var(--bg); border-color: var(--text); }
.chip svg { width: 16px; height: 16px; }
.chip-add { color: var(--accent); }

.project-section { margin-bottom: 18px; }
.project-head { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.project-title { flex: 1; min-width: 0; text-align: left; border: 0; background: transparent; padding: 4px 0; font-family: var(--font-heading); font-size: 20px; font-weight: 700; cursor: pointer; overflow-wrap: anywhere; }
.project-head .icon-btn { width: 32px; height: 32px; }
.project-head .icon-btn svg { width: 18px; height: 18px; }

/* Blätter Bereich und Projekt */
.hue-picker { display: flex; flex-wrap: wrap; align-items: center; gap: 16px; }
.hue-presets { display: grid; grid-template-columns: repeat(5, 32px); gap: 10px; }
.hue-dot {
  width: 32px; height: 32px; border-radius: 50%;
  border: 0; cursor: pointer;
  background: oklch(0.74 0.14 var(--hue));
}
.hue-dot[aria-pressed="true"] { box-shadow: 0 0 0 2px var(--bg), 0 0 0 4px var(--text); }
.hue-wheel {
  position: relative; flex: none;
  width: 128px; height: 128px; border-radius: 50%;
  background: conic-gradient(from 0deg,
    oklch(0.74 0.14 0), oklch(0.74 0.14 45), oklch(0.74 0.14 90), oklch(0.74 0.14 135), oklch(0.74 0.14 180),
    oklch(0.74 0.14 225), oklch(0.74 0.14 270), oklch(0.74 0.14 315), oklch(0.74 0.14 360));
  touch-action: none; cursor: pointer;
}
.hue-wheel::before { content: ""; position: absolute; inset: 30px; border-radius: 50%; background: var(--bg); }
.hue-wheel-handle { position: absolute; inset: 0; pointer-events: none; }
.hue-wheel-handle::after {
  content: ""; position: absolute; left: 50%; top: 3px;
  width: 22px; height: 22px; margin-left: -11px; border-radius: 50%;
  background: oklch(0.74 0.14 var(--hue));
  border: 3px solid #fff; box-shadow: 0 1px 4px rgba(0, 0, 0, 0.35);
}
.area-preview { display: flex; align-items: center; gap: 12px; padding: 12px 16px; }
.area-preview-text { min-width: 0; }
.sheet-context { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 0; }
.sheet-context-name { color: var(--text); font-weight: 600; }
.confirm { background: var(--surface); border-radius: var(--r-card); padding: 16px; }
.confirm p { margin: 0 0 12px; }
.confirm-actions { display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; }

/* Papierkorb (US7) */
.trash-list { padding: 0 16px; }
.trash-row { display: flex; gap: 12px; padding: 12px 0; align-items: flex-start; }
.trash-row + .trash-row { border-top: 1px solid var(--divider); }
.trash-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.trash-title { font-weight: 600; overflow-wrap: anywhere; }
.trash-kind { font-weight: 500; }
.trash-actions { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 4px; }

@media (min-width: 768px) {
  .sidebar { overflow-y: auto; }
  .sidebar-heading { margin-top: 20px; padding: 6px 10px; font-size: 12px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }
  .sidebar-profile { margin: 0 4px; }
  .sidebar-areas { display: flex; flex-direction: column; gap: 2px; }
  .side-area { display: flex; align-items: center; gap: 8px; padding: 6px 10px; border-radius: 8px; color: var(--text); font-weight: 500; }
  .side-area.active { background: color-mix(in srgb, var(--accent) 12%, transparent); }
  .side-area-name { min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .side-project { display: block; padding: 4px 10px 4px 52px; border-radius: 8px; color: var(--text); font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .side-project.active { color: var(--accent-700); font-weight: 600; }
  .side-add { display: flex; align-items: center; gap: 6px; padding: 6px 10px; border: 0; background: transparent; color: var(--accent); font-weight: 500; cursor: pointer; text-align: left; }
  .side-add svg { width: 18px; height: 18px; }
}
