/* Tablet ve mobil uyum */
@media (max-width: 1280px) {
  :root { --side-w: 300px; --drawer-w: 380px; }
  .brand div { display: none; }
}

@media (max-width: 1000px) {
  .stat { min-width: 64px; padding: 2px 8px; }
  .stat b { font-size: 13px; }
}

@media (max-width: 820px) {
  :root { --top-h: 50px; --tool-h: 60px; --drawer-w: 100%; }
  #topbar { gap: 6px; padding: 0 6px; padding-top: env(safe-area-inset-top); height: calc(var(--top-h) + env(safe-area-inset-top)); }
  .brand img { width: 28px; height: 28px; }
  .stats { justify-content: flex-start; }
  .stat { min-width: 0; padding: 2px 7px; }
  .stat small { font-size: 9px; }
  .speed button { padding: 6px 7px; font-size: 12px; }

  #main { flex-direction: column; }
  #toolbar {
    position: fixed; left: 0; right: 0; bottom: 0; width: auto; height: calc(var(--tool-h) + env(safe-area-inset-bottom));
    padding-bottom: env(safe-area-inset-bottom); flex-direction: row; overflow-x: auto; overflow-y: hidden; border-right: 0;
    border-top: 1px solid var(--line); z-index: 30; scrollbar-width: none;
  }
  #toolbar::-webkit-scrollbar { display: none; }
  .tool { flex: 0 0 64px; padding: 6px 2px; }
  #mapcol { flex: 1 1 auto; margin-bottom: calc(var(--tool-h) + env(safe-area-inset-bottom)); }

  #side {
    position: fixed; left: 0; right: 0; width: auto; bottom: calc(var(--tool-h) + env(safe-area-inset-bottom)); height: 62vh;
    border-left: 0; border-top: 1px solid var(--line); border-radius: 18px 18px 0 0; z-index: 25;
    transform: translateY(105%); transition: transform .25s ease; box-shadow: 0 -16px 40px rgba(0, 0, 0, 0.5);
  }
  body.side-open #side { transform: none; }
  .side-toggle {
    display: block; position: absolute; right: 10px; bottom: 10px; z-index: 7; border: 1px solid var(--line);
    background: rgba(14, 28, 54, 0.95); border-radius: 999px; padding: 9px 14px; font-weight: 700; cursor: pointer;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.4);
  }
  .side-toggle b { background: var(--orange); color: #111; border-radius: 999px; padding: 0 6px; margin-left: 4px; }
  .side-toggle.alert { border-color: var(--red); animation: glow 1.2s infinite alternate; }
  @keyframes glow { to { box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.45); } }
  body.drawer-open .side-toggle { display: none; }

  .drawer {
    left: 0; right: 0; top: auto; bottom: 0; width: auto; max-width: none; height: 64%;
    border-radius: 18px 18px 0 0; animation: slideup .22s ease-out; z-index: 26;
  }
  @keyframes slideup { from { transform: translateY(40px); opacity: 0; } to { transform: none; opacity: 1; } }
  .drawer-body { padding: 8px 12px 24px; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .legend { display: none; }
  .nextstep { bottom: 10px; width: calc(100% - 20px); }
  .ns { padding: 10px; gap: 8px; }
  .ns > i { font-size: 22px; }
  .nst em { display: none; }
  .ns .btn.primary { padding: 10px; font-size: 13px; white-space: normal; max-width: 42%; }
  .side-toggle { right: auto; left: 10px; bottom: auto; top: 48px; padding: 7px 12px; font-size: 13px; }
  .clock { font-size: 12px; padding: 4px 8px; }
  .mode-banner { top: auto; bottom: 60px; width: calc(100% - 20px); justify-content: space-between; font-size: 13px; }
  .acts { max-width: 55%; }
  .opts.grid2, .opts.row { grid-template-columns: 1fr; }
  .modal { padding: 16px; border-radius: 16px; }
  .start h1 { font-size: 21px; }
  .btn { padding: 9px 12px; }
  .btn.xs { padding: 6px 8px; }
  .toasts { top: calc(var(--top-h) + env(safe-area-inset-top) + 6px); }
}

@media (max-width: 420px) {
  .speed button[data-v="4"] { display: none; }
  .achgrid { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* Masaüstünde detay paneli açıkken "Sıradaki adım" kartı görünür harita alanına kayar */
@media (min-width: 821px) {
  body.drawer-open .nextstep { left: calc(50% + 215px); width: min(560px, calc(100% - 460px)); }
}
@media (min-width: 821px) and (max-width: 1180px) {
  body.drawer-open .nextstep { display: none; }
}
/* Basit mod — telefon */
@media (max-width: 820px) {
  body.simple .brand { display: none; }
  body.simple #topbar { gap: 6px; }
  body.simple .stats { gap: 5px; }
  body.simple .stat { min-width: 0; flex: 1 1 0; padding: 3px 8px; }
  body.simple .stat b { font-size: 14.5px; }
  body.simple .speed button { padding: 8px 11px; min-width: 42px; }
  body.simple #toolbar { width: auto; }
  body.simple .tool { flex: 1 1 0; padding: 7px 2px; }
  body.simple .tool i { font-size: 24px; }
  body.simple .map-controls { display: none; }
  body.simple .drawer { left: 0; height: 70%; }
  body.simple .clock { top: 8px; }
  .tiles { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
/* Neşeli tema — telefon */
@media (max-width: 820px) {
  body.simple #topbar { margin: 6px 6px 0; height: 56px; border-radius: 16px; padding: 0 6px; }
  .ftile { gap: 4px; padding: 2px 4px; flex-direction: column; align-items: center; text-align: center; }
  .ftile + .ftile { border-left: 0; }
  .ftile i { font-size: 18px; }
  .ftile span { align-items: center; }
  .ftile small, .ftile .fbar { display: none; }
  .ftile b { font-size: 13px; }
  body.simple #main { padding: 6px; gap: 6px; }
  body.simple #toolbar { border-radius: 18px 18px 0 0; box-shadow: 0 -4px 16px rgba(15,39,66,.12); }
  body.simple #map-wrap { border-radius: 18px; }
  body.simple .legend { display: none !important; }
  body.simple .dock { padding-top: 6px; }
  .dock-row { display: block; }
  .dk-city, .dk-status { display: none; }
  .dk-actions { display: grid; grid-auto-flow: column; grid-template-columns: none; grid-auto-columns: 78%; overflow-x: auto; scroll-snap-type: x mandatory; gap: 8px; padding-bottom: 2px; scrollbar-width: none; }
  .dk-actions::-webkit-scrollbar { display: none; }
  .acard { scroll-snap-align: start; padding: 10px; gap: 4px; border-radius: 16px; }
  .acard p { -webkit-line-clamp: 2; font-size: 12px; }
  .acard .btn { padding: 10px; }
  .lvlbar { margin-top: 4px; padding: 2px 6px; font-size: 12px; }
  .lvlbar span { display: none; }
  body.simple .drawer { left: 0; top: auto; }
}
/* Telefon: alt çubukta 4 ana düğme + Menü; diğer ekranlar Menü'de */
@media (max-width: 820px) {
  body.simple #toolbar { width: auto; padding: 0 4px env(safe-area-inset-bottom); gap: 0; overflow: hidden; }
  body.simple .tool.tx, .tgrp { display: none !important; }
  body.simple .tool.mob { display: flex; }
  body.simple .tool { flex: 1 1 0; }
  body.simple .tool.on { box-shadow: inset 0 3px 0 #0ea5e9; }
  .autobtn span { display: none; }
  body.simple .drawer { left: 0; }
}