/* ============================================================================
   SAWAS Dashboard – Mobile Web App
   Optimiert für iOS-Safari (Add-to-Home-Screen) und Android-Chrome.
   Look angelehnt an das Desktop-Dashboard: dunkler Hintergrund mit Aurora,
   rotierender Rahmen in Cyan/Magenta/Neon-Gruen, "S A W A S DASHBOARD"-Pille
   oben im Rand.
   ============================================================================ */

* { box-sizing: border-box; }
:root {
  --c1: #00E5FF;   /* Cyan      */
  --c2: #FF00C8;   /* Magenta   */
  --c3: #7CFF00;   /* Neon-Gruen */
  --bg: #0A0E1C;
  --fg: #E8F4FF;
  --muted: #9EE6FF;
  --card-bg: rgba(0, 229, 255, 0.04);
  --card-border: rgba(0, 229, 255, 0.18);
  --safe-top:    env(safe-area-inset-top, 0);
  --safe-bottom: env(safe-area-inset-bottom, 0);
}

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
               "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: contain;
}

body {
  min-height: 100vh;
  /* Horizontal kein Padding -> die App nimmt die volle Bildschirmbreite */
  padding: calc(6px + var(--safe-top)) 0 calc(6px + var(--safe-bottom));
  line-height: 1.45;
  overflow-x: hidden;            /* nichts soll horizontal aus dem Viewport haengen */
}
html { overflow-x: hidden; }

/* ----------------------------------------------------------------------------
   Aurora-Hintergrund (3 weiche, langsam wandernde Farbverläufe)
   ---------------------------------------------------------------------------- */
.aurora {
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(circle at 20% 15%, rgba(0, 229, 255, 0.18), transparent 50%),
    radial-gradient(circle at 80% 30%, rgba(255, 0, 200, 0.16), transparent 55%),
    radial-gradient(circle at 50% 90%, rgba(124, 255, 0, 0.14), transparent 55%),
    var(--bg);
  filter: blur(0.5px);
  animation: aurora-shift 30s ease-in-out infinite alternate;
}
@keyframes aurora-shift {
  0%   { background-position: 0% 0%, 100% 0%, 50% 100%; }
  100% { background-position: 20% 10%, 80% 20%, 40% 90%; }
}

/* ----------------------------------------------------------------------------
   Rotierender Rahmen + Titel-Pille
   ---------------------------------------------------------------------------- */
.frame {
  position: relative;
  /* Volle Breite, eckiger oben/unten weil wir bis an den Rand gehen */
  margin: 0 4px;
  border-radius: 14px;
  background: rgba(15, 20, 36, 0.92);
  padding: 22px 10px 18px;
  background-clip: padding-box;
  border: 2px solid transparent;
  box-shadow: 0 0 40px rgba(0, 229, 255, 0.10) inset;
  max-width: calc(100vw - 8px);
  box-sizing: border-box;
}
.frame::before {
  content: "";
  position: absolute;
  inset: -2px;
  z-index: -1;
  border-radius: inherit;
  background: conic-gradient(from 0deg,
    var(--c1), var(--c2), var(--c3), var(--c1));
  animation: spin 8s linear infinite;
}
@keyframes spin {
  to { transform: rotate(360deg); }
}

.title-pill {
  position: absolute;
  top: -12px;
  left: 50%;
  transform: translateX(-50%);
  background: #0C1018;
  border: 1.5px solid;
  border-image: conic-gradient(from 0deg, var(--c1), var(--c2), var(--c3), var(--c1)) 1;
  padding: 3px 14px;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 1px;
  border-radius: 20px;
  background-image:
    linear-gradient(to right, var(--c1), var(--c2), var(--c3));
  -webkit-background-clip: text;
          background-clip: text;
  color: transparent;
  background-color: #0C1018;
  white-space: nowrap;
  text-shadow: 0 0 10px rgba(0, 229, 255, 0.35);
}

/* ----------------------------------------------------------------------------
   Karten / Module
   ---------------------------------------------------------------------------- */
.content {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding-top: 6px;
}

.card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: 12px;
  padding: 12px 14px;
}
.card-title {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.6px;
  text-transform: uppercase;
}

/* Clock */
.clock-time {
  font-size: 2.4rem;
  font-weight: 800;
  letter-spacing: 1px;
  background: linear-gradient(90deg, var(--c1), var(--c2), var(--c3));
  -webkit-background-clip: text;
          background-clip: text;
  color: transparent;
  line-height: 1.0;
}
.clock-date {
  color: var(--muted);
  font-size: 0.9rem;
  margin-top: 4px;
}

