/* Cockpit Frontend — CSS Grid, themeParams Dark/Light, Ampel-Farben */
/* Variablen werden per JS aus themeParams gesetzt (tg-adapter + app.js) */

:root {
  /* Telegram themeParams — werden per JS überschrieben */
  --tg-bg:        #1c1c1e;
  --tg-text:      #ffffff;
  --tg-hint:      #8e8e93;
  --tg-link:      #0a84ff;
  --tg-btn:       #0a84ff;
  --tg-btn-text:  #ffffff;
  --tg-secondary: #2c2c2e;

  /* Ampel-Farben (Dot + Kachel-BG) */
  --status-green:     #30d158;
  --status-green-bg:  #0d2b17;
  --status-yellow:    #ffd60a;
  --status-yellow-bg: #2b2200;
  --status-red:       #ff453a;
  --status-red-bg:    #2b0a08;
  --status-stale:     #636366;
  --status-stale-bg:  #1c1c1e;

  --radius: 12px;
  --gap: 10px;

  /* iOS Spring Easing */
  --spring-open:    cubic-bezier(0.32, 0.72, 0, 1);
  --spring-close:   cubic-bezier(0.4, 0, 1, 1);
  --spring-bounce:  cubic-bezier(0.34, 1.56, 0.64, 1);
  --ease-std:       cubic-bezier(0.4, 0, 0.2, 1);

  /* iOS System Tokens */
  --ios-sep:        rgba(84, 84, 88, 0.65);
  --ios-fill:       rgba(120, 120, 128, 0.18);
  --ios-glass:      rgba(44, 44, 46, 0.72);
  --ios-glass-lt:   rgba(242, 242, 247, 0.82);
  --transition-btn: transform 0.12s var(--ease-std), opacity 0.12s var(--ease-std);
}

/* Light-Mode Overrides */
[data-scheme="light"] {
  --status-green-bg:  #d4f5e0;
  --status-yellow-bg: #fff8cc;
  --status-red-bg:    #fde0de;
  --status-stale-bg:  #ebebeb;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--tg-bg);
  color: var(--tg-text);
  font-size: 15px;
  line-height: 1.4;
  -webkit-text-size-adjust: 100%;
}

/* Safe-area padding — iOS WKWebView nach expand() */
body {
  padding: env(safe-area-inset-top, 0)
           env(safe-area-inset-right, 0)
           env(safe-area-inset-bottom, 0)
           env(safe-area-inset-left, 0);
}

/* ── Layout ── */

#app {
  display: flex;
  flex-direction: column;
  min-height: 100%;
  max-width: 600px;
  margin: 0 auto;
}

/* ── Offline/Stale-Banner ── */

#banner {
  display: none;
  background: var(--status-yellow-bg);
  color: var(--status-yellow);
  border-bottom: 1px solid var(--status-yellow);
  padding: 8px 14px;
  font-size: 13px;
  text-align: center;
}
#banner.visible { display: block; }

/* ── Header ── */

/* Verbindungs-Indikator (Step 7 Bulletproof) */
.conn-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin: 0 6px;
  flex-shrink: 0;
  transition: background-color 0.4s ease;
}
.conn-dot.online  { background: #4caf50; box-shadow: 0 0 4px #4caf5088; }
.conn-dot.offline { background: #f44336; animation: pulse-red 1.4s infinite; }

@keyframes pulse-red {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.4; }
}

#header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  background: var(--ios-glass);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  border-bottom: 0.5px solid var(--ios-sep);
  position: sticky;
  top: 0;
  z-index: 10;
}
[data-scheme="light"] #header { background: var(--ios-glass-lt); }

#header h1 {
  font-size: 17px;
  font-weight: 600;
}

#btn-refresh {
  background: var(--tg-btn);
  color: var(--tg-btn-text);
  border: none;
  border-radius: 8px;
  padding: 6px 14px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  touch-action: manipulation;
}
#btn-refresh:active { opacity: 0.7; }

/* ── Grid-Bereich ── */

#grid-container {
  flex: 1;
  padding: 14px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.grid-section-title {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--tg-hint);
  margin: 14px 0 8px;
}
.grid-section-title:first-child { margin-top: 0; }

/* CSS Grid — 2 Spalten, mobil-first */
.grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--gap);
}

/* Kachel */
.card {
  border-radius: var(--radius);
  padding: 12px;
  border: 1px solid rgba(255,255,255,0.06);
  transition: opacity 0.15s;
  min-height: 72px;
}
.card.clickable {
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.card.clickable:active { opacity: 0.75; }
.card:focus-visible { outline: 2px solid var(--tg-link); outline-offset: 2px; }

.card-header {
  display: flex;
  align-items: center;
  gap: 7px;
}

/* Ampel-Dot */
.dot {
  flex-shrink: 0;
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

.card-label {
  font-size: 14px;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.card-section {
  font-size: 11px;
  color: var(--tg-hint);
  margin-top: 4px;
}

.card-summary {
  font-size: 12px;
  color: var(--tg-hint);
  margin-top: 5px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Loading / Error / Empty */
.loading, .grid-error, .empty {
  grid-column: 1 / -1;
  padding: 32px 0;
  text-align: center;
  color: var(--tg-hint);
  font-size: 14px;
}
.grid-error { color: var(--status-red); }

/* ── Detail-Overlay ── */

#detail-overlay {
  display: flex;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0);
  z-index: 100;
  align-items: flex-end;
  visibility: hidden;
  pointer-events: none;
  transition:
    background 0.28s var(--ease-std),
    visibility 0s linear 0.28s;
}
#detail-overlay.visible {
  background: rgba(0,0,0,0.6);
  visibility: visible;
  pointer-events: auto;
  transition:
    background 0.28s var(--ease-std),
    visibility 0s linear 0s;
}

#detail-sheet {
  background: var(--tg-secondary);
  border-radius: var(--radius) var(--radius) 0 0;
  width: 100%;
  max-height: 75vh;
  display: flex;
  flex-direction: column;
  padding-bottom: env(safe-area-inset-bottom, 0);
  transform: translateY(100%);
  transition: transform 0.35s var(--spring-close);
  will-change: transform;
}
#detail-overlay.visible #detail-sheet {
  transform: translateY(0);
  transition: transform 0.52s var(--spring-open);
}

#detail-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}

#detail-title {
  font-size: 15px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#detail-close {
  background: rgba(255,255,255,0.1);
  border: none;
  border-radius: 50%;
  width: 28px;
  height: 28px;
  font-size: 16px;
  cursor: pointer;
  color: var(--tg-text);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
#detail-close:active { opacity: 0.6; }

#detail-output {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 14px 16px;
  font-family: 'Menlo', 'Courier New', monospace;
  font-size: 12px;
  line-height: 1.6;
  color: var(--tg-text);
  white-space: pre-wrap;
  word-break: normal;        /* nicht mitten im Wort trennen */
  overflow-wrap: break-word; /* nur unteilbar lange Tokens (URLs/Hashes) brechen */
}
/* Touch-Auswahl in Telegram WKWebView freischalten (Long-Press → Kopieren) */
#detail-output, #detail-output * {
  -webkit-user-select: text;
  user-select: text;
  -webkit-touch-callout: default;
}

/* ── Token-Modal ── */

#token-modal {
  display: flex;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0);
  z-index: 200;
  align-items: center;
  justify-content: center;
  padding: 20px;
  visibility: hidden;
  pointer-events: none;
  transition: background 0.22s var(--ease-std), visibility 0s linear 0.22s;
}
#token-modal.visible {
  background: rgba(0,0,0,0.7);
  visibility: visible;
  pointer-events: auto;
  transition: background 0.22s var(--ease-std), visibility 0s;
}
#token-modal #token-box {
  transform: scale(0.93) translateY(8px);
  opacity: 0;
  transition: transform 0.32s var(--spring-open), opacity 0.22s var(--ease-std);
}
#token-modal.visible #token-box {
  transform: scale(1) translateY(0);
  opacity: 1;
}

