/* ============================================================
   BUS TRACKER — STYLES
   Mobile-first. Breakpoints: 640px, 1100px
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Source+Sans+3:ital,wght@0,300;0,400;0,600;0,700;1,400&family=Source+Code+Pro:wght@400;500;600&display=swap');

/* ── Reset & base ────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  /* ── HIBP-inspired palette ── */
  /* Accent: red (replaces green for UI chrome) */
  --accent:        #E74C3C;
  --accent-light:  #2D1515;
  --accent-dark:   #C0392B;

  /* Green kept for bus arrivals & positive market moves */
  --green:         #27AE60;
  --green-light:   #0D2D1A;
  --green-dark:    #5DCAA5;

  --amber:         #F39C12;
  --amber-light:   #2D1E00;
  --amber-dark:    #FAC775;

  --red:           #E74C3C;
  --red-light:     #2D1515;
  --red-dark:      #F09595;

  /* Upload mode colours */
  --cal-color:    #27AE60;  --cal-light:   #0D2D1A;  --cal-dark:   #5DCAA5;
  --email-color:  #4A90D9;  --email-light: #0D1E35;  --email-dark: #7ABAFF;
  --enc-color:    #E74C3C;  --enc-light:   #2D1515;  --enc-dark:   #F09595;

  /* Layout */
  --bg:            #1A1A2E;
  --surface:       #12121F;
  --border:        rgba(255,255,255,0.07);
  --border-strong: rgba(255,255,255,0.13);
  --text-primary:  #F0F0F8;
  --text-secondary:#8888AA;
  --text-tertiary: #4A4A66;

  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 10px;

  --font-sans: 'Source Sans 3', system-ui, sans-serif;
  --font-mono: 'Source Code Pro', 'Fira Mono', monospace;

  --tab-bar-h: 60px;
}

/* Light mode override (user toggled) */
[data-theme="light"] {
  --bg:            #F0F0F8;
  --surface:       #FFFFFF;
  --border:        rgba(0,0,0,0.08);
  --border-strong: rgba(0,0,0,0.14);
  --text-primary:  #12121F;
  --text-secondary:#4A4A66;
  --text-tertiary: #8888AA;
  --accent-light:  #FCE8E8;
  --green-light:   #E8F8EE;
  --green-dark:    #1A7A42;
  --amber-light:   #FEF3DC;
  --red-light:     #FCE8E8;
  --cal-light:     #E8F8EE;
  --email-light:   #E8F0FC;
  --enc-light:     #FCE8E8;
}


html { font-size: 16px; -webkit-text-size-adjust: 100%; }

body {
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text-primary);
  min-height: 100dvh;
  padding-bottom: var(--tab-bar-h);
}

.hidden { display: none !important; }

/* ── Header ──────────────────────────────────────────────── */
.app-header {
  background: var(--surface);
  border-bottom: 0.5px solid var(--border-strong);
  padding: 0.75rem 1rem;
  position: sticky;
  top: 0;
  z-index: 200;
}

.header-inner {
  max-width: 1100px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 0.625rem;
}

.header-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.app-title {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 1.0625rem;
  font-weight: 600;
  color: var(--text-primary);
}

.title-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--green);
  flex-shrink: 0;
}

.refresh-btn {
  background: var(--accent);
  border: none;
  border-radius: var(--radius-sm);
  color: #fff;
  font-size: 1.0625rem;
  font-family: var(--font-sans);
  min-height: 44px;
  min-width: 46px;
  padding: 0 10px;
  cursor: pointer;
  flex-shrink: 0;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  transition: opacity 0.15s;
}

.refresh-btn:active   { opacity: 0.75; }
.refresh-btn:disabled { opacity: 0.45; cursor: default; }

/* ── Search bar ──────────────────────────────────────────── */
.search-row { display: flex; gap: 0.5rem; }

.search-input {
  flex: 1;
  background: var(--bg);
  border: 0.5px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 0.5rem 0.875rem;
  font-size: 0.9375rem;
  font-family: var(--font-mono);
  color: var(--text-primary);
  outline: none;
  min-height: 44px;
  transition: border-color 0.15s, box-shadow 0.15s;
  -webkit-appearance: none;
}

