/* ============================================================
   TrackTire — Design Tokens
   Subjekt: Boxengasse / Datenlogger-Ästhetik (Timing-Tower, Reifendruck-Gauge)
   ============================================================ */
:root {
  --bg:            #14161A;
  --surface:       #1D2025;
  --surface-raised:#22262C;
  --border:        #2C3138;
  --text:          #EDEFF2;
  --text-muted:    #8B929E;
  --text-faint:    #5B616B;

  --amber:         #FFB238;
  --amber-dim:     #7A5A22;
  --cyan:          #4FD1C5;
  --cyan-dim:      #235049;
  --danger:        #E0654F;

  --font-display: "Barlow Condensed", sans-serif;
  --font-body:    "Inter", sans-serif;
  --font-mono:    "JetBrains Mono", monospace;

  --radius-s: 6px;
  --radius-m: 12px;
  --radius-l: 18px;

  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
}

body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

button, input, select, textarea {
  font-family: inherit;
  color: inherit;
}

a { color: var(--cyan); }

::selection { background: var(--amber-dim); color: var(--text); }

/* ---------- Topbar ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: calc(14px + var(--safe-top)) 18px 14px;
  background: rgba(20, 22, 26, 0.92);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}

.brand { display: flex; align-items: center; gap: 8px; }

.brand-mark {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 3px solid var(--text);
  position: relative;
  flex-shrink: 0;
}
.brand-mark::after {
  content: "";
  position: absolute;
  inset: 5px;
  border-radius: 50%;
  background: var(--amber);
}

.brand-name {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.35rem;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}
.brand-name .accent { color: var(--amber); }
.brand-tld { color: var(--text-faint); font-size: 0.85em; }

/* Positions-Badge (V = Vorderreifen, H = Hinterreifen) */
.pos-badge {
  width: 36px; height: 36px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.05rem;
  border: 2px solid var(--bg);
}
.pos-badge.pos-front { background: var(--cyan); color: #06231F; }
.pos-badge.pos-rear { background: var(--amber); color: #1A1300; }
.pos-badge-inline {
  display: inline-flex;
  width: 26px; height: 26px;
  font-size: 0.85rem;
  vertical-align: middle;
  margin-right: 2px;
}

/* Vorder-/Hinterreifen-Umschalter im Post-Formular */
.pos-toggle {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 16px;
}
.pos-option {
  padding: 12px;
  border-radius: var(--radius-s);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  font-weight: 700;
  font-size: 0.9rem;
}
.pos-option.active {
  border-color: var(--amber);
  background: var(--amber-dim);
  color: var(--amber);
}

.btn-inline { width: auto; padding: 8px 14px; font-size: 0.8rem; margin-bottom: 12px; }

/* Hinweisbanner für unbestätigte E-Mail-Adresse */
.verify-banner {
  display: flex;
  align-items: center;
  gap: 12px;
  background: rgba(255, 178, 56, 0.10);
  border: 1px solid var(--amber-dim);
  border-radius: var(--radius-m);
  padding: 12px 14px;
  margin-bottom: 16px;
}
.verify-banner-text {
  font-size: 0.82rem;
  line-height: 1.4;
  color: var(--text-muted);
  flex: 1;
}
.verify-banner-text strong { color: var(--amber); display: block; margin-bottom: 2px; }
.verify-banner-btn {
  background: var(--amber);
  color: #1A1300;
  border: none;
  border-radius: var(--radius-s);
  padding: 9px 12px;
  font-size: 0.78rem;
  font-weight: 700;
  white-space: nowrap;
  flex-shrink: 0;
}
.verify-banner-btn:disabled { opacity: 0.6; }

/* Kurzmeldungen */
.toast {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: calc(88px + var(--safe-bottom));
  z-index: 60;
  max-width: 90vw;
  background: var(--surface-raised);
  border: 1px solid var(--cyan-dim);
  color: var(--text);
  padding: 12px 18px;
  border-radius: var(--radius-m);
  font-size: 0.85rem;
  line-height: 1.4;
  box-shadow: 0 6px 24px rgba(0,0,0,0.5);
  animation: toast-in 0.25s ease;
}
.toast-error { border-color: var(--danger); color: var(--danger); }
@keyframes toast-in {
  from { opacity: 0; transform: translateX(-50%) translateY(10px); }
  to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* Avatar mit Edit-Knopf */
.avatar-wrap { position: relative; width: 72px; margin: 0 auto 10px; }
.profile-avatar-img {
  width: 72px; height: 72px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--border);
  display: block;
}
.avatar-edit {
  position: absolute;
  bottom: -2px; right: -6px;
  width: 26px; height: 26px;
  border-radius: 50%;
  background: var(--amber);
  color: #1A1300;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.8rem;
  cursor: pointer;
  border: 2px solid var(--surface);
}

/* Motorradbild im Profil */
.moto-image-drop {
  border: 1.5px dashed var(--border);
  border-radius: var(--radius-m);
  aspect-ratio: 16/9;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-faint);
  font-size: 0.85rem;
  overflow: hidden;
  position: relative;
  margin-bottom: 14px;
  background: var(--bg);
}
.moto-image-drop img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.moto-image-drop input[type=file] { position: absolute; inset: 0; opacity: 0; cursor: pointer; }

.topbar-action {
  background: var(--surface-raised);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 7px 14px;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 600;
}
.topbar-action:active { background: var(--border); }

/* ---------- App shell ---------- */
.app {
  flex: 1;
  width: 100%;
  max-width: 560px;
  margin: 0 auto;
  padding: 16px 16px calc(96px + var(--safe-bottom));
}

.screen-title {
  font-family: var(--font-display);
  font-size: 1.6rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  text-transform: uppercase;
  margin: 4px 0 14px;
}

/* ---------- Tabbar ---------- */
.tabbar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 20;
  display: flex;
  justify-content: space-around;
  background: rgba(20, 22, 26, 0.94);
  backdrop-filter: blur(10px);
  border-top: 1px solid var(--border);
  padding: 8px 6px calc(8px + var(--safe-bottom));
}