#token-box {
  background: var(--tg-secondary);
  border-radius: var(--radius);
  padding: 24px 20px;
  width: 100%;
  max-width: 340px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

#token-box h2 { font-size: 16px; font-weight: 600; }
#token-box p  { font-size: 13px; color: var(--tg-hint); }

#token-input {
  background: var(--tg-bg);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 14px;
  color: var(--tg-text);
  width: 100%;
  outline: none;
}
#token-input:focus { border-color: var(--tg-link); }

#token-submit {
  background: var(--tg-btn);
  color: var(--tg-btn-text);
  border: none;
  border-radius: 8px;
  padding: 11px;
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  width: 100%;
}
#token-submit:active { opacity: 0.75; }

/* ── Health-Panel ── */

#health-container {
  padding: 0 14px 8px;
}

#health-panel {
  padding-bottom: 4px;
}

.health-list {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.health-item {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--tg-secondary);
  border-radius: 20px;
  padding: 5px 10px;
  border: 1px solid rgba(255,255,255,0.06);
}

.health-item[data-status="green"] .dot  { background: var(--status-green); }
.health-item[data-status="yellow"] .dot { background: var(--status-yellow); }
.health-item[data-status="red"] .dot    { background: var(--status-red); }
.health-item[data-status="stale"] .dot  { background: var(--status-stale); }

.health-label {
  font-size: 12px;
  color: var(--tg-text);
  white-space: nowrap;
}

/* ── Footer ── */

#footer {
  padding: 10px 14px;
  padding-bottom: max(10px, env(safe-area-inset-bottom, 10px));
  border-top: 1px solid rgba(255,255,255,0.08);
  background: var(--tg-secondary);
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

#btn-hayalet-end {
  background: var(--status-red-bg);
  color: var(--status-red);
  border: 1px solid var(--status-red);
  border-radius: 8px;
  padding: 7px 16px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  touch-action: manipulation;
}
#btn-hayalet-end:active { opacity: 0.7; }

/* ── Detail-Actions (task buttons in Detail-View) ── */

#detail-actions {
  padding: 0 16px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.detail-actions-title {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--tg-hint);
  padding-top: 4px;
}

.task-btn {
  background: var(--tg-btn);
  color: var(--tg-btn-text);
  border: none;
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  touch-action: manipulation;
  text-align: left;
}
.task-btn:active { opacity: 0.7; }
.task-btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* ── Confirm-Modal ── */

#confirm-overlay {
  display: flex;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0);
  z-index: 300;
  align-items: center;
  justify-content: center;
  padding: 20px;
  visibility: hidden;
  pointer-events: none;
  transition: background 0.22s var(--ease-std), visibility 0s linear 0.22s;
}
#confirm-overlay.visible {
  background: rgba(0,0,0,0.75);
  visibility: visible;
  pointer-events: auto;
  transition: background 0.22s var(--ease-std), visibility 0s;
}
#confirm-overlay #confirm-box {
  transform: scale(0.93) translateY(8px);
  opacity: 0;
  transition: transform 0.32s var(--spring-open), opacity 0.22s var(--ease-std);
}
#confirm-overlay.visible #confirm-box {
  transform: scale(1) translateY(0);
  opacity: 1;
}

#confirm-box {
  background: var(--tg-secondary);
  border-radius: var(--radius);
  padding: 20px;
  width: 100%;
  max-width: 360px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

#confirm-box h2 {
  font-size: 16px;
  font-weight: 600;
}

#confirm-preview {
  background: var(--tg-bg);
  border-radius: 8px;
  padding: 10px 12px;
  font-family: 'Menlo', 'Courier New', monospace;
  font-size: 12px;
  line-height: 1.5;
  color: var(--tg-text);
  white-space: pre-wrap;
  word-break: break-all;
  max-height: 120px;
  overflow-y: auto;
  margin: 0;
}

#confirm-fingerprint {
  font-size: 11px;
  color: var(--tg-hint);
  font-family: 'Menlo', 'Courier New', monospace;
  word-break: break-all;
  min-height: 1em;
}

.confirm-btns {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

#confirm-cancel {
  background: rgba(255,255,255,0.1);
  color: var(--tg-text);
  border: none;
  border-radius: 8px;
  padding: 9px 18px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
}
#confirm-cancel:active { opacity: 0.7; }

#confirm-ok {
  background: var(--tg-btn);
  color: var(--tg-btn-text);
  border: none;
  border-radius: 8px;
  padding: 9px 18px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
}
#confirm-ok:active { opacity: 0.7; }

/* ── Große Bildschirme ── */
@media (min-width: 480px) {
  .grid { grid-template-columns: repeat(3, 1fr); }
}

/* ── Zwei-Wege-Kontrolle: Eingabe · Steuer-Tasten · Sprache · Copy (2026-06-26) ── */
#detail-control {
  padding: 8px 14px 14px;
  border-top: 1px solid rgba(255,255,255,0.08);
  display: flex; flex-direction: column; gap: 8px;
}
.ctrl-row { display: flex; flex-wrap: wrap; gap: 6px; }
.ctrl-btn {
  background: var(--tg-secondary);
  color: var(--tg-text);
  border: 1px solid rgba(255,255,255,0.10);
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 13px; font-weight: 500;
  cursor: pointer; min-width: 40px;
}
.ctrl-btn:active { opacity: 0.6; }
.input-row { display: flex; gap: 6px; align-items: flex-end; }
#pane-input {
  flex: 1;
  background: var(--tg-bg);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 15px; color: var(--tg-text);
  resize: none; outline: none; max-height: 120px; line-height: 1.3;
}
#pane-input:focus { border-color: var(--tg-link); }
.icon-btn {
  background: var(--tg-secondary);
  border: 1px solid rgba(255,255,255,0.10);
  border-radius: 8px;
  font-size: 18px; padding: 8px 10px; cursor: pointer;
}
.icon-btn.recording {
  background: var(--status-red-bg);
  border-color: var(--status-red);
  animation: pulse 1s ease-in-out infinite;
}
@keyframes pulse { 0%,100%{opacity:1} 50%{opacity:0.45} }
.send-btn {
  background: var(--tg-btn); color: var(--tg-btn-text);
  border: none; border-radius: 8px;
  padding: 10px 16px; font-size: 15px; font-weight: 600; cursor: pointer;
}
.send-btn:active { opacity: 0.75; }
.send-btn:disabled, .icon-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.input-status { font-size: 12px; color: var(--tg-hint); min-height: 14px; }
.input-status.err { color: var(--status-red); }

/* ── Hierarchie: Fenster → Panes (2026-06-26) ── */
.win-block { margin: 0 10px 8px; }
.win-head {
  display: flex; align-items: center; gap: 8px;
  padding: 12px 12px; border-radius: var(--radius);
  cursor: pointer; border: 1px solid rgba(255,255,255,0.08);
}
.win-head:active { opacity: 0.8; }
.win-caret { font-size: 12px; color: var(--tg-hint); width: 12px; }
.win-name { font-size: 16px; font-weight: 600; color: var(--tg-text); }
.win-count { margin-left: auto; font-size: 12px; color: var(--tg-hint); }
.win-panes { display: flex; flex-direction: column; gap: 6px; padding: 6px 0 2px 14px; }
.pane-card { padding: 10px 12px; border-radius: 10px; cursor: pointer; }
.pane-card:active { opacity: 0.7; }
.pane-status { margin-left: auto; font-size: 12px; color: var(--tg-hint); }

/* Aufgaben einklappbar + mehr Platz für Output */
.tasks-toggle {
  margin: 6px 14px 0; align-self: flex-start;
  background: var(--tg-secondary); color: var(--tg-text);
  border: 1px solid rgba(255,255,255,0.10); border-radius: 8px;
  padding: 6px 10px; font-size: 13px; cursor: pointer;
}
#detail-actions.collapsed { display: none; }
#detail-output { flex: 1; min-height: 40vh; }

