/* Zeitzonen – baut auf md-tokens.css auf (Designsystem: ~/Agentic Cowork ai/Design/DESIGN.md).
   Grundfarben, Schrift, Radien nur über Tokens. Funktionsfarben (Orte, Tageszeiten, Karte) bleiben eigene Werte. */
:root {
  --lime: var(--md-lime);
  --lime-ink: var(--md-on-lime);
  --a: #2f7fd0;            /* Andere Zeitzone */
  --a-ink: #1d5c9e;
  --b: var(--md-lime);     /* Bei mir – Martins Farbe */
  --b-ink: var(--md-accent);
  --x: #b06ad8;            /* weitere Orte */
  --bg: var(--md-bg);
  --surface: var(--md-surface);
  --surface-2: var(--md-bg);   /* Eingabefelder und Hover auf Karten */
  --ink: var(--md-ink);
  --muted: var(--md-muted);
  --line: var(--md-line);
  --work: #dfe8a0;
  --edge: #eef1d6;
  --night: #3d4654;
  --night-ink: #c9d0d8;
  --ocean: #d6e2ec;
  --space: var(--md-surface);  /* Fläche rund um die Weltkarte */
  --grid: rgba(80, 110, 140, .18);
  --land: #fbfbf8;
  --border: #b9c2ca;
  --shade: rgba(8, 22, 44, .26);
  --radius: var(--md-radius-m);
  --float: 0 8px 28px rgba(0,0,0,.18);   /* nur für Schwebendes über der Karte (Vorschläge, Tooltips) */
  --size-clock: 2rem;                    /* große Uhrzeit-Eingabe */
  --size-tick: 0.65625rem;               /* Skalen-Beschriftung im Roller und in der Tagesübersicht */
}
@media (prefers-color-scheme: dark) {
  :root {
    --a: #4c9be8; --a-ink: #8cc2f5;
    --work: #4d5320; --edge: #33371f; --night: #11151a; --night-ink: #78818b;
    --ocean: #0d1b29; --grid: rgba(140, 170, 200, .12); --land: #2a3036; --border: #47505a; --shade: rgba(0, 0, 0, .45);
    --float: 0 8px 28px rgba(0,0,0,.45);
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; }
/* Werkzeug: kompakte Grundgröße (Rolle meta), Rest über Tokens */
body { font-size: var(--md-size-meta); line-height: 1.45; }
button, input, select { font: inherit; color: inherit; }
[hidden] { display: none !important; }

/* ---------- Header ---------- */
header {
  position: sticky; top: 0; z-index: 1000;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(12px); -webkit-backdrop-filter: saturate(1.4) blur(12px);
  border-bottom: 1px solid var(--line);
  padding: max(10px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) 10px max(16px, env(safe-area-inset-left));
}
.bar { display: flex; align-items: center; gap: 8px; max-width: 1600px; margin: 0 auto; }
.logo { display: flex; align-items: center; gap: var(--md-space-s); font-weight: 900; font-size: var(--md-size-body); letter-spacing: -.02em; line-height: 1.2; margin-right: auto; min-width: 0; white-space: nowrap; }
.logo img { flex: none; width: 28px; height: 28px; }
.logo small { display: block; font-weight: 500; font-size: var(--md-size-caption); color: var(--muted); letter-spacing: 0; }
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: var(--md-tap); min-width: var(--md-tap); padding: 0 14px; border-radius: var(--md-radius-s);
  border: 2px solid var(--ink); background: transparent; cursor: pointer; font-weight: 700; font-size: var(--md-size-meta); white-space: nowrap;
}
.icon-btn:hover { box-shadow: inset 0 -.3em 0 var(--lime); }
.icon-btn.primary:hover { box-shadow: none; filter: brightness(.94); }
.icon-btn.primary { background: var(--lime); border-color: var(--lime); color: var(--lime-ink); }
.icon-btn svg { width: 18px; height: 18px; }
.live-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--muted); opacity: .5; }
body.live .live-dot { background: var(--lime); opacity: 1; box-shadow: 0 0 0 3px color-mix(in srgb, var(--lime) 35%, transparent); }