.tab {
  background: none;
  border: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 4px 10px;
  color: var(--text-faint);
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  flex: 1;
  max-width: 90px;
}
.tab-icon { width: 22px; height: 22px; }
.tab[aria-current="page"] { color: var(--amber); }

.tab-post {
  color: var(--bg);
}
.tab-post .tab-icon {
  background: var(--amber);
  border-radius: 50%;
  padding: 5px;
  width: 30px;
  height: 30px;
  margin-bottom: -2px;
}
.tab-post span { color: var(--text-faint); }

/* ============================================================
   Signature element: Verschleiß-Ring (Reifen-Querschnitt-Gauge)
   Radiales Ringsegment zeigt Zustand des Reifens auf jeder Karte
   ============================================================ */
.wear-ring {
  --pct: 100;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background:
    radial-gradient(closest-side, var(--surface) 62%, transparent 63% 100%),
    conic-gradient(var(--ring-color, var(--amber)) calc(var(--pct) * 1%), rgba(255,255,255,0.12) 0);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.wear-ring-label {
  font-family: var(--font-mono);
  font-size: 0.6rem;
  font-weight: 700;
  color: var(--text);
}

/* ---------- Tire Card ---------- */
.tire-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-l);
  overflow: hidden;
  margin-bottom: 16px;
  position: relative;
}

.tire-card-media {
  position: relative;
  aspect-ratio: 4 / 3;
  background: var(--surface-raised);
  overflow: hidden;
}
.tire-card-media img { width: 100%; height: 100%; object-fit: cover; display: block; }

.tire-card-media::before {
  /* dezente Lauffläche-Textur am linken Rand als Signatur */
  content: "";
  position: absolute;
  top: 0; bottom: 0; left: 0;
  width: 8px;
  background: repeating-linear-gradient(
    0deg, rgba(0,0,0,0.55) 0 4px, rgba(255,255,255,0.06) 4px 6px
  );
  z-index: 2;
}

.tire-card-badge {
  position: absolute;
  top: 10px; right: 10px;
  z-index: 3;
}

.tire-card-body { padding: 12px 14px 14px; }

.tire-card-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 8px;
}

.tire-card-title {
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 600;
  line-height: 1.15;
}
.tire-card-sub {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 2px;
}

/* Telemetrie-Leiste: Rundenzeit / Druck / Temp im Mono-Font wie ein Timing-Screen */
.telemetry-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-s);
  padding: 8px 6px;
  margin-top: 10px;
}
.telemetry-cell { text-align: center; }
.telemetry-value {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 0.9rem;
  color: var(--cyan);
}
.telemetry-value.empty { color: var(--text-faint); }
.telemetry-label {
  font-size: 0.6rem;
  color: var(--text-faint);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-top: 2px;
}

.tire-card-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}
.tag {
  font-size: 0.68rem;
  font-weight: 600;
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--surface-raised);
  border: 1px solid var(--border);
  color: var(--text-muted);
}