/* ── Vollbild-Detail + Dichte (2026-06-26 v2: Übersicht wie tmux) ── */
#detail-overlay { align-items: stretch; }
#detail-sheet {
  width: 100vw; max-width: 100vw; height: 100dvh; max-height: 100dvh;
  border-radius: 0;
}
#detail-header { padding: 10px 12px; }
#detail-output { font-size: 11.5px; line-height: 1.45; padding: 8px 10px; min-height: 0; }

/* Dichtes Grid */
#grid { padding-top: 6px; }
.win-block { margin: 0 8px 6px; }
.win-head { padding: 9px 10px; gap: 7px; }
.win-num {
  font-size: 11px; font-weight: 700; color: var(--tg-hint);
  background: rgba(255,255,255,0.08); border-radius: 5px;
  min-width: 18px; text-align: center; padding: 1px 4px;
}
.win-name { font-size: 14px; }
.win-count { font-size: 11px; }
.win-panes { gap: 4px; padding: 4px 0 2px 10px; }
.pane-card { padding: 7px 10px; }
.pane-card .card-label { font-size: 13px; }
.pane-card .card-summary { font-size: 10.5px; opacity: 0.7; }
.pane-status { font-size: 11px; }
.dot { width: 9px; height: 9px; }

/* Kompakte Steuer-Tasten */
#detail-control { padding: 6px 10px 10px; gap: 6px; }
.ctrl-row { gap: 5px; }
.ctrl-btn { padding: 7px 9px; font-size: 13px; min-width: 34px; }
.send-btn { padding: 8px 14px; font-size: 14px; }
.tasks-toggle { margin: 4px 12px 0; padding: 5px 9px; font-size: 12px; }

/* Summary sauber umbrechen statt mitten im Wort abschneiden (2026-06-26 v3) */
.card-summary {
  white-space: normal;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden; word-break: break-word; line-height: 1.35;
}
.card-label { white-space: normal; word-break: break-word; }

/* ── Native Dashboard-Ansicht (Fenster 1, 2026-06-26) ── */
#detail-output.dashboard-mode {
  white-space: normal; font-family: inherit; font-size: 14px;
  padding: 12px 14px; line-height: 1.4;
}
.dash-sec { margin-bottom: 18px; }
.dash-h {
  font-size: 12px; font-weight: 700; color: var(--tg-hint);
  text-transform: uppercase; letter-spacing: 0.4px; margin-bottom: 8px;
}
.dash-row { font-size: 14px; color: var(--tg-text); padding: 3px 0; }
.dash-task {
  display: flex; gap: 9px; padding: 9px 11px;
  background: var(--tg-secondary); border-radius: 9px; margin-bottom: 6px;
}
.dash-ic { flex-shrink: 0; font-size: 14px; }
.dash-task-main { font-size: 14px; color: var(--tg-text); line-height: 1.35; word-break: break-word; }
.dash-task-sub { font-size: 12px; color: var(--tg-hint); margin-top: 2px; }
.dash-proj {
  display: flex; justify-content: space-between; gap: 10px;
  padding: 7px 4px; border-bottom: 1px solid rgba(255,255,255,0.06);
}
.dash-proj-n { font-size: 13px; color: var(--tg-text); }
.dash-proj-s { font-size: 12px; color: var(--tg-hint); text-align: right; max-width: 56%; word-break: break-word; }
.dash-blocker { color: var(--status-yellow); font-size: 13px; line-height: 1.4; }

/* Trello-Karten im Dashboard (2026-06-26) */
.dash-trello {
  display: flex; justify-content: space-between; gap: 10px;
  padding: 8px 10px; background: var(--tg-secondary); border-radius: 8px; margin-bottom: 6px;
}
.dash-trello-n { font-size: 13px; color: var(--tg-text); word-break: break-word; line-height: 1.3; }
.dash-trello-age { font-size: 11px; color: var(--tg-hint); white-space: nowrap; flex-shrink: 0; }

/* Trello-Karten-Detail (Beschreibung + Kommentare, 2026-06-26) */
.dash-trello.clickable { cursor: pointer; }
.dash-trello.clickable:active { opacity: 0.7; }
.trello-title { font-size: 16px; font-weight: 700; color: var(--tg-text); margin: 12px 0 6px; line-height: 1.3; }
.trello-desc { font-size: 14px; color: var(--tg-text); white-space: pre-wrap; word-break: break-word; line-height: 1.45; }
.trello-comment { padding: 9px 11px; background: var(--tg-secondary); border-radius: 8px; margin-bottom: 6px; }
.trello-c-meta { font-size: 11px; color: var(--tg-hint); margin-bottom: 3px; }
.trello-c-txt { font-size: 14px; color: var(--tg-text); white-space: pre-wrap; word-break: break-word; line-height: 1.4; }

/* 📜 Verlauf — Unterhaltungs-Blasen (2026-06-29) */
.tx-msg { margin: 8px 0; padding: 9px 11px; border-radius: 9px; }
.tx-user { background: rgba(10,132,255,0.13); }
.tx-claude { background: var(--tg-secondary); }
.tx-who { font-size: 11px; color: var(--tg-hint); margin-bottom: 3px; }
.tx-txt { font-size: 14px; color: var(--tg-text); white-space: pre-wrap; word-break: normal; overflow-wrap: break-word; line-height: 1.45; }

/* ================================================================
   iOS App-Feeling — Spring, Haptics, Glass (2026-07-05)
   ================================================================ */

/* -- Globale Touch-Highlights entfernen (iOS native) -- */
* { -webkit-tap-highlight-color: transparent; }

/* -- Transition auf alle interaktiven Elemente -- */
.ctrl-btn, .icon-btn, .send-btn, .task-btn,
#btn-refresh, #btn-hayalet-end, #token-submit,
#detail-close, #confirm-cancel, #confirm-ok,
.card.clickable, .pane-card, .win-head,
.dash-trello.clickable, .tasks-toggle {
  transition: var(--transition-btn);
}

/* -- Scale-Press für Buttons (iOS: leichter Drück-Effekt) -- */
.ctrl-btn:active              { transform: scale(0.92); opacity: 0.65 !important; }
.icon-btn:active              { transform: scale(0.90); opacity: 0.65 !important; }
.send-btn:active              { transform: scale(0.96); opacity: 0.72 !important; }
.task-btn:active              { transform: scale(0.95); opacity: 0.7  !important; }
.tasks-toggle:active          { transform: scale(0.96); opacity: 0.72 !important; }
#btn-refresh:active           { transform: scale(0.94); opacity: 0.7  !important; }
#btn-hayalet-end:active       { transform: scale(0.95); opacity: 0.7  !important; }
#token-submit:active          { transform: scale(0.96); opacity: 0.75 !important; }
#detail-close:active          { transform: scale(0.88); opacity: 0.6  !important; }
#confirm-cancel:active,
#confirm-ok:active            { transform: scale(0.96); opacity: 0.7  !important; }
.card.clickable:active        { transform: scale(0.97); opacity: 0.78 !important; }
.pane-card:active             { transform: scale(0.98); opacity: 0.75 !important; }
.win-head:active              { transform: scale(0.98); opacity: 0.80 !important; }
.dash-trello.clickable:active { transform: scale(0.97); opacity: 0.72 !important; }

/* -- Drag-Handle auf dem Detail-Sheet -- */
.sheet-handle {
  width: 36px;
  height: 4px;
  background: rgba(255, 255, 255, 0.22);
  border-radius: 2px;
  margin: 10px auto 0;
  flex-shrink: 0;
  touch-action: none;
}
[data-scheme="light"] .sheet-handle { background: rgba(0, 0, 0, 0.18); }