.search-input::placeholder { color: var(--text-tertiary); font-family: var(--font-sans); }
.search-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(231,76,60,0.15);
}

.search-go {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  padding: 0 1rem;
  min-height: 44px;
  font-size: 0.9375rem;
  font-family: var(--font-sans);
  font-weight: 500;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.search-go:active { opacity: 0.75; }

/* ── Tab bar ─────────────────────────────────────────────── */
.tab-bar {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: var(--tab-bar-h);
  background: var(--surface);
  border-top: 1px solid var(--border-strong);
  display: flex;
  align-items: stretch;
  z-index: 300;
  padding-bottom: env(safe-area-inset-bottom);
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}
.tab-bar::-webkit-scrollbar { display: none; }

.tab-item {
  flex: 0 0 calc(100% / 6);
  min-width: 54px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-tertiary);
  font-family: var(--font-sans);
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  min-height: 44px;
}

.tab-item.active { color: var(--accent); }
.tab-item.active .tab-label { font-weight: 600; }

.tab-icon  { font-size: 1.375rem; line-height: 1; filter: grayscale(1) opacity(0.45); transition: filter 0.15s; }
.tab-item.active .tab-icon { filter: none; }

.tab-label { font-size: 0.6875rem; font-weight: 500; color: var(--text-tertiary); transition: color 0.15s; }
.tab-item.active .tab-label { color: var(--accent); }

/* ── Views ───────────────────────────────────────────────── */
.view {
  max-width: 1100px;
  margin: 0 auto;
  padding: 1rem;
}

.mrt-view {
  max-width: 100%;
  padding: 0;
  height: calc(100dvh - var(--tab-bar-h) - 52px);
  overflow: auto;
  -webkit-overflow-scrolling: touch;
}
.mrt-img-wrap {
  min-width: 100%;
  min-height: 100%;
  display: flex;
  justify-content: center;
}
.mrt-img {
  width: 100%;
  height: auto;
  display: block;
  user-select: none;
  -webkit-user-drag: none;
}

/* ── Section label ───────────────────────────────────────── */
.section-label {
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-tertiary);
  margin: 1.25rem 0 0.625rem;
}

/* ── Stop grid ───────────────────────────────────────────── */
.stop-grid { display: grid; grid-template-columns: 1fr; gap: 0.75rem; }

@media (min-width: 640px) {
  .stop-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (min-width: 1100px) {
  .stop-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

/* ── Stop card ───────────────────────────────────────────── */
.stop-card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  border: 0.5px solid var(--border);
  padding: 1rem;
  transition: opacity 0.2s;
}

.stop-card.loading { opacity: 0.5; }

.card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 0.75rem;
}

.card-name { font-size: 1rem; font-weight: 600; color: var(--text-primary); line-height: 1.2; }
.card-code { font-size: 0.75rem; color: var(--text-tertiary); font-family: var(--font-mono); margin-top: 2px; }

.custom-badge {
  font-size: 0.6875rem; font-weight: 500;
  background: var(--green-light); color: var(--green-dark);
  padding: 2px 8px; border-radius: 20px;
  white-space: nowrap; flex-shrink: 0; margin-left: 0.5rem;
}

/* ── Bus table ───────────────────────────────────────────── */
.bus-table { width: 100%; border-collapse: collapse; table-layout: fixed; }

.bus-table thead th {
  font-size: 0.6875rem; font-weight: 500;
  color: var(--text-tertiary); text-align: center;
  padding-bottom: 0.375rem; letter-spacing: 0.03em;
}

.bus-table thead th:first-child { text-align: left; }
.bus-table tbody tr { border-top: 0.5px solid var(--border); }

.bus-table tbody td { padding: 0.5rem 0; text-align: center; vertical-align: middle; }
.bus-table tbody td:first-child { text-align: left; }