.tire-card-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 10px;
  font-size: 0.75rem;
  color: var(--text-faint);
}
.comment-count { display: flex; align-items: center; gap: 4px; }

/* ---------- Forms ---------- */
.field { margin-bottom: 14px; }
.field label {
  display: block;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  margin-bottom: 6px;
}
.field input, .field select, .field textarea {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-s);
  padding: 11px 12px;
  font-size: 0.95rem;
  color: var(--text);
}
.field input:focus, .field select:focus, .field textarea:focus {
  outline: 2px solid var(--amber);
  outline-offset: 1px;
  border-color: var(--amber);
}
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.field-hint { font-size: 0.72rem; color: var(--text-faint); margin-top: 4px; }

/* Setup-Schieberegler (Gabel/Federbein) */
.slider-field label {
  display: flex;
  align-items: baseline;
  gap: 5px;
  text-transform: none;
  font-weight: 500;
  color: var(--text);
  font-size: 0.88rem;
}
.slider-value {
  font-family: var(--font-mono);
  font-weight: 700;
  color: var(--amber);
  font-size: 0.95rem;
}
input[type="range"].range-input {
  width: 100%;
  height: 32px;
  padding: 0;
  background: none;
  border: none;
  -webkit-appearance: none;
  appearance: none;
}
input[type="range"].range-input::-webkit-slider-runnable-track {
  height: 4px;
  background: var(--border);
  border-radius: 2px;
}
input[type="range"].range-input::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 20px; height: 20px;
  border-radius: 50%;
  background: var(--amber);
  border: 3px solid var(--bg);
  box-shadow: 0 0 0 1px var(--amber);
  margin-top: -8px;
}
input[type="range"].range-input::-moz-range-track {
  height: 4px;
  background: var(--border);
  border-radius: 2px;
}
input[type="range"].range-input::-moz-range-thumb {
  width: 20px; height: 20px;
  border-radius: 50%;
  background: var(--amber);
  border: 3px solid var(--bg);
  box-shadow: 0 0 0 1px var(--amber);
}

/* Setup-Block in der Detailansicht */
.setup-block {
  border: 1px solid var(--border);
  border-radius: var(--radius-m);
  padding: 12px 14px;
  margin-bottom: 14px;
}
.setup-block-title {
  font-family: var(--font-display);
  font-size: 1rem;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  color: var(--amber);
  margin-bottom: 8px;
}
.setup-rows { display: flex; flex-direction: column; gap: 6px; }
.setup-row {
  display: flex;
  justify-content: space-between;
  font-size: 0.85rem;
  padding: 3px 0;
  border-bottom: 1px solid var(--border);
}
.setup-row:last-child { border-bottom: none; }
.setup-row-label { color: var(--text-muted); }
.setup-row-value { font-family: var(--font-mono); color: var(--cyan); font-weight: 600; }

fieldset {
  border: 1px solid var(--border);
  border-radius: var(--radius-m);
  padding: 12px 14px 4px;
  margin: 0 0 16px;
}
legend {
  font-family: var(--font-display);
  font-size: 0.95rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--amber);
  padding: 0 6px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: 100%;
  padding: 13px 16px;
  border-radius: var(--radius-s);
  border: none;
  font-weight: 700;
  font-size: 0.95rem;
  cursor: pointer;
}
.btn-primary { background: var(--amber); color: #1A1300; }
.btn-primary:active { background: #E6A030; }
.btn-secondary { background: var(--surface-raised); color: var(--text); border: 1px solid var(--border); }
.btn-ghost { background: none; color: var(--cyan); border: 1px solid var(--cyan-dim); }
.btn:disabled { opacity: 0.5; }

.image-drop {
  border: 1.5px dashed var(--border);
  border-radius: var(--radius-m);
  aspect-ratio: 4/3;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 8px;
  color: var(--text-faint);
  font-size: 0.82rem;
  overflow: hidden;
  position: relative;
  margin-bottom: 16px;
  background: var(--surface);
}
.image-drop img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.image-drop input[type=file] { position: absolute; inset: 0; opacity: 0; cursor: pointer; }

/* ---------- Search ---------- */
.search-bar {
  display: flex;
  gap: 8px;
  margin-bottom: 14px;
}
.search-bar input {
  flex: 1;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 11px 16px;
  font-size: 0.95rem;
}
.filter-toggle {
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: 999px;
  width: 42px;
  color: var(--amber);
}

.filter-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-m);
  padding: 14px;
  margin-bottom: 16px;
}