/* -- Verbesserte Conn-Dot Animationen -- */
.conn-dot.online {
  background: var(--status-green);
  box-shadow: 0 0 0 2px rgba(48, 209, 88, 0.2);
  animation: conn-pulse 2.4s ease-in-out infinite;
}
@keyframes conn-pulse {
  0%, 100% { box-shadow: 0 0 0 2px rgba(48, 209, 88, 0.15); }
  50%       { box-shadow: 0 0 0 5px rgba(48, 209, 88, 0.28); }
}

/* -- Skeleton Loading (Shimmer-Effekt) -- */
@keyframes shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}
.skeleton-row {
  height: 14px;
  border-radius: 7px;
  background: linear-gradient(
    105deg,
    rgba(255,255,255,0.05) 25%,
    rgba(255,255,255,0.12) 50%,
    rgba(255,255,255,0.05) 75%
  );
  background-size: 200% 100%;
  animation: shimmer 1.5s ease-in-out infinite;
  margin-bottom: 8px;
}
.skeleton-card {
  background: rgba(255,255,255,0.04);
  border-radius: var(--radius);
  padding: 14px;
  min-height: 68px;
  overflow: hidden;
  position: relative;
}
.skeleton-card::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(
    105deg,
    transparent 40%,
    rgba(255,255,255,0.07) 50%,
    transparent 60%
  );
  background-size: 200% 100%;
  animation: shimmer 1.6s ease-in-out infinite;
}

/* -- Pane-Karten: iOS Grouped Inset List Style -- */
.win-panes {
  background: rgba(255,255,255,0.035);
  border-radius: 10px;
  overflow: hidden;
}
.win-panes .pane-card {
  border-radius: 0;
  border-bottom: 0.5px solid var(--ios-sep);
}
.win-panes .pane-card:last-child {
  border-bottom: none;
}

/* -- Separator unter den Karten (iOS-Stil) -- */
.win-block + .win-block { margin-top: 6px; }

/* -- Detail-Header verbessert -- */
#detail-header {
  border-bottom: 0.5px solid var(--ios-sep) !important;
}

/* -- Vollbild-Override: keep stretch + spring -- */
/* (override aus der Dense-Sektion weiter unten bleibt gültig für align-items:stretch) */

/* ================================================================
   Native Mobile Redesign — Telegram WebView + iOS grouped lists
   2026-07-05 native1
   ================================================================ */

:root {
  --tg-viewport-height: 100dvh;
  --tg-viewport-stable-height: 100dvh;
  --tg-safe-top: env(safe-area-inset-top, 0px);
  --tg-safe-right: env(safe-area-inset-right, 0px);
  --tg-safe-bottom: env(safe-area-inset-bottom, 0px);
  --tg-safe-left: env(safe-area-inset-left, 0px);
  --tg-content-safe-top: 0px;
  --tg-content-safe-bottom: 0px;
  --app-viewport-height: 100dvh;

  --app-page: #0b0d10;
  --app-page-2: #151922;
  --app-text: #f7f8fb;
  --app-muted: rgba(235, 238, 245, 0.62);
  --app-faint: rgba(235, 238, 245, 0.38);
  --app-card: rgba(30, 34, 43, 0.82);
  --app-card-solid: #1b1f28;
  --app-bar: rgba(18, 21, 28, 0.78);
  --app-fill: rgba(118, 118, 128, 0.20);
  --app-input: rgba(10, 12, 16, 0.58);
  --app-stroke: rgba(255, 255, 255, 0.11);
  --app-hairline: rgba(255, 255, 255, 0.08);
  --app-shadow: 0 22px 56px rgba(0, 0, 0, 0.34);
  --app-shadow-soft: 0 10px 28px rgba(0, 0, 0, 0.22);
  --app-radius-xl: 24px;
  --app-radius-lg: 18px;
  --app-radius-md: 14px;
}

body[data-scheme="light"] {
  --app-page: #f2f4f8;
  --app-page-2: #e7edf5;
  --app-text: #111318;
  --app-muted: rgba(40, 44, 52, 0.62);
  --app-faint: rgba(40, 44, 52, 0.36);
  --app-card: rgba(255, 255, 255, 0.82);
  --app-card-solid: #ffffff;
  --app-bar: rgba(255, 255, 255, 0.76);
  --app-fill: rgba(118, 118, 128, 0.14);
  --app-input: rgba(255, 255, 255, 0.80);
  --app-stroke: rgba(38, 42, 50, 0.10);
  --app-hairline: rgba(38, 42, 50, 0.08);
  --app-shadow: 0 18px 42px rgba(40, 47, 62, 0.16);
  --app-shadow-soft: 0 8px 20px rgba(40, 47, 62, 0.12);
}

html,
body {
  min-height: 100%;
  overflow-x: hidden;
  background: var(--app-page);
  color: var(--app-text);
}

body {
  padding: 0 !important;
  background:
    linear-gradient(180deg, var(--app-page) 0%, var(--app-page-2) 100%);
  overscroll-behavior: none;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(180deg, rgba(255,255,255,0.07), rgba(255,255,255,0) 28%),
    repeating-linear-gradient(0deg, rgba(255,255,255,0.018) 0 1px, transparent 1px 4px);
  opacity: 0.62;
  z-index: 0;
}

body[data-scheme="light"]::before {
  background:
    linear-gradient(180deg, rgba(255,255,255,0.82), rgba(255,255,255,0) 32%),
    repeating-linear-gradient(0deg, rgba(20,30,50,0.022) 0 1px, transparent 1px 4px);
  opacity: 1;
}

#app {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 680px;
  min-height: var(--app-viewport-height);
  margin: 0 auto;
  background: transparent;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

#banner {
  position: sticky;
  top: 0;
  z-index: 30;
  margin: 0;
  border: 0;
  border-bottom: 0.5px solid rgba(255, 214, 10, 0.36);
  background: rgba(255, 214, 10, 0.16);
  color: #ffd60a;
  backdrop-filter: blur(18px) saturate(160%);
  -webkit-backdrop-filter: blur(18px) saturate(160%);
}

#header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: end;
  min-height: 104px;
  padding:
    calc(18px + var(--tg-safe-top, 0px) + var(--tg-content-safe-top, 0px))
    16px
    14px;
  border: 0;
  background: linear-gradient(180deg, rgba(20, 23, 31, 0.92), rgba(20, 23, 31, 0.70));
  box-shadow: 0 1px 0 var(--app-hairline), 0 18px 36px rgba(0, 0, 0, 0.20);
  backdrop-filter: blur(26px) saturate(180%);
  -webkit-backdrop-filter: blur(26px) saturate(180%);
}

body[data-scheme="light"] #header {
  background: linear-gradient(180deg, rgba(252, 253, 255, 0.94), rgba(246, 248, 252, 0.74));
  box-shadow: 0 1px 0 var(--app-hairline), 0 18px 36px rgba(40, 47, 62, 0.12);
}

.header-copy {
  min-width: 0;
}

.header-kicker {
  margin-bottom: 4px;
  color: var(--app-muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

#header h1 {
  color: var(--app-text);
  font-size: 34px;
  font-weight: 760;
  line-height: 1;
  letter-spacing: 0;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  padding-bottom: 2px;
}

.connection-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 34px;
  padding: 0 10px;
  border: 0.5px solid var(--app-stroke);
  border-radius: 999px;
  background: var(--app-fill);
  color: var(--app-muted);
  font-size: 12px;
  font-weight: 650;
  white-space: nowrap;
}

.conn-dot {
  width: 8px;
  height: 8px;
  margin: 0;
  box-shadow: none;
}

.conn-dot.online {
  background: var(--status-green);
  box-shadow: 0 0 0 3px rgba(48, 209, 88, 0.18);
}

.conn-dot.offline {
  background: var(--status-red);
}

#btn-refresh {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  padding: 0;
  border: 0.5px solid var(--app-stroke);
  border-radius: 50%;
  background: var(--app-card);
  color: var(--app-text);
  box-shadow: var(--app-shadow-soft);
  font-size: 24px;
  line-height: 1;
  backdrop-filter: blur(18px) saturate(170%);
  -webkit-backdrop-filter: blur(18px) saturate(170%);
}