/* Speedtest – Verlauf */
.btn-history {
  width: 32px; height: 32px;
  border-radius: 8px;
  background: rgba(0, 229, 255, 0.10);
  border: 1px solid rgba(0, 229, 255, 0.35);
  color: var(--muted);
  font-size: 1rem;
  cursor: pointer;
  -webkit-tap-highlight-color: rgba(0, 229, 255, 0.20);
}
.btn-history:active { color: #fff; background: rgba(0, 229, 255, 0.22); }
.speed-history {
  margin-top: 8px;
  background: rgba(0, 0, 0, 0.30);
  border: 1px solid rgba(0, 229, 255, 0.20);
  border-radius: 8px;
  padding: 6px;
  max-height: 240px;
  overflow-y: auto;
}
.speed-history-row {
  display: grid;
  grid-template-columns: 1fr auto auto auto;
  gap: 8px;
  padding: 4px 6px;
  font-size: 0.82rem;
  color: var(--fg);
  border-bottom: 1px dashed rgba(255,255,255,0.06);
}
.speed-history-row:last-child { border-bottom: none; }
.speed-history-row .when { color: var(--muted); }
.speed-history-row .ping { color: #9EE6FF; font-variant-numeric: tabular-nums; }
.speed-history-row .down { color: #7CFF00; font-weight: 700; font-variant-numeric: tabular-nums; }
.speed-history-row .del  {
  background: transparent; border: none; color: #FF8FB5;
  cursor: pointer; padding: 0 4px; font-size: 0.95rem;
}
.speed-history-empty {
  color: var(--muted);
  font-size: 0.82rem;
  padding: 6px;
  text-align: center;
}
.speed-history-clear {
  width: 100%;
  background: transparent;
  border: 1px dashed rgba(255, 100, 100, 0.40);
  color: #FF8FB5;
  border-radius: 6px;
  padding: 4px;
  margin-top: 4px;
  font-size: 0.78rem;
  cursor: pointer;
}

/* Speedtest */
.speed-row {
  display: flex;
  gap: 16px;
  margin-bottom: 10px;
}
.speed-metric {
  flex: 1 1 0;
}
.speed-caption {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.6px;
  text-transform: uppercase;
}
.speed-value {
  color: #fff;
  font-size: 1.8rem;
  font-weight: 800;
  line-height: 1.1;
}
.speed-unit {
  color: var(--muted);
  font-size: 0.7rem;
}
.speed-status {
  color: var(--muted);
  font-size: 0.8rem;
  margin-top: 6px;
  min-height: 1.2em;
}

/* Notizen & Memos */
.memos-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}
.memos-head .card-title { margin: 0; }
.btn-add-round {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--c1), var(--c3));
  color: #001821;
  border: none;
  font-size: 1.3rem;
  font-weight: 800;
  line-height: 30px;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(0, 229, 255, 0.30);
  -webkit-tap-highlight-color: rgba(0, 229, 255, 0.20);
}
.btn-add-round:active { filter: brightness(0.92); }