.col-num   { width: 52px; }
.col-next  { width: calc(50% - 26px); }
.col-after { width: calc(50% - 26px); }

.bus-service-no { font-size: 0.9375rem; font-weight: 500; font-family: var(--font-mono); color: var(--text-primary); }

.arrival-cell { display: flex; flex-direction: column; align-items: center; gap: 3px; }

.arrival-time { font-size: 1rem; font-weight: 500; font-family: var(--font-mono); }
.arrival-time.green { color: var(--arrival-green); }
.arrival-time.amber { color: var(--arrival-green); } /* amber now maps to green */
.arrival-time.red   { color: var(--arrival-red); }
.arrival-time.muted { color: var(--arrival-grey); font-size: 0.8125rem; font-weight: 400; }

.load-pill { font-size: 0.625rem; font-weight: 500; padding: 1px 6px; border-radius: 20px; white-space: nowrap; }
.load-sea { background: var(--green-light); color: var(--green-dark); }
.load-sda { background: var(--amber-light); color: var(--amber-dark); }
.load-lsd { background: var(--red-light);   color: var(--red-dark); }

.no-services { font-size: 0.875rem; color: var(--text-tertiary); text-align: center; padding: 1rem 0 0.5rem; }
.card-error  { font-size: 0.8125rem; color: var(--red); padding: 0.5rem 0; }

/* ── Skeleton ────────────────────────────────────────────── */
.skeleton {
  background: linear-gradient(90deg, var(--border) 25%, var(--border-strong) 50%, var(--border) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.4s infinite;
  border-radius: 4px; height: 14px;
}
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

/* ── Upload view ─────────────────────────────────────────── */
.upload-wrap { max-width: 520px; margin: 0 auto; padding-bottom: 1rem; }

.upload-card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  border: 0.5px solid var(--border);
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.875rem;
}

/* File + photo row */
.upload-row { display: grid; grid-template-columns: 1fr 1fr; gap: 0.75rem; }

.upload-drop-zone {
  border: 1.5px dashed var(--border-strong);
  border-radius: var(--radius-md);
  padding: 1.25rem 0.75rem;
  text-align: center;
  cursor: pointer;
  display: flex; flex-direction: column;
  align-items: center; gap: 0.375rem;
  min-height: 90px; justify-content: center;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  transition: border-color 0.15s, background 0.15s;
}
.upload-drop-zone:active { background: var(--bg); border-color: var(--green); }
.drop-icon  { font-size: 1.625rem; line-height: 1; }
.drop-label { font-size: 0.8125rem; color: var(--text-secondary); font-weight: 500; }
.file-input-hidden { display: none; }

/* Note textarea */
.text-input {
  width: 100%;
  background: var(--bg);
  border: 0.5px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 0.75rem;
  font-size: 0.9375rem;
  font-family: var(--font-sans);
  color: var(--text-primary);
  resize: vertical; outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
  -webkit-appearance: none;
}
.text-input::placeholder { color: var(--text-tertiary); }
.text-input:focus { border-color: var(--green); box-shadow: 0 0 0 3px rgba(29,158,117,0.15); }

/* ── 3 icon options ──────────────────────────────────────── */
.icon-options {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 8px;
}

.icon-opt {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 14px 6px;
  border-radius: var(--radius-md);
  border: 1.5px solid var(--border-strong);
  background: var(--bg);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  transition: all 0.15s;
  position: relative;
}

.opt-icon { font-size: 1.75rem; line-height: 1; }

/* Selected states */
.icon-opt.active-calendar { border-color: var(--cal-color);   background: var(--cal-light); }
.icon-opt.active-email    { border-color: var(--email-color);  background: var(--email-light); }
.icon-opt.active-encrypt  { border-color: var(--enc-color);    background: var(--enc-light); }

/* Active dot indicator */
.icon-opt.active-calendar::after,
.icon-opt.active-email::after,
.icon-opt.active-encrypt::after {
  content: '';
  position: absolute;
  top: 5px; right: 5px;
  width: 7px; height: 7px;
  border-radius: 50%;
}
.icon-opt.active-calendar::after { background: var(--cal-color); }
.icon-opt.active-email::after    { background: var(--email-color); }
.icon-opt.active-encrypt::after  { background: var(--enc-color); }