#grid-container {
  flex: 1 0 auto;
  padding: 16px 14px 8px;
  overflow: visible;
}

#grid {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding-top: 0;
}

.grid-section-title {
  margin: 8px 2px 9px;
  color: var(--app-muted);
  font-size: 12px;
  font-weight: 760;
  letter-spacing: 0.08em;
}

.win-block {
  margin: 0;
  overflow: hidden;
  border: 0.5px solid var(--app-stroke);
  border-radius: var(--app-radius-xl);
  background: var(--app-card);
  box-shadow: var(--app-shadow-soft);
  backdrop-filter: blur(22px) saturate(160%);
  -webkit-backdrop-filter: blur(22px) saturate(160%);
}

.win-block + .win-block {
  margin-top: 0;
}

.win-head {
  min-height: 62px;
  padding: 14px 16px;
  gap: 10px;
  border: 0;
  border-radius: 0;
  background: transparent !important;
}

.win-caret {
  order: 5;
  width: 24px;
  height: 24px;
  margin-left: 2px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--app-fill);
  color: var(--app-muted);
  font-size: 13px;
}

.win-num {
  min-width: 28px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  background: linear-gradient(180deg, rgba(10, 132, 255, 0.24), rgba(48, 209, 88, 0.12));
  color: var(--app-text);
  font-size: 12px;
  font-weight: 800;
}

.win-name {
  min-width: 0;
  color: var(--app-text);
  font-size: 17px;
  font-weight: 720;
  line-height: 1.2;
}

.win-count {
  margin-left: auto;
  padding: 4px 8px;
  border-radius: 999px;
  background: var(--app-fill);
  color: var(--app-muted);
  font-size: 11px;
  font-weight: 650;
}

.win-panes {
  gap: 0;
  padding: 0 0 0 54px;
  border-radius: 0;
  background: transparent;
}

.win-panes .pane-card,
.pane-card {
  min-height: 62px;
  padding: 12px 14px 12px 0;
  border: 0;
  border-top: 0.5px solid var(--app-hairline);
  border-radius: 0;
  background: transparent !important;
}

.win-panes .pane-card:last-child {
  border-bottom: 0;
}

.card-header {
  gap: 8px;
}

.dot {
  width: 10px;
  height: 10px;
  box-shadow: 0 0 0 3px rgba(255,255,255,0.08);
}

body[data-scheme="light"] .dot {
  box-shadow: 0 0 0 3px rgba(40,47,62,0.06);
}

.card-label {
  color: var(--app-text);
  font-size: 14px;
  font-weight: 680;
  line-height: 1.25;
  white-space: normal;
  word-break: break-word;
}

.pane-status {
  margin-left: auto;
  color: var(--app-faint);
  font-size: 11px;
  font-weight: 650;
}

.card-summary {
  margin-top: 5px;
  margin-left: 18px;
  color: var(--app-muted);
  font-size: 12px;
  line-height: 1.35;
}

.loading,
.grid-error,
.empty {
  margin: 0;
  border: 0.5px solid var(--app-stroke);
  border-radius: var(--app-radius-xl);
  background: var(--app-card);
  box-shadow: var(--app-shadow-soft);
  color: var(--app-muted);
  padding: 28px 18px;
}

#health-container {
  padding: 8px 14px 18px;
}

#health-panel {
  padding-bottom: 0;
}

.health-list {
  gap: 7px;
}

.health-item {
  min-height: 34px;
  padding: 7px 11px;
  border: 0.5px solid var(--app-stroke);
  border-radius: 999px;
  background: var(--app-card);
  box-shadow: none;
  backdrop-filter: blur(18px) saturate(150%);
  -webkit-backdrop-filter: blur(18px) saturate(150%);
}

.health-label {
  color: var(--app-text);
  font-size: 12px;
  font-weight: 650;
}

#footer {
  position: sticky;
  bottom: 0;
  z-index: 20;
  margin-top: auto;
  padding: 10px 14px calc(12px + var(--tg-safe-bottom, 0px));
  border: 0;
  background: linear-gradient(180deg, rgba(0,0,0,0), var(--app-page) 44%);
  justify-content: center;
}

#btn-hayalet-end {
  width: min(100%, 460px);
  min-height: 48px;
  border: 0.5px solid rgba(255, 69, 58, 0.36);
  border-radius: 18px;
  background: linear-gradient(180deg, rgba(255, 69, 58, 0.18), rgba(255, 69, 58, 0.10));
  color: var(--tg-destructive, var(--status-red));
  font-size: 15px;
  font-weight: 720;
  box-shadow: var(--app-shadow-soft);
}

#detail-overlay {
  align-items: flex-end !important;
  justify-content: center;
  padding:
    calc(8px + var(--tg-content-safe-top, 0px))
    8px
    0;
  background: rgba(0, 0, 0, 0);
  backdrop-filter: blur(0);
  -webkit-backdrop-filter: blur(0);
}

#detail-overlay.visible {
  background: rgba(0, 0, 0, 0.44);
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
}

#detail-sheet {
  width: min(100%, 680px) !important;
  max-width: 680px !important;
  height: min(92dvh, calc(var(--app-viewport-height) - var(--tg-content-safe-top, 0px) - 8px)) !important;
  max-height: min(92dvh, calc(var(--app-viewport-height) - var(--tg-content-safe-top, 0px) - 8px)) !important;
  margin: 0 auto;
  overflow: hidden;
  border: 0.5px solid var(--app-stroke);
  border-bottom: 0;
  border-radius: 30px 30px 0 0 !important;
  background: var(--app-card-solid);
  box-shadow: 0 -24px 70px rgba(0, 0, 0, 0.46);
  padding-bottom: var(--tg-safe-bottom, env(safe-area-inset-bottom, 0px));
}

body[data-scheme="light"] #detail-sheet {
  box-shadow: 0 -24px 70px rgba(40, 47, 62, 0.22);
}

.sheet-handle {
  width: 44px;
  height: 5px;
  margin: 10px auto 7px;
  border-radius: 999px;
  background: var(--app-faint);
}

#detail-header {
  min-height: 50px;
  padding: 8px 14px 12px;
  border-bottom: 0.5px solid var(--app-hairline) !important;
  background: var(--app-card-solid);
}

#detail-title {
  color: var(--app-text);
  font-size: 17px;
  font-weight: 760;
}

#detail-close {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--app-fill);
  color: var(--app-muted);
  font-size: 17px;
  font-weight: 720;
}

#detail-output {
  min-height: 0;
  margin: 10px 12px 0;
  padding: 12px 13px;
  border: 0.5px solid var(--app-hairline);
  border-radius: 18px;
  background: #0a0d12;
  color: #f4f7fb;
  font-size: 12px;
  line-height: 1.52;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.04);
}

#detail-output.dashboard-mode {
  margin: 0;
  padding: 14px 14px 4px;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--app-text);
  font-family: inherit;
  font-size: 14px;
  line-height: 1.42;
  box-shadow: none;
}

.tasks-toggle {
  margin: 9px 14px 0;
  padding: 7px 11px;
  border: 0.5px solid var(--app-stroke);
  border-radius: 999px;
  background: var(--app-fill);
  color: var(--app-muted);
  font-size: 12px;
  font-weight: 700;
}

#detail-actions {
  padding: 8px 14px 12px;
}

.task-btn {
  border-radius: 15px;
  padding: 12px 13px;
  font-weight: 700;
  box-shadow: none;
}

#detail-control {
  padding: 10px 12px calc(12px + var(--tg-safe-bottom, 0px));
  gap: 8px;
  border-top: 0.5px solid var(--app-hairline);
  background: var(--app-bar);
  backdrop-filter: blur(24px) saturate(170%);
  -webkit-backdrop-filter: blur(24px) saturate(170%);
}