/* ---------- Zeit-Roller ---------- */
.roller-wrap { display: flex; align-items: center; gap: 4px; flex: 0 1 440px; min-width: 0; }
.roll-step {
  width: 36px; height: var(--md-tap); flex: none; border: 1px solid var(--line); background: var(--bg); border-radius: var(--md-radius-s);
  cursor: pointer; font-size: 22px; line-height: 1; color: var(--muted); padding: 0 0 3px;
}
.roll-step:hover { background: var(--surface-2); color: var(--ink); }
.roller {
  position: relative; flex: 1 1 auto; min-width: 0; height: var(--md-tap); border-radius: var(--md-radius-s); overflow: hidden;
  border: 1px solid var(--line); background: var(--surface); cursor: ew-resize; touch-action: none; user-select: none; -webkit-user-select: none;
  -webkit-mask-image: linear-gradient(90deg, transparent, #000 14%, #000 86%, transparent);
          mask-image: linear-gradient(90deg, transparent, #000 14%, #000 86%, transparent);
}
.roller.drag { cursor: grabbing; }
.roller-ticks { position: absolute; inset: 0; }
.roller-ticks i { position: absolute; bottom: 0; width: 1px; height: 7px; background: var(--muted); opacity: .5; }
.roller-ticks i.h { height: 13px; opacity: .9; }
.roller-ticks i.day { height: 100%; background: var(--b); opacity: .9; width: 2px; }
.roller-ticks b { position: absolute; top: 3px; transform: translateX(-50%); font-size: var(--size-tick); font-weight: 600; color: var(--muted); font-variant-numeric: tabular-nums; }
.roller-mark { position: absolute; left: 50%; top: 0; bottom: 0; width: 2px; margin-left: -1px; background: var(--b); }
.roller-label {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -62%); padding: 1px 8px; border-radius: 4px;
  background: var(--b); color: var(--lime-ink); font-weight: 800; font-size: var(--md-size-caption); white-space: nowrap; font-variant-numeric: tabular-nums;
  pointer-events: none;
}
.roller-label small { font-weight: 600; opacity: .75; margin-left: 4px; }
@media (max-width: 760px) {
  .bar { flex-wrap: wrap; row-gap: 8px; }
  .roller-wrap { order: 5; flex: 1 1 100%; }
}

/* ---------- Layout ---------- */
.layout {
  display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px;
  max-width: 1600px; margin: 0 auto;
  padding: 16px max(16px, env(safe-area-inset-right)) max(24px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
}
.panel { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
@media (min-width: 980px) {
  .layout { grid-template-columns: 470px minmax(0, 1fr); align-items: start; }
}

.card {
  background: var(--surface); border: 2px solid transparent; border-radius: var(--radius); padding: var(--md-space-l);
}
h2 { font-size: var(--md-size-h3); font-weight: 800; letter-spacing: -.01em; margin: 0; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }
.hint { color: var(--muted); font-size: var(--md-size-caption); font-weight: 500; margin: var(--md-space-s) 0 0; }

/* ---------- Schnelleingabe ---------- */
.quick label { display: block; font-size: var(--md-size-eyebrow); font-weight: 900; color: var(--muted); text-transform: uppercase; letter-spacing: .14em; margin-bottom: var(--md-space-s); }
.quick input, .place-input {
  width: 100%; height: var(--md-tap); padding: 0 var(--md-space-m); border-radius: var(--md-radius-s);
  border: 1px solid var(--line); background: var(--surface-2);
}
.quick input:focus, .place-input:focus { border-color: var(--ink); }
.quick-out { margin: var(--md-space-s) 0 0; font-size: var(--md-size-meta); color: var(--muted); min-height: 1.45em; }
.quick-out b { color: var(--ink); }

/* ---------- Ortskarten ---------- */
.pair { display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; }
.place-card { border-width: 2px; transition: border-color .15s; }
#cardA { border-color: color-mix(in srgb, var(--a) 45%, var(--line)); }
#cardB { border-color: color-mix(in srgb, var(--b) 55%, var(--line)); }
.place-card.target#cardA { border-color: var(--a); box-shadow: 0 0 0 3px color-mix(in srgb, var(--a) 25%, transparent); }
.place-card.target#cardB { border-color: var(--b); box-shadow: 0 0 0 3px color-mix(in srgb, var(--b) 30%, transparent); }
.card-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: var(--md-space-s); }
.tag { font-size: var(--md-size-eyebrow); font-weight: 900; text-transform: uppercase; letter-spacing: .1em; padding: 4px 9px; border-radius: 4px; }
.tag-a { background: var(--a); color: #fff; }
.tag-b { background: var(--b); color: var(--lime-ink); }
.time-row { display: flex; gap: 8px; margin-top: 10px; align-items: stretch; }
.time-input {
  flex: 1 1 auto; min-width: 0; font-size: var(--size-clock); font-weight: 900; letter-spacing: -.03em; font-variant-numeric: tabular-nums;
  border: 1px solid var(--line); border-radius: var(--md-radius-s); background: var(--surface-2); padding: 2px 10px; height: 58px;
}
.date-input { flex: 0 1 150px; min-width: 0; border: 1px solid var(--line); border-radius: var(--md-radius-s); background: var(--surface-2); padding: 0 8px; }
.time-input:focus, .date-input:focus { border-color: var(--ink); }
.meta { margin: var(--md-space-s) 0 0; font-size: var(--md-size-meta); color: var(--muted); }
.meta b { color: var(--ink); font-weight: 600; }
.meta .day { color: var(--a-ink); font-weight: 700; }
.meta .note { display: block; font-size: var(--md-size-caption); margin-top: 2px; }
.swap {
  display: inline-flex; align-items: center; gap: 5px; height: 36px; margin: -6px -6px -6px 0; padding: 0 10px;
  border-radius: var(--md-radius-s); border: 0; background: transparent; cursor: pointer;
  font-size: var(--md-size-caption); font-weight: 700; color: var(--muted);
}
.swap::after { content: ""; position: absolute; inset: -4px; }   /* Tippfläche 44 px */
.swap { position: relative; }
.swap:hover { background: var(--surface-2); color: var(--ink); }
.swap svg { width: 15px; height: 15px; }
.device-line { margin: -2px 4px 0; font-size: var(--md-size-caption); color: var(--muted); }

/* ---------- Suche ---------- */
.search { position: relative; }
.suggest {
  position: absolute; left: 0; right: 0; top: calc(100% + 4px); z-index: 1200; margin: 0; padding: 4px; list-style: none;
  background: var(--bg); border: 1px solid var(--line); border-radius: var(--md-radius-s); box-shadow: var(--float);
  max-height: 320px; overflow-y: auto;
}
.suggest li { display: flex; justify-content: space-between; gap: 10px; align-items: baseline; padding: 9px 10px; border-radius: 6px; cursor: pointer; min-height: var(--md-tap); }
.suggest li[aria-selected="true"], .suggest li:hover { background: var(--surface); }
.suggest .s-name { font-weight: 600; }
.suggest .s-sub { color: var(--muted); font-size: var(--md-size-caption); display: block; font-weight: 400; }
.suggest .s-time { color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; font-size: var(--md-size-caption); }

/* ---------- Weitere Orte ---------- */
.extra-list { list-style: none; margin: 0 0 8px; padding: 0; }
.extra-list:empty { display: none; }
.extra-list li { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.extra-list .x-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--x); flex: none; }
.extra-list .x-name { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.extra-list .x-name small { color: var(--muted); }
.extra-list .x-time { font-weight: 800; font-size: var(--md-size-h3); font-variant-numeric: tabular-nums; white-space: nowrap; }
.extra-list .x-diff { color: var(--muted); font-size: var(--md-size-caption); white-space: nowrap; width: 64px; text-align: right; }
.extra-list .x-del { width: var(--md-tap); height: var(--md-tap); flex: none; border: 0; background: none; color: var(--muted); cursor: pointer; border-radius: var(--md-radius-s); font-size: var(--md-size-h3); }
.extra-list .x-del:hover { background: var(--bg); color: var(--ink); }

/* ---------- Tagesübersicht ---------- */
.legend { font-size: var(--md-size-caption); color: var(--muted); display: inline-flex; gap: 6px; align-items: center; }
.lg { display: inline-block; width: 12px; height: 12px; border-radius: 3px; margin-left: 4px; }
.lg.work { background: var(--work); } .lg.edge { background: var(--edge); border: 1px solid var(--line); } .lg.night { background: var(--night); }
.timeline-scroll { position: relative; overflow-x: auto; margin: 0 -14px; padding: 0 14px 4px; -webkit-overflow-scrolling: touch; }
.timeline { display: grid; grid-template-columns: 92px repeat(24, minmax(26px, 1fr)); gap: 2px; min-width: 720px; font-variant-numeric: tabular-nums; }
.tl-label {
  position: sticky; left: -14px; z-index: 1; background: var(--surface); padding: 0 6px 0 0;
  font-size: var(--md-size-caption); font-weight: 600; display: flex; align-items: center; gap: 6px; min-width: 0;
}
.tl-label span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tl-label i { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.tl-cell {
  height: 34px; border-radius: 5px; display: flex; flex-direction: column; align-items: center; justify-content: center;
  font-size: var(--size-tick); font-weight: 600; line-height: 1.05; cursor: pointer; border: 0; padding: 0; position: relative;
}
.tl-cell small { font-size: .8em; font-weight: 500; opacity: .75; }
.tl-cell.work { background: var(--work); }
.tl-cell.edge { background: var(--edge); }
.tl-cell.night { background: var(--night); color: var(--night-ink); }
.tl-cell.sel { outline: 2px solid var(--ink); outline-offset: -2px; font-weight: 900; }
.tl-cell.newday::before { content: ""; position: absolute; left: -2px; top: 2px; bottom: 2px; width: 2px; background: var(--ink); opacity: .5; }

/* ---------- Karte ---------- */
.map-wrap { min-width: 0; }
.map-tools { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: var(--md-space-s); font-size: var(--md-size-caption); color: var(--muted); }
.seg { display: inline-flex; background: var(--surface); border-radius: var(--md-radius-s); padding: 3px; gap: 2px; }
.seg button { border: 0; background: none; height: 38px; padding: 0 12px; border-radius: 6px; cursor: pointer; font-weight: 700; font-size: var(--md-size-caption); color: var(--muted); }
.seg button[aria-checked="true"].seg-a { background: var(--a); color: #fff; }
.seg button[aria-checked="true"].seg-b { background: var(--b); color: var(--lime-ink); }
.seg button[aria-checked="true"].seg-x { background: var(--x); color: #fff; }
#map {
  height: min(62vh, 440px); min-height: 300px; border-radius: var(--radius); border: 0;
  background: var(--space); cursor: crosshair;
}
.leaflet-container { font: inherit; background: var(--space); }
.leaflet-grab { cursor: crosshair; }
.leaflet-dragging .leaflet-grab { cursor: grabbing; }
.map-legend, .hint, .quick-out { max-width: none; }
.map-legend { font-size: var(--md-size-caption); color: var(--muted); margin: 8px 2px 0; }
.proj { margin-left: auto; }
.proj button[aria-checked="true"] { background: var(--bg); color: var(--ink); }
.full-btn { padding: 0 12px; }
.full-btn .ico-close, .map-wrap.full .full-btn .ico-open { display: none; }
.map-wrap.full .full-btn .ico-close { display: inline; }

/* Desktop: Karte füllt die rechte Spalte bis zum Fensterrand */
@media (min-width: 980px) {
  .map-wrap { position: sticky; top: 80px; height: calc(100vh - 96px); height: calc(100dvh - 96px); display: flex; flex-direction: column; }
  .map-wrap #map { flex: 1 1 auto; height: auto; min-height: 420px; }
}

/* Vollbild (echtes Vollbild oder – z. B. am iPhone – das ganze Browserfenster) */
.map-wrap.full {
  position: fixed; inset: 0; z-index: 1500; height: auto; display: flex; flex-direction: column; background: var(--bg);
  padding: max(10px, env(safe-area-inset-top)) max(10px, env(safe-area-inset-right)) max(10px, env(safe-area-inset-bottom)) max(10px, env(safe-area-inset-left));
}
.map-wrap.full #map { flex: 1 1 auto; height: auto; min-height: 0; }
.map-wrap.full .map-legend { display: none; }
body.map-open { overflow: hidden; }
.leaflet-tooltip.pin {
  background: var(--bg); color: var(--ink); border: 0; border-radius: 6px; padding: 4px 8px;
  box-shadow: var(--float); font-weight: 600; font-size: var(--md-size-caption); font-variant-numeric: tabular-nums;
}
.leaflet-tooltip.pin b { font-size: var(--md-size-meta); font-weight: 800; }
.leaflet-tooltip.pin-a { border-left: 4px solid var(--a); }
.leaflet-tooltip.pin-b { border-left: 4px solid var(--b); }
.leaflet-tooltip.pin-x { border-left: 4px solid var(--x); }
.leaflet-tooltip.hover { font-weight: 500; }
.leaflet-tooltip.pin::before { display: none; }
.leaflet-control-attribution { font-size: var(--size-tick); background: color-mix(in srgb, var(--bg) 80%, transparent) !important; color: var(--muted); }
.leaflet-control-attribution a { color: inherit; text-decoration: none; }
.leaflet-control-attribution a:hover { background: none; text-decoration: underline; }
.leaflet-bar a { background: var(--bg); color: var(--ink); border-color: var(--line); text-decoration: none; }
.leaflet-bar a:hover { background: var(--surface); }
.leaflet-touch .leaflet-bar { border: 0; border-radius: var(--md-radius-s); overflow: hidden; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: max(20px, env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 2000;
  background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: var(--md-radius-s); font-weight: 600; font-size: var(--md-size-meta);
  max-width: calc(100vw - 32px); text-align: center;
}

@media (max-width: 420px) {
  .logo small { display: none; }
  .icon-btn { padding: 0 11px; }
  .date-input { flex-basis: 128px; font-size: var(--md-size-caption); }
}