/* ── Slider ──────────────────────────────────────────────── */
.slider-wrap {
  position: relative;
  height: 52px;
  border-radius: 26px;
  overflow: hidden;
  user-select: none;
  transition: background 0.25s;
}

.slider-wrap.calendar-mode { background: #D5F0E0; }
.slider-wrap.email-mode    { background: #D6E9F8; }
.slider-wrap.encrypt-mode  { background: #F5D5D3; }

.slider-label {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 500;
  pointer-events: none;
  transition: opacity 0.1s;
}
.slider-label.calendar-mode { color: var(--cal-dark); }
.slider-label.email-mode    { color: var(--email-dark); }
.slider-label.encrypt-mode  { color: var(--enc-dark); }

.slider-thumb {
  position: absolute;
  left: 4px; top: 4px;
  width: 44px; height: 44px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 20px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.18);
  cursor: grab;
  transition: background 0.25s, left 0.3s;
}
.slider-thumb.calendar-mode { background: var(--cal-color); }
.slider-thumb.email-mode    { background: var(--email-color); }
.slider-thumb.encrypt-mode  { background: var(--enc-color); }

/* ── Status + progress ───────────────────────────────────── */
.upload-status { font-size: 0.875rem; min-height: 1.25rem; line-height: 1.5; text-align: center; }
.upload-status.idle    { color: var(--text-secondary); }
.upload-status.loading { color: var(--text-secondary); }
.upload-status.success { color: var(--green); }
.upload-status.error   { color: var(--red); }
.upload-status.warn    { color: var(--amber); }

.progress-track { width: 100%; height: 4px; background: var(--border); border-radius: 2px; overflow: hidden; }
.progress-bar   { height: 100%; background: var(--green); border-radius: 2px; width: 0%; transition: width 0.3s ease; }

/* ── FIFA view ───────────────────────────────────────────── */
#view-fifa {
  height: calc(100dvh - var(--tab-bar-h) - 52px);
  overflow: hidden;
  padding: 0;
}
#view-fifa .fifa-wrap {
  height: 100%;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

/* ── Weather view ─────────────────────────────────────────── */
.weather-wrap {
  max-width: 520px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  padding-bottom: 1rem;
}

.weather-search-wrap { position: relative; }
.weather-search-row  { display: flex; gap: 0.5rem; }

.weather-search-input {
  flex: 1;
  background: var(--surface);
  border: 0.5px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 0.5rem 0.875rem;
  font-size: 0.9375rem;
  font-family: var(--font-sans);
  color: var(--text-primary);
  outline: none;
  min-height: 44px;
  transition: border-color 0.15s, box-shadow 0.15s;
  -webkit-appearance: none;
}
.weather-search-input::placeholder { color: var(--text-tertiary); }
.weather-search-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(231,76,60,0.15);
}

.weather-search-btn {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  padding: 0 1rem;
  min-height: 44px;
  font-size: 0.9375rem;
  font-family: var(--font-sans);
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
.weather-search-btn:active { opacity: 0.8; }

.weather-dropdown {
  position: absolute;
  top: calc(100% + 4px);
  left: 0; right: 0;
  background: var(--surface);
  border: 0.5px solid var(--border-strong);
  border-radius: var(--radius-md);
  box-shadow: 0 4px 16px rgba(0,0,0,0.10);
  z-index: 300;
  list-style: none;
  overflow: hidden;
  max-height: 220px;
  overflow-y: auto;
}
.weather-dropdown.hidden { display: none; }

.weather-dropdown-item {
  padding: 0.75rem 1rem;
  font-size: 0.875rem;
  color: var(--text-primary);
  cursor: pointer;
  border-top: 0.5px solid var(--border);
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  line-height: 1.4;
}
.weather-dropdown-item:first-child { border-top: none; }
.weather-dropdown-item:active { background: var(--bg); }

.weather-card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  border: 0.5px solid var(--border);
  padding: 1.125rem;
}