.ctrl-row {
  flex-wrap: nowrap;
  gap: 7px;
  overflow-x: auto;
  padding-bottom: 2px;
  scrollbar-width: none;
}

.ctrl-row::-webkit-scrollbar {
  display: none;
}

.ctrl-btn {
  min-width: 40px;
  height: 36px;
  padding: 0 12px;
  border: 0.5px solid var(--app-stroke);
  border-radius: 999px;
  background: var(--app-fill);
  color: var(--app-text);
  font-size: 13px;
  font-weight: 720;
}

.input-row {
  gap: 4px;
  align-items: center;
  padding: 4px;
  border: 0.5px solid var(--app-stroke);
  border-radius: 22px;
  background: var(--app-input);
}

#pane-input {
  min-height: 36px;
  max-height: 110px;
  border: 0;
  border-radius: 18px;
  background: transparent;
  color: var(--app-text);
  padding: 8px 9px;
  line-height: 1.25;
}

#pane-input:focus {
  border-color: transparent;
}

.icon-btn {
  width: 38px;
  height: 38px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: var(--app-fill);
  font-size: 18px;
}

.send-btn {
  min-height: 38px;
  padding: 0 14px;
  border-radius: 18px;
  font-size: 14px;
  font-weight: 760;
  box-shadow: none;
}

.input-status {
  min-height: 15px;
  color: var(--app-muted);
  font-size: 12px;
}

#token-box,
#confirm-box {
  border: 0.5px solid var(--app-stroke);
  border-radius: 24px;
  background: var(--app-card-solid);
  box-shadow: var(--app-shadow);
}

#token-input,
#confirm-preview {
  border: 0.5px solid var(--app-stroke);
  border-radius: 15px;
  background: var(--app-input);
  color: var(--app-text);
}

.confirm-btns button,
#token-submit {
  border-radius: 15px;
  min-height: 42px;
  font-weight: 720;
}

.dash-sec {
  margin: 0 0 12px;
  padding: 13px 13px;
  border: 0.5px solid var(--app-stroke);
  border-radius: 18px;
  background: var(--app-card);
}

.dash-h {
  color: var(--app-muted);
  font-size: 11px;
  letter-spacing: 0.08em;
}

.dash-row,
.dash-task-main,
.dash-proj-n,
.trello-title,
.trello-desc,
.trello-c-txt,
.tx-txt {
  color: var(--app-text);
}

.dash-task,
.dash-trello,
.trello-comment,
.tx-claude {
  border: 0.5px solid var(--app-stroke);
  border-radius: 15px;
  background: var(--app-fill);
}

.tx-user {
  border: 0.5px solid rgba(10, 132, 255, 0.22);
  border-radius: 15px;
  background: rgba(10, 132, 255, 0.16);
}

@media (min-width: 560px) {
  #header {
    border-radius: 0 0 28px 28px;
  }

  #grid-container,
  #health-container,
  #footer {
    padding-left: 18px;
    padding-right: 18px;
  }
}

/* ================================================================
   Reader-first refinement — Apple-style deference to content
   2026-07-05 native2
   ================================================================ */

#header {
  min-height: 82px;
  padding:
    calc(10px + var(--tg-safe-top, 0px) + var(--tg-content-safe-top, 0px))
    14px
    10px;
  gap: 10px;
  box-shadow: 0 1px 0 var(--app-hairline);
}

.header-kicker {
  margin-bottom: 2px;
  font-size: 11px;
}

#header h1 {
  font-size: 28px;
  font-weight: 740;
}

.header-actions {
  gap: 6px;
}

.connection-pill {
  min-height: 30px;
  padding: 0 9px;
  font-size: 11px;
}

#btn-refresh {
  width: 38px;
  height: 38px;
  font-size: 21px;
  box-shadow: none;
}

#grid-container {
  padding: 10px 10px 6px;
}

#grid {
  gap: 8px;
}

.win-block {
  border-radius: 17px;
  box-shadow: none;
}

.win-head {
  min-height: 46px;
  padding: 9px 11px;
  gap: 8px;
}

.win-caret {
  width: 22px;
  height: 22px;
  font-size: 12px;
}

.win-num {
  min-width: 24px;
  height: 24px;
  border-radius: 8px;
  font-size: 11px;
}

.win-name {
  font-size: 15px;
  font-weight: 720;
}

.win-count {
  padding: 3px 7px;
  font-size: 10.5px;
}

.win-panes {
  padding-left: 42px;
}

.win-panes .pane-card,
.pane-card {
  min-height: 44px;
  padding: 7px 10px 7px 0;
}

.card-header {
  gap: 7px;
}

.dot {
  width: 8px;
  height: 8px;
}

.card-label {
  font-size: 13px;
  line-height: 1.18;
}

.pane-status {
  font-size: 10.5px;
}

.card-summary {
  margin-top: 3px;
  margin-left: 15px;
  font-size: 11px;
  line-height: 1.2;
  -webkit-line-clamp: 1;
}

#health-container {
  padding: 5px 10px 12px;
}

.grid-section-title {
  margin: 6px 2px 7px;
  font-size: 11px;
}

.health-list {
  gap: 5px;
}

.health-item {
  min-height: 30px;
  padding: 5px 9px;
}

#footer {
  padding: 7px 10px calc(8px + var(--tg-safe-bottom, 0px));
}

#btn-hayalet-end {
  min-height: 42px;
  border-radius: 15px;
  font-size: 14px;
}

#detail-overlay {
  align-items: stretch !important;
  padding: 0;
}

#detail-overlay.visible {
  background: var(--app-page);
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}

#detail-sheet {
  width: min(100vw, 680px) !important;
  max-width: 680px !important;
  height: var(--app-viewport-height) !important;
  max-height: var(--app-viewport-height) !important;
  border: 0;
  border-radius: 0 !important;
  box-shadow: none;
  padding-bottom: 0;
  background: var(--app-page);
}

body[data-scheme="light"] #detail-sheet {
  box-shadow: none;
}

.sheet-handle {
  display: none;
}

#detail-header {
  min-height: 42px;
  padding:
    calc(4px + var(--tg-safe-top, 0px) + var(--tg-content-safe-top, 0px))
    8px
    5px;
  background: var(--app-bar);
  backdrop-filter: blur(20px) saturate(170%);
  -webkit-backdrop-filter: blur(20px) saturate(170%);
}

#detail-title {
  font-size: 15px;
  font-weight: 720;
}

#detail-close {
  width: 30px;
  height: 30px;
  font-size: 16px;
}

#detail-output {
  flex: 1 1 auto;
  margin: 5px 6px 0;
  padding: 7px 8px;
  border-radius: 11px;
  font-size: 11.5px;
  line-height: 1.35;
  border-color: rgba(255,255,255,0.07);
}

#detail-output.dashboard-mode {
  margin: 0;
  padding: 9px 10px 0;
  font-size: 13.5px;
  line-height: 1.35;
}

.tasks-toggle[hidden] {
  display: none !important;
}

.tasks-toggle {
  margin: 5px 8px 0;
  padding: 4px 8px;
  font-size: 11px;
  min-height: 24px;
}

#detail-actions {
  padding: 5px 8px 7px;
  gap: 5px;
}

.task-btn {
  padding: 9px 10px;
  border-radius: 12px;
  font-size: 13px;
}

#detail-control {
  padding: 5px 6px calc(6px + var(--tg-safe-bottom, 0px));
  gap: 5px;
}

.ctrl-row {
  gap: 5px;
  padding-bottom: 0;
}

.ctrl-btn {
  min-width: 34px;
  height: 30px;
  padding: 0 9px;
  font-size: 12px;
}

.input-row {
  min-height: 38px;
  padding: 3px;
  border-radius: 19px;
}

#pane-input {
  min-height: 32px;
  max-height: 88px;
  padding: 6px 7px;
  font-size: 14px;
}

.icon-btn {
  width: 34px;
  height: 34px;
  font-size: 16px;
}