.memo-recorder {
  background: rgba(255, 0, 200, 0.06);
  border: 1px solid rgba(255, 0, 200, 0.35);
  border-radius: 10px;
  padding: 10px;
  margin-bottom: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.rec-row {
  display: flex;
  align-items: center;
  gap: 10px;
}
.rec-btn {
  flex: 1 1 auto;
  background: linear-gradient(90deg, #FF00C8, #FFD27A);
  color: #001821;
  border: none;
  border-radius: 8px;
  padding: 10px 14px;
  font-weight: 800;
  cursor: pointer;
}
.rec-btn-stop {
  background: linear-gradient(90deg, #FF6F66, #FFD27A);
}
.rec-btn:active { filter: brightness(0.92); }
.rec-time {
  font-variant-numeric: tabular-nums;
  color: #fff;
  font-weight: 700;
  font-size: 1.05rem;
  min-width: 56px;
  text-align: right;
}
.rec-preview { width: 100%; }
#rec-text {
  width: 100%;
  min-height: 60px;
  resize: vertical;
  background: rgba(0, 0, 0, 0.35);
  color: #fff;
  border: 1px solid rgba(255, 0, 200, 0.30);
  border-radius: 8px;
  padding: 8px 10px;
  font: inherit;
  -webkit-appearance: none;
}
#rec-text:focus { outline: none; border-color: var(--c2); }
.rec-actions {
  display: flex;
  gap: 8px;
}
.rec-actions > * { flex: 1 1 0; }
.rec-hint {
  color: var(--muted);
  font-size: 0.72rem;
  margin: 0;
  line-height: 1.4;
}
.rec-hint code {
  background: rgba(255, 0, 200, 0.18);
  padding: 0 4px;
  border-radius: 4px;
}
.rec-hint.error {
  background: rgba(255, 100, 100, 0.18);
  border: 1px solid rgba(255, 100, 100, 0.40);
  border-radius: 6px;
  padding: 6px 8px;
  color: #FFB0B0;
}

.memo-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.memo-card {
  background: rgba(0, 0, 0, 0.30);
  border: 1px solid rgba(0, 229, 255, 0.18);
  border-radius: 10px;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.memo-card:active { background: rgba(0, 229, 255, 0.10); }
.memo-text {
  color: #FFFFFF;
  font-size: 0.95rem;
  white-space: pre-wrap;
  word-wrap: break-word;
}
.memo-text-empty {
  color: var(--muted);
  font-style: italic;
}
.memo-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: var(--muted);
  font-size: 0.72rem;
}
.memo-meta .memo-del {
  background: transparent;
  color: #FF8FB5;
  border: none;
  font-size: 0.95rem;
  cursor: pointer;
  padding: 2px 4px;
  -webkit-tap-highlight-color: rgba(255, 0, 200, 0.20);
}
.memo-meta .memo-del:active { color: #fff; }
.memo-audio {
  width: 100%;
}
.memo-empty {
  color: var(--muted);
  font-size: 0.85rem;
  padding: 6px 2px;
  text-align: center;
}

/* Geraete-Info */
.kv {
  list-style: none;
  margin: 0; padding: 0;
}
.kv li {
  display: flex;
  justify-content: space-between;
  padding: 4px 0;
  font-size: 0.9rem;
  border-top: 1px dashed rgba(255, 255, 255, 0.06);
}
.kv li:first-child { border-top: none; }
.kv li span:first-child { color: var(--muted); }
.kv li span:last-child  { color: #FFFFFF; max-width: 60%; text-align: right; overflow-wrap: anywhere; }

/* Buttons */
.btn-primary, .btn-ghost {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border-radius: 10px;
  padding: 10px 14px;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  border: none;
  -webkit-appearance: none;
  user-select: none;
}
.btn-primary {
  width: 100%;
  background: linear-gradient(90deg, var(--c1), var(--c3));
  color: #001821;
  box-shadow: 0 4px 16px rgba(0, 229, 255, 0.20);
}
.btn-primary:active { filter: brightness(0.92); }
.btn-primary:disabled { opacity: 0.6; }

.btn-ghost {
  background: transparent;
  color: var(--muted);
  border: 1px dashed rgba(0, 229, 255, 0.45);
}
.btn-ghost:active { color: #fff; border-color: var(--c1); }

/* Hilfe-Karte (App aufs Handy legen) */
.card-help {
  position: relative;
  background: linear-gradient(135deg,
    rgba(0, 229, 255, 0.10),
    rgba(255, 0, 200, 0.08));
  border-color: rgba(0, 229, 255, 0.35);
}
.card-help h3 {
  margin: 12px 0 4px;
  color: #FFFFFF;
  font-size: 0.95rem;
  letter-spacing: 0.3px;
}
.card-help ol {
  margin: 4px 0 8px 22px;
  padding: 0;
  color: var(--fg);
  font-size: 0.9rem;
  line-height: 1.55;
}
.card-help li { margin: 2px 0; }
.card-help strong { color: #FFFFFF; }
.help-lead {
  margin: 0 0 4px;
  color: var(--fg);
  font-size: 0.9rem;
}
.help-block {
  margin-top: 6px;
  padding-top: 6px;
  border-top: 1px dashed rgba(255, 255, 255, 0.10);
}
.help-block:first-of-type { border-top: none; }
.help-tip {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.45;
  background: rgba(0, 0, 0, 0.20);
  padding: 6px 8px;
  border-radius: 6px;
}
.help-foot {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 0.72rem;
  text-align: center;
}
.card-help-x {
  position: absolute;
  top: 6px; right: 6px;
  width: 28px; height: 28px;
  border: none; background: transparent;
  color: var(--muted);
  font-size: 1.2rem;
  cursor: pointer;
  -webkit-tap-highlight-color: rgba(0, 229, 255, 0.20);
}
.card-help-x:active { color: #fff; }
.key {
  display: inline-block;
  background: rgba(255, 255, 255, 0.10);
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 4px;
  padding: 0 6px;
  margin: 0 2px;
  font-weight: 700;
}

/* Netzwerk-Scanner */
.scan-tabs {
  display: flex;
  gap: 4px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  padding: 2px 0 6px;
  margin-bottom: 4px;
  scrollbar-width: thin;
}
.scan-tab {
  background: rgba(0, 229, 255, 0.06);
  color: var(--muted);
  border: 1px solid rgba(0, 229, 255, 0.25);
  border-radius: 14px;
  padding: 4px 10px;
  font-size: 0.8rem;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
}
.scan-tab.active {
  background: rgba(0, 229, 255, 0.22);
  color: #fff;
  border-color: var(--c1);
  box-shadow: 0 0 12px rgba(0, 229, 255, 0.30);
}
.scan-tab .net {
  opacity: 0.65;
  font-weight: 500;
  margin-left: 4px;
  font-size: 0.7rem;
}
.scan-actions {
  display: flex;
  gap: 8px;
  margin-bottom: 6px;
}
.scan-actions .btn-primary { flex: 1 1 0; }
.scan-actions .btn-ghost   { flex: 0 0 auto; padding: 10px 12px; }
.scan-status {
  color: var(--muted);
  font-size: 0.8rem;
  margin: 4px 0 4px;
  min-height: 1.2em;
}
.scan-list {
  display: flex; flex-direction: column;
  gap: 4px;
  margin-top: 4px;
}
.scan-dev {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(124, 255, 0, 0.18);
  border-radius: 8px;
  padding: 8px 10px;
  text-decoration: none;
  color: #fff;
  font-size: 0.95rem;
}
.scan-dev .scan-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: #7CFF00;
  box-shadow: 0 0 10px rgba(124, 255, 0, 0.7);
  flex-shrink: 0;
}
.scan-dev .scan-meta {
  color: var(--muted);
  font-size: 0.75rem;
  margin-left: auto;
  text-align: right;
}
.scan-note {
  color: var(--muted);
  font-size: 0.72rem;
  margin: 8px 0 0;
  line-height: 1.4;
}
.scan-note code {
  background: rgba(0, 229, 255, 0.12);
  padding: 0 4px; border-radius: 4px;
}
.dialog-hint {
  color: var(--muted);
  font-size: 0.72rem;
  margin: 4px 0 0;
  line-height: 1.4;
}

/* Pulse waehrend Speedtest */
.pulsing { animation: pulse-op 1s ease-in-out infinite; }
@keyframes pulse-op {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.55; }
}

/* Footer */
.footer {
  text-align: center;
  color: var(--muted);
  font-size: 0.75rem;
  padding: 10px 0 4px;
  letter-spacing: 0.3px;
}
.footer a { color: var(--c1); text-decoration: none; }
.footer .muted { color: var(--muted); }

/* ----------------------------------------------------------------------------
   Dialog (Link hinzufuegen)
   ---------------------------------------------------------------------------- */
.dialog-backdrop[hidden] { display: none; }
.dialog-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(5, 8, 16, 0.72);
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  backdrop-filter: blur(4px);
}
.dialog {
  width: 100%;
  max-width: 380px;
  background: linear-gradient(180deg, #0F1424, #0A0E1C);
  border: 2px solid var(--c1);
  border-radius: 16px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.dialog h3 {
  margin: 0 0 6px;
  color: #fff;
  font-size: 1.1rem;
}
.dialog label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  color: var(--muted);
  font-size: 0.85rem;
}
.dialog input {
  background: rgba(0, 0, 0, 0.35);
  color: #fff;
  border: 1px solid rgba(0, 229, 255, 0.30);
  border-radius: 8px;
  padding: 8px 10px;
  font: inherit;
  -webkit-appearance: none;
}
.dialog input:focus { outline: none; border-color: var(--c1); }
.dialog-row {
  display: flex;
  gap: 8px;
  margin-top: 6px;
}
.dialog-row > * { flex: 1 1 0; }

/* ----------------------------------------------------------------------------
   Schmale Telefone (< 360px) - Klassen kompakter
   ---------------------------------------------------------------------------- */
@media (max-width: 360px) {
  .clock-time { font-size: 2rem; }
  .speed-value { font-size: 1.5rem; }
  .card { padding: 10px 12px; }
}