.weather-location {
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 0.5rem;
}

.weather-hero {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 0.625rem 0 1rem;
  gap: 0.5rem;
}
.weather-hero-left { display: flex; align-items: center; gap: 0.625rem; }

#weather-icon { font-size: 3.25rem; line-height: 1; }
#weather-temp {
  font-size: 3rem;
  font-weight: 600;
  color: var(--text-primary);
  font-family: var(--font-mono);
  letter-spacing: -0.03em;
  line-height: 1;
}
#weather-desc {
  font-size: 0.9375rem;
  color: var(--text-secondary);
  font-weight: 500;
  text-align: right;
  flex-shrink: 0;
  max-width: 100px;
  line-height: 1.3;
}

.weather-meta {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.5rem;
}
@media (max-width: 360px) { .weather-meta { grid-template-columns: repeat(2, 1fr); } }

.weather-meta-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
  background: var(--bg);
  border-radius: var(--radius-sm);
  padding: 0.5rem 0.375rem;
  text-align: center;
}
.weather-meta-label {
  font-size: 0.625rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-tertiary);
}
.weather-meta-val {
  font-size: 0.9375rem;
  font-weight: 500;
  color: var(--text-primary);
  font-family: var(--font-mono);
}

.weather-forecast { display: none; }

.weather-forecast-title {
  font-size: 0.625rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 0.875rem;
}

.weather-hourly {
  display: flex;
  gap: 0;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  margin: 0 -1.125rem;
  padding: 0 1.125rem;
}
.weather-hourly::-webkit-scrollbar { display: none; }

.weather-hour {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  min-width: 58px;
  padding: 0.625rem 0.25rem;
  border-right: 0.5px solid var(--border);
  flex-shrink: 0;
  text-align: center;
}
.weather-hour:last-child { border-right: none; }
.weather-hour-time { font-size: 0.6875rem; color: var(--text-tertiary); font-weight: 600; }
.weather-hour-icon { font-size: 1.5rem; line-height: 1; }
.weather-hour-temp { font-size: 0.9375rem; font-weight: 600; color: var(--text-primary); font-family: var(--font-mono); }
.weather-hour-rain { font-size: 0.6875rem; color: #4A90D9; font-weight: 500; }

.weather-loading { color: var(--text-tertiary); font-size: 0.9375rem; text-align: center; padding: 1.5rem 0; }
.weather-error   { color: var(--red); font-size: 0.875rem; text-align: center; padding: 1rem 0; }

.weather-summary-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.5rem;
  margin-top: 0.25rem;
}

/* ── Recipient checkboxes ─────────────────────────────────── */
.recipients-wrap {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
}