.send-btn {
  min-height: 34px;
  padding: 0 12px;
  font-size: 13px;
}

.input-status {
  min-height: 0;
  font-size: 11px;
  line-height: 1.1;
}

.input-status:empty {
  display: none;
}

@media (min-width: 560px) {
  #header {
    border-radius: 0;
  }

  #grid-container,
  #health-container,
  #footer {
    padding-left: 12px;
    padding-right: 12px;
  }
}

/* Native2 density pass: content wins over decoration */
body::before {
  display: none;
}

body {
  background: var(--app-page);
}

#header {
  min-height: 68px;
  padding:
    calc(8px + var(--tg-safe-top, 0px) + var(--tg-content-safe-top, 0px))
    12px
    8px;
}

.header-kicker {
  font-size: 10px;
  letter-spacing: 0.07em;
}

#header h1 {
  font-size: 24px;
}

.connection-pill {
  min-height: 28px;
  padding: 0 8px;
}

#btn-refresh {
  width: 34px;
  height: 34px;
  font-size: 19px;
}

#grid-container {
  padding: 8px 8px 5px;
}

#grid {
  gap: 7px;
}

.win-block {
  border-radius: 14px;
}

.win-head {
  min-height: 40px;
  padding: 8px 10px;
}

.win-caret {
  width: 20px;
  height: 20px;
}

.win-num {
  min-width: 22px;
  height: 22px;
  border-radius: 7px;
}

.win-name {
  font-size: 14px;
}

.win-panes {
  padding-left: 38px;
}

.win-panes .pane-card,
.pane-card {
  min-height: 39px;
  padding: 6px 9px 6px 0;
}

.card-label {
  font-size: 12.5px;
}

.card-summary {
  margin-top: 2px;
  margin-left: 14px;
  font-size: 10.5px;
  line-height: 1.15;
}

#detail-output {
  margin: 4px 5px 0;
  padding: 6px 7px;
  font-size: 10.8px;
  line-height: 1.30;
}

#detail-header {
  min-height: 38px;
  padding:
    calc(3px + var(--tg-safe-top, 0px) + var(--tg-content-safe-top, 0px))
    7px
    4px;
}

#detail-title {
  font-size: 14px;
}

#detail-close {
  width: 28px;
  height: 28px;
}

#detail-control {
  padding: 4px 5px calc(5px + var(--tg-safe-bottom, 0px));
  gap: 4px;
}

.ctrl-row {
  gap: 4px;
}

.ctrl-btn {
  min-width: 31px;
  height: 28px;
  padding: 0 8px;
  font-size: 11.5px;
}

.input-row {
  min-height: 35px;
  border-radius: 17px;
}

#pane-input {
  min-height: 29px;
  padding: 5px 6px;
  font-size: 13px;
}

.icon-btn {
  width: 31px;
  height: 31px;
  font-size: 15px;
}

.send-btn {
  min-height: 31px;
  padding: 0 10px;
  font-size: 12.5px;
}

/* ================================================================
   iOS Operator Pass — reader first, grouped-list logic
   2026-07-05 ios3
   ================================================================ */

:root {
  --app-page: #111112;
  --app-page-2: #111112;
  --app-text: #f5f5f7;
  --app-muted: rgba(235, 235, 245, 0.64);
  --app-faint: rgba(235, 235, 245, 0.42);
  --app-card: rgba(28, 28, 30, 0.92);
  --app-card-solid: #1c1c1e;
  --app-bar: rgba(28, 28, 30, 0.88);
  --app-fill: rgba(118, 118, 128, 0.18);
  --app-input: rgba(44, 44, 46, 0.92);
  --app-stroke: rgba(235, 235, 245, 0.14);
  --app-hairline: rgba(235, 235, 245, 0.10);
  --reader-bg: #050608;
  --reader-text: #f6f7fb;
  --reader-muted: #9ba3af;
  --operator-blue: #0a84ff;
  --operator-green: #30d158;
  --operator-yellow: #ffd60a;
  --operator-red: #ff453a;
}

body[data-scheme="light"] {
  --app-page: #f5f5f7;
  --app-page-2: #f5f5f7;
  --app-text: #111114;
  --app-muted: rgba(60, 60, 67, 0.66);
  --app-faint: rgba(60, 60, 67, 0.38);
  --app-card: rgba(255, 255, 255, 0.88);
  --app-card-solid: #ffffff;
  --app-bar: rgba(248, 248, 250, 0.90);
  --app-fill: rgba(120, 120, 128, 0.15);
  --app-input: rgba(255, 255, 255, 0.94);
  --app-stroke: rgba(60, 60, 67, 0.14);
  --app-hairline: rgba(60, 60, 67, 0.12);
  --reader-bg: #050608;
  --reader-text: #f6f7fb;
  --reader-muted: #9ba3af;
}

body {
  background: var(--app-page);
}

#app {
  max-width: 760px;
}

#header {
  min-height: 60px;
  padding:
    calc(6px + var(--tg-safe-top, 0px) + var(--tg-content-safe-top, 0px))
    10px
    6px;
  background: var(--app-bar);
  box-shadow: 0 0.5px 0 var(--app-hairline);
}

.header-kicker {
  margin-bottom: 1px;
  font-size: 9.5px;
}

#header h1 {
  font-size: 22px;
  line-height: 1.02;
}

.connection-pill {
  min-height: 28px;
  padding: 0 7px;
  border-radius: 14px;
}

#btn-refresh {
  width: 36px;
  height: 36px;
}

#grid-container {
  padding: 8px 8px 4px;
}

#grid {
  gap: 9px;
}

.win-block {
  overflow: hidden;
  border: 0.5px solid var(--app-stroke);
  border-radius: 10px;
  background: var(--app-card-solid);
  box-shadow: none;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}

.win-head {
  min-height: 44px;
  padding: 8px 10px;
  gap: 8px;
}

.win-head:focus-visible,
.pane-card:focus-visible,
.ctrl-btn:focus-visible,
.icon-btn:focus-visible,
.send-btn:focus-visible,
#detail-close:focus-visible {
  outline: 2px solid var(--operator-blue);
  outline-offset: -2px;
}

.win-caret {
  order: 5;
  width: 22px;
  height: 22px;
  background: transparent;
  color: var(--app-faint);
}

.win-num {
  min-width: 24px;
  height: 24px;
  border-radius: 7px;
  background: var(--app-fill);
  color: var(--app-muted);
}

.win-name {
  font-size: 14px;
  font-weight: 700;
}

.win-count {
  padding: 0;
  background: transparent;
  color: var(--app-faint);
}

.win-panes {
  padding: 0 0 0 34px;
  background: transparent;
}

.win-panes .pane-card,
.pane-card {
  min-height: 44px;
  padding: 7px 10px 7px 0;
  border-top: 0.5px solid var(--app-hairline);
  background: transparent !important;
}

.pane-card[data-status="green"] .dot { background: var(--operator-green) !important; }
.pane-card[data-status="yellow"] .dot { background: var(--operator-yellow) !important; }
.pane-card[data-status="red"] .dot { background: var(--operator-red) !important; }
.pane-card[data-status="stale"] .dot { background: var(--status-stale) !important; }

.dot {
  width: 8px;
  height: 8px;
  box-shadow: 0 0 0 2px var(--app-fill);
}

.card-label {
  font-size: 12.5px;
  font-weight: 680;
  line-height: 1.15;
}

.pane-status {
  flex-shrink: 0;
  margin-left: 8px;
  padding: 2px 6px;
  border-radius: 999px;
  background: var(--app-fill);
  color: var(--app-muted);
  font-size: 10.5px;
  font-weight: 700;
}

.card-summary {
  margin-top: 2px;
  margin-left: 14px;
  color: var(--app-muted);
  font-size: 10.5px;
  line-height: 1.15;
  -webkit-line-clamp: 1;
}

#health-container {
  padding: 5px 8px 10px;
}