.chip-group { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 4px; }
.chip {
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 0.78rem;
  color: var(--text-muted);
}
.chip.active { background: var(--amber-dim); border-color: var(--amber); color: var(--amber); }

/* ---------- Empty / loading states ---------- */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-faint);
}
.empty-state .title { font-family: var(--font-display); font-size: 1.3rem; color: var(--text-muted); margin-bottom: 6px; }

.skeleton {
  background: linear-gradient(90deg, var(--surface) 25%, var(--surface-raised) 37%, var(--surface) 63%);
  background-size: 400% 100%;
  animation: shimmer 1.4s ease infinite;
  border-radius: var(--radius-l);
  aspect-ratio: 4/3;
  margin-bottom: 16px;
}
@keyframes shimmer { 0% { background-position: 100% 0; } 100% { background-position: -100% 0; } }

/* ---------- Detail screen ---------- */
.detail-hero {
  border-radius: var(--radius-l);
  overflow: hidden;
  margin-bottom: 14px;
  border: 1px solid var(--border);
}
.detail-hero img { width: 100%; display: block; aspect-ratio: 4/3; object-fit: cover; }

.spec-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1px;
  background: var(--border);
  border: 1px solid var(--border);
  border-radius: var(--radius-m);
  overflow: hidden;
  margin: 14px 0;
}
.spec-cell { background: var(--surface); padding: 10px 12px; }
.spec-label { font-size: 0.65rem; color: var(--text-faint); text-transform: uppercase; letter-spacing: 0.04em; }
.spec-value { font-family: var(--font-mono); font-size: 0.92rem; margin-top: 2px; }
.spec-value.accent { color: var(--cyan); font-weight: 700; }

.comment {
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.comment:last-child { border-bottom: none; }
.comment-author { font-weight: 600; font-size: 0.85rem; }
.comment-text { font-size: 0.9rem; color: var(--text-muted); margin-top: 2px; }
.comment-time { font-size: 0.68rem; color: var(--text-faint); margin-top: 2px; }

.comment-input-row {
  display: flex;
  gap: 8px;
  margin-top: 14px;
}
.comment-input-row input {
  flex: 1;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 10px 16px;
  font-size: 0.9rem;
}
.comment-send {
  background: var(--amber);
  color: #1A1300;
  border: none;
  border-radius: 50%;
  width: 42px; height: 42px;
  flex-shrink: 0;
  font-weight: 700;
}

/* ---------- Modal (Login/Register) ---------- */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(10,11,13,0.7);
  z-index: 50;
  display: flex;
  align-items: flex-end;
}
.modal-sheet {
  background: var(--surface);
  border-top: 1px solid var(--border);
  border-radius: 20px 20px 0 0;
  width: 100%;
  max-width: 560px;
  margin: 0 auto;
  padding: 22px 20px calc(24px + var(--safe-bottom));
  max-height: 88vh;
  overflow-y: auto;
}
.modal-title {
  font-family: var(--font-display);
  font-size: 1.4rem;
  text-transform: uppercase;
  margin-bottom: 4px;
}
.modal-sub { font-size: 0.85rem; color: var(--text-muted); margin-bottom: 18px; }
.modal-switch { text-align: center; margin-top: 14px; font-size: 0.85rem; color: var(--text-muted); }
.modal-switch button { background: none; border: none; color: var(--cyan); font-weight: 600; }
.modal-close {
  position: absolute; top: 14px; right: 16px;
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: 50%;
  width: 30px; height: 30px;
  color: var(--text-muted);
}
.modal-sheet { position: relative; }

.error-banner {
  background: rgba(224, 101, 79, 0.12);
  border: 1px solid var(--danger);
  color: var(--danger);
  padding: 10px 12px;
  border-radius: var(--radius-s);
  font-size: 0.85rem;
  margin-bottom: 12px;
}

.profile-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-m);
  padding: 18px;
  text-align: center;
  margin-bottom: 20px;
}
.profile-avatar {
  width: 60px; height: 60px;
  border-radius: 50%;
  background: var(--amber-dim);
  color: var(--amber);
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-display);
  font-size: 1.6rem;
  margin: 0 auto 10px;
}
.profile-name { font-family: var(--font-display); font-size: 1.3rem; }
.profile-email { color: var(--text-muted); font-size: 0.85rem; }

@media (min-width: 560px) {
  .app { padding-left: 0; padding-right: 0; }
}