.recipients-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-tertiary);
  padding-top: 12px;
  flex-shrink: 0;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.recipients-list {
  display: flex;
  flex-direction: column;
  gap: 0;
  flex: 1;
  background: var(--bg);
  border: 0.5px solid var(--border-strong);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.recipient-item {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  padding: 10px 12px;
  cursor: pointer;
  border-bottom: 0.5px solid var(--border);
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  transition: background 0.1s;
}
.recipient-item:last-child { border-bottom: none; }
.recipient-item:active     { background: var(--surface); }

.recipient-cb {
  width: 18px;
  height: 18px;
  border-radius: 4px;
  accent-color: var(--green);
  cursor: pointer;
  flex-shrink: 0;
}

.recipient-name {
  font-size: 0.9375rem;
  font-weight: 500;
  color: var(--text-primary);
  flex-shrink: 0;
}

.recipient-email {
  font-size: 0.75rem;
  color: var(--text-tertiary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ── Theme toggle ─────────────────────────────────────────── */
.theme-toggle {
  width: 44px; height: 26px; border-radius: 13px;
  background: var(--border-strong); position: relative;
  cursor: pointer; transition: background 0.2s;
  flex-shrink: 0; -webkit-tap-highlight-color: transparent; touch-action: manipulation;
}
.theme-toggle.active { background: var(--green); }
.theme-toggle-knob {
  position: absolute; top: 3px; left: 3px;
  width: 20px; height: 20px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 4px rgba(0,0,0,0.2);
  transition: transform 0.2s;
}
.theme-toggle.active .theme-toggle-knob { transform: translateX(18px); }

/* ── Profile view ─────────────────────────────────────────── */
.profile-wrap {
  max-width: 520px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  padding-bottom: 1rem;
}

/* User card */
.profile-card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  border: 0.5px solid var(--border);
  padding: 1.25rem;
  display: flex;
  align-items: center;
  gap: 1rem;
}

.profile-avatar-wrap {
  flex-shrink: 0;
  width: 56px;
  height: 56px;
  position: relative;
}

.profile-photo {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  object-fit: cover;
}

.profile-photo.hidden { display: none; }

.profile-initials {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 1.25rem;
  font-weight: 600;
  display: none;
  align-items: center;
  justify-content: center;
  letter-spacing: 0.02em;
  font-family: var(--font-sans);
}

.profile-info { flex: 1; min-width: 0; }

.profile-name {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.profile-email {
  font-size: 0.8125rem;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 2px;
}

.profile-provider {
  font-size: 0.6875rem;
  color: var(--text-tertiary);
  margin-top: 4px;
}

/* Sections */
.profile-section {
  background: var(--surface);
  border-radius: var(--radius-lg);
  border: 0.5px solid var(--border);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.profile-section-label {
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-tertiary);
  padding: 0.75rem 1rem 0.25rem;
}

/* Action rows */
.profile-action-btn {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  width: 100%;
  min-height: 52px;
  padding: 0 1rem;
  background: none;
  border: none;
  border-top: 0.5px solid var(--border);
  font-family: var(--font-sans);
  font-size: 0.9375rem;
  color: var(--text-primary);
  cursor: pointer;
  text-align: left;
  text-decoration: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  transition: background 0.1s;
}

.profile-action-btn:first-child { border-top: none; }
.profile-action-btn:active { background: var(--bg); }

.profile-action-static { cursor: default; }
.profile-action-static:active { background: none; }

.profile-action-icon  { font-size: 1.125rem; flex-shrink: 0; }
.profile-action-label { flex: 1; }

.profile-action-value {
  font-size: 0.8125rem;
  color: var(--text-tertiary);
  white-space: nowrap;
}

.profile-action-chevron {
  font-size: 1.125rem;
  color: var(--text-tertiary);
  flex-shrink: 0;
}

/* Sign out — red text */
.profile-signout-btn { color: var(--red); }
.profile-signout-btn .profile-action-icon { filter: none; }

/* ── Notes view ───────────────────────────────────────────── */
.notes-wrap {
  max-width: 520px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  padding-bottom: 1rem;
}

.notes-card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  border: 0.5px solid var(--border);
  padding: 1.125rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.notes-section-label {
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-tertiary);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.notes-status {
  font-size: 0.75rem;
  color: var(--text-tertiary);
  animation: notespulse 1s ease infinite;
}
@keyframes notespulse {
  0%,100% { opacity: 1; } 50% { opacity: 0.3; }
}

/* Remote text — Markdown rendering */
.notes-text-content {
  font-size: 0.9375rem;
  color: var(--text-primary);
  line-height: 1.7;
}
.notes-loading    { color: var(--text-tertiary); font-size: 0.875rem; }
.notes-error      { color: var(--red); font-size: 0.875rem; }

/* ── Markdown styles ── */
.notes-md h1, .notes-md h2, .notes-md h3,
.notes-md h4, .notes-md h5, .notes-md h6 {
  color: var(--text-primary);
  font-weight: 600;
  line-height: 1.3;
  margin: 1.25rem 0 0.5rem;
}
.notes-md h1 { font-size: 1.4rem;   border-bottom: 0.5px solid var(--border-strong); padding-bottom: 0.375rem; }
.notes-md h2 { font-size: 1.175rem; border-bottom: 0.5px solid var(--border); padding-bottom: 0.25rem; }
.notes-md h3 { font-size: 1rem;     color: var(--text-secondary); }
.notes-md h4 { font-size: 0.9375rem; color: var(--text-secondary); }

.notes-md p  { margin: 0.5rem 0; }
.notes-md strong { font-weight: 600; color: var(--text-primary); }
.notes-md em     { font-style: italic; color: var(--text-secondary); }

.notes-md ul, .notes-md ol {
  padding-left: 1.375rem;
  margin: 0.5rem 0;
}
.notes-md li { margin: 0.25rem 0; }
.notes-md li > ul, .notes-md li > ol { margin: 0.125rem 0; }

.notes-md code {
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  background: var(--bg);
  border: 0.5px solid var(--border-strong);
  border-radius: 4px;
  padding: 1px 5px;
  color: var(--green);
}
.notes-md pre {
  background: var(--bg);
  border: 0.5px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 0.875rem;
  overflow-x: auto;
  margin: 0.75rem 0;
  -webkit-overflow-scrolling: touch;
}
.notes-md pre code {
  background: none;
  border: none;
  padding: 0;
  color: var(--text-primary);
  font-size: 0.8125rem;
  line-height: 1.6;
}

.notes-md blockquote {
  border-left: 3px solid var(--green);
  margin: 0.75rem 0;
  padding: 0.25rem 0 0.25rem 0.875rem;
  color: var(--text-secondary);
  font-style: italic;
}
.notes-md blockquote p { margin: 0; }

.notes-md hr {
  border: none;
  border-top: 0.5px solid var(--border-strong);
  margin: 1rem 0;
}

.notes-md a {
  color: var(--green);
  text-decoration: underline;
  text-underline-offset: 2px;
}

/* ── Tables ── */
.notes-table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin: 0.75rem 0;
  border-radius: var(--radius-sm);
  border: 0.5px solid var(--border-strong);
  scrollbar-width: thin;
  scrollbar-color: var(--border-strong) transparent;
}
.notes-table-wrap::-webkit-scrollbar        { height: 4px; }
.notes-table-wrap::-webkit-scrollbar-thumb  { background: var(--border-strong); border-radius: 2px; }
.notes-table-wrap::-webkit-scrollbar-track  { background: transparent; }

.notes-table {
  width: 100%;
  min-width: 320px;
  border-collapse: collapse;
  font-size: 0.875rem;
  white-space: nowrap;
}
.notes-table th {
  background: var(--bg);
  color: var(--text-secondary);
  font-weight: 600;
  font-size: 0.75rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 8px 12px;
  border-bottom: 1.5px solid var(--border-strong);
  text-align: left;
}
.notes-table td {
  padding: 9px 12px;
  border-bottom: 0.5px solid var(--border);
  color: var(--text-primary);
  vertical-align: top;
  white-space: normal;
  min-width: 80px;
}
.notes-table tr:last-child td { border-bottom: none; }
.notes-table tr:hover td { background: var(--bg); }

/* Record button */
.notes-record-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
}

.notes-record-btn {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  background: var(--bg);
  border: 1.5px solid var(--border-strong);
  border-radius: 28px;
  padding: 12px 24px;
  font-family: var(--font-sans);
  font-size: 0.9375rem;
  font-weight: 500;
  color: var(--text-primary);
  cursor: pointer;
  transition: all 0.15s;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  min-height: 52px;
  width: 100%;
  justify-content: center;
}
.notes-record-btn:active  { opacity: 0.8; }
.notes-record-btn.recording {
  background: var(--red);
  border-color: var(--red);
  color: #fff;
  animation: recpulse 1.2s ease-in-out infinite;
}
@keyframes recpulse {
  0%,100% { box-shadow: 0 0 0 0 rgba(226,75,74,0.4); }
  50%     { box-shadow: 0 0 0 8px rgba(226,75,74,0); }
}

.notes-record-icon  { font-size: 1.25rem; line-height: 1; }
.notes-record-timer {
  font-family: var(--font-mono);
  font-size: 0.9375rem;
  color: var(--text-tertiary);
  min-height: 1.25rem;
}

/* Recordings list */
.notes-recordings-list {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.notes-empty {
  font-size: 0.875rem;
  color: var(--text-tertiary);
  text-align: center;
  padding: 0.75rem 0;
}

.notes-rec-item {
  padding: 10px 0;
  border-bottom: 0.5px solid var(--border);
  transition: opacity 0.2s;
}
.notes-rec-item:last-child { border-bottom: none; }

.notes-rec-meta {
  display: flex;
  align-items: baseline;
  gap: 0.625rem;
  margin-bottom: 6px;
}
.notes-rec-ts {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-primary);
}
.notes-rec-dur {
  font-size: 0.75rem;
  color: var(--text-tertiary);
  font-family: var(--font-mono);
}

.notes-rec-actions {
  display: flex;
  gap: 6px;
}

.notes-rec-btn {
  flex: 1;
  padding: 7px 6px;
  border-radius: var(--radius-sm);
  border: 0.5px solid var(--border-strong);
  background: var(--bg);
  font-family: var(--font-sans);
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.12s;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  text-align: center;
}
.notes-rec-btn:active { opacity: 0.7; }

.notes-rec-play   { color: var(--green);  border-color: var(--green);  background: var(--green-light); }
.notes-rec-email  { color: var(--text-secondary); }
.notes-rec-delete { color: var(--red);    border-color: var(--red);    background: var(--red-light); }

.notes-rec-msg {
  font-size: 0.8125rem;
  min-height: 1rem;
  margin-top: 4px;
}

.notes-refresh-btn {
  background: none;
  border: none;
  color: var(--text-tertiary);
  font-size: 1rem;
  cursor: pointer;
  padding: 2px 4px;
  border-radius: 4px;
  transition: color 0.15s, transform 0.2s;
  -webkit-tap-highlight-color: transparent;
}
.notes-refresh-btn:hover  { color: var(--green); }
.notes-refresh-btn:active { transform: rotate(180deg); }

/* ── Tab settings (profile) ──────────────────────────────── */
.tab-settings-list {
  display: flex;
  flex-direction: column;
}

.tab-setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 1rem;
  border-top: 0.5px solid var(--border);
  gap: 0.75rem;
}
.tab-setting-row:first-child { border-top: none; }