.grid-section-title {
  margin: 5px 2px 6px;
}

.health-item {
  min-height: 28px;
  padding: 4px 8px;
  background: var(--app-card-solid);
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}

#footer {
  padding: 6px 8px calc(7px + var(--tg-safe-bottom, 0px));
  background: var(--app-page);
}

#btn-hayalet-end {
  min-height: 40px;
  border-radius: 12px;
  box-shadow: none;
}

#detail-sheet {
  background: var(--app-page);
}

#detail-header {
  min-height: 42px;
  padding:
    calc(2px + var(--tg-safe-top, 0px) + var(--tg-content-safe-top, 0px))
    5px
    2px
    10px;
  background: var(--app-bar);
}

#detail-title {
  font-size: 13.5px;
  font-weight: 720;
}

#detail-close {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  font-size: 18px;
}

#detail-output {
  flex: 1 1 auto;
  margin: 0;
  padding: 6px 7px;
  border: 0;
  border-radius: 0;
  background: var(--reader-bg);
  color: var(--reader-text);
  font-size: 10.8px;
  line-height: 1.24;
  box-shadow: none;
}

#detail-output.dashboard-mode {
  background: var(--app-page);
  color: var(--app-text);
}

#detail-control {
  padding: 3px 4px calc(4px + var(--tg-safe-bottom, 0px));
  gap: 3px;
  border-top: 0.5px solid var(--app-hairline);
  background: var(--app-bar);
}

.ctrl-row {
  gap: 4px;
}

.ctrl-btn {
  min-width: 32px;
  height: 28px;
  padding: 0 8px;
  border-radius: 14px;
  font-size: 11.5px;
}

.input-row {
  min-height: 34px;
  padding: 2px;
  border-radius: 17px;
}

#pane-input {
  min-height: 30px;
  padding: 5px 7px;
  font-size: 13px;
}

.icon-btn {
  width: 32px;
  height: 32px;
}

.send-btn {
  min-height: 32px;
  padding: 0 11px;
}

@media (min-width: 700px) {
  #grid-container,
  #health-container,
  #footer {
    padding-left: 10px;
    padding-right: 10px;
  }

  #detail-sheet {
    max-width: 760px !important;
  }
}

/* ================================================================
   Live-Sync + tmux Layout Controls (2026-07-05 sync4)
   ================================================================ */

.header-actions {
  align-items: center;
}

#btn-new-window {
  width: 36px;
  height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 18px;
  background: var(--operator-blue);
  color: #fff;
  font-size: 24px;
  font-weight: 520;
  line-height: 1;
  cursor: pointer;
  touch-action: manipulation;
  transition: var(--transition-btn);
}

#btn-new-window:active {
  transform: scale(0.94);
  opacity: 0.72;
}

#btn-new-window:focus-visible {
  outline: 2px solid var(--operator-blue);
  outline-offset: 2px;
}

.conn-dot.sync {
  background: var(--operator-blue);
  box-shadow: 0 0 0 2px rgba(10, 132, 255, 0.24);
  animation: none;
}

.conn-dot.live,
.conn-dot.online {
  background: var(--status-green);
  box-shadow: 0 0 0 2px rgba(48, 209, 88, 0.2);
  animation: conn-pulse 2.4s ease-in-out infinite;
}

.conn-dot.auth {
  background: var(--status-yellow);
  box-shadow: 0 0 0 2px rgba(255, 214, 10, 0.24);
  animation: none;
}

.conn-dot.offline {
  background: var(--operator-red);
}

.split-btn {
  min-width: 58px;
  color: var(--operator-blue);
  font-weight: 720;
}

.kill-btn {
  min-width: 72px;
  border-color: rgba(255, 69, 58, 0.36);
  color: var(--operator-red);
  font-weight: 760;
}

#detail-output .term-line {
  color: inherit;
}

#detail-output .term-link {
  color: var(--operator-blue);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
}

#detail-output .term-error {
  color: var(--operator-red);
  font-weight: 650;
}

#detail-output .term-warn {
  color: var(--operator-yellow);
}

#detail-output .term-success {
  color: var(--operator-green);
}

#window-modal {
  display: flex;
  position: fixed;
  inset: 0;
  z-index: 260;
  align-items: flex-end;
  justify-content: center;
  padding: 18px 12px calc(18px + var(--tg-safe-bottom, 0px));
  background: rgba(0, 0, 0, 0);
  visibility: hidden;
  pointer-events: none;
  transition: background 0.22s var(--ease-std), visibility 0s linear 0.22s;
}

#window-modal.visible {
  background: rgba(0, 0, 0, 0.56);
  visibility: visible;
  pointer-events: auto;
  transition: background 0.22s var(--ease-std), visibility 0s;
}

#window-box {
  width: min(100%, 380px);
  transform: translateY(14px) scale(0.98);
  opacity: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 16px;
  border: 0.5px solid var(--app-stroke);
  border-radius: 18px;
  background: var(--app-card-solid);
  box-shadow: var(--app-shadow-soft);
  transition: transform 0.32s var(--spring-open), opacity 0.2s var(--ease-std);
}

#window-modal.visible #window-box {
  transform: translateY(0) scale(1);
  opacity: 1;
}

#window-box h2 {
  font-size: 17px;
  line-height: 1.2;
  font-weight: 720;
}

#window-name-input {
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  border: 1px solid var(--app-stroke);
  border-radius: 12px;
  outline: none;
  background: var(--app-input);
  color: var(--app-text);
  font: inherit;
}

#window-name-input:focus {
  border-color: var(--operator-blue);
  box-shadow: 0 0 0 3px rgba(10, 132, 255, 0.16);
}

.window-btns {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

#window-cancel,
#window-create {
  min-height: 44px;
  border: 0;
  border-radius: 12px;
  padding: 0 16px;
  font-size: 15px;
  font-weight: 650;
  cursor: pointer;
  transition: var(--transition-btn);
}

#window-cancel {
  background: var(--app-fill);
  color: var(--app-text);
}

#window-create {
  background: var(--operator-blue);
  color: #fff;
}

#window-cancel:active,
#window-create:active {
  transform: scale(0.96);
  opacity: 0.72;
}

#window-create:disabled {
  opacity: 0.45;
  cursor: default;
}

@media (max-width: 430px) {
  .split-btn {
    min-width: 50px;
    padding-inline: 7px;
  }

  .kill-btn {
    min-width: 60px;
    padding-inline: 7px;
  }
}

/* Voice intent preview — compact, content-first, never overlays terminal text. */
.voice-preview {
  display: grid;
  gap: 6px;
  margin: 2px 0;
  padding: 8px;
  border: 0.5px solid var(--app-hairline, rgba(84, 84, 88, 0.45));
  border-radius: 12px;
  background: color-mix(in srgb, var(--app-fill, rgba(120, 120, 128, 0.16)) 74%, transparent);
}

.voice-preview[hidden] {
  display: none !important;
}

.voice-preview-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-width: 0;
  font-size: 12px;
}

.voice-preview-head strong {
  color: var(--app-text, var(--tg-text));
  font-weight: 760;
}

.voice-preview-head span,
.voice-preview-raw {
  color: var(--app-muted, var(--tg-hint));
  font-size: 11px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.voice-preview-text {
  color: var(--app-text, var(--tg-text));
  font-size: 12.5px;
  line-height: 1.25;
  max-height: 48px;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
}

.voice-preview-actions {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 6px;
}

.voice-preview-actions button {
  min-height: 30px;
  border: 0;
  border-radius: 9px;
  font-size: 12px;
  font-weight: 720;
  color: var(--app-text, var(--tg-text));
  background: var(--app-fill, rgba(120, 120, 128, 0.18));
}

.voice-preview-actions .voice-run {
  color: #fff;
  background: var(--operator-blue, var(--tg-link));
}

.voice-preview-actions button:active {
  transform: scale(0.97);
  opacity: 0.75;
}