.tab-setting-left {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  flex: 1;
}
.tab-setting-icon  { font-size: 1.125rem; }
.tab-setting-label { font-size: 0.9375rem; color: var(--text-primary); }
.tab-setting-locked { font-size: 0.75rem; color: var(--text-tertiary); }

.tab-setting-right {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  flex-shrink: 0;
}

/* Toggle switch */
.tab-toggle-wrap { position: relative; display: inline-flex; align-items: center; cursor: pointer; }
.tab-toggle-cb   { position: absolute; opacity: 0; width: 0; height: 0; }
.tab-toggle-track {
  width: 40px; height: 24px;
  border-radius: 12px;
  background: var(--border-strong);
  position: relative;
  transition: background 0.2s;
}
.tab-toggle-cb:checked + .tab-toggle-track { background: var(--green); }
.tab-toggle-knob {
  position: absolute;
  top: 3px; left: 3px;
  width: 18px; height: 18px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
  transition: transform 0.2s;
}
.tab-toggle-cb:checked + .tab-toggle-track .tab-toggle-knob { transform: translateX(16px); }

/* Order buttons */
.tab-order-btns { display: flex; flex-direction: column; gap: 2px; }
.tab-order-btn {
  background: var(--bg);
  border: 0.5px solid var(--border-strong);
  border-radius: 4px;
  color: var(--text-secondary);
  font-size: 0.6875rem;
  padding: 2px 6px;
  cursor: pointer;
  line-height: 1.4;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.1s;
}
.tab-order-btn:active   { background: var(--surface); }
.tab-order-btn:disabled { opacity: 0.3; cursor: default; }
