/* shadcn-inspired tokens: neutral surfaces, hairline borders, no motion. */
:root{
  --background:#ffffff;
  --foreground:#09090b;
  --card:#ffffff;
  --muted:#f4f4f5;
  --muted-foreground:#71717a;
  --border:#e4e4e7;
  --input:#e4e4e7;
  --primary:#18181b;
  --primary-foreground:#fafafa;
  --accent:#f4f4f5;
  --destructive:#dc2626;
  --ring:#a1a1aa;
  --radius:10px;
}

@media (prefers-color-scheme:dark){
  :root{
    --background:#09090b;
    --foreground:#fafafa;
    --card:#0c0c0f;
    --muted:#18181b;
    --muted-foreground:#a1a1aa;
    --border:#27272a;
    --input:#27272a;
    --primary:#fafafa;
    --primary-foreground:#18181b;
    --accent:#1c1c1f;
    --destructive:#ef4444;
    --ring:#52525b;
  }
}

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

/* class-level display rules below outrank the UA [hidden] rule, so restate it */
[hidden]{display:none !important}

html{-webkit-text-size-adjust:100%}

body{
  background:var(--background);
  color:var(--foreground);
  font-family:ui-sans-serif,system-ui,-apple-system,"Segoe UI",Roboto,"Helvetica Neue",Arial,sans-serif;
  font-size:15px;
  line-height:1.5;
  -webkit-font-smoothing:antialiased;
  padding-bottom:env(safe-area-inset-bottom);
}

button,input{font:inherit;color:inherit}
button{background:none;border:none;cursor:pointer}

h1,h2,h3{font-weight:600;letter-spacing:-0.01em}
h2{font-size:17px}

.muted{color:var(--muted-foreground);font-size:13px}

/* ---------- top bar ---------- */

.topbar{
  position:sticky;
  top:0;
  z-index:20;
  background:var(--background);
  border-bottom:1px solid var(--border);
  padding:14px 16px 0;
}

.brand{font-size:20px}

.tabs{display:flex;gap:20px;margin-top:12px}

.tab{
  padding:0 0 10px;
  font-size:14px;
  font-weight:500;
  color:var(--muted-foreground);
  border-bottom:2px solid transparent;
  margin-bottom:-1px;
}

.tab[aria-selected="true"]{color:var(--foreground);border-bottom-color:var(--primary)}

.page{max-width:560px;margin:0 auto;padding:18px 16px 48px}

/* ---------- month bar ---------- */

.month-bar{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:8px;
  margin-bottom:14px;
}

.month-title{text-align:center}
.month-title h2{font-size:18px}

.icon-btn{
  width:38px;
  height:38px;
  flex:none;
  display:flex;
  align-items:center;
  justify-content:center;
  font-size:22px;
  line-height:1;
  color:var(--muted-foreground);
  border:1px solid var(--border);
  border-radius:var(--radius);
  background:var(--card);
}

.icon-btn:active{background:var(--accent)}

/* ---------- calendar ---------- */

.card{
  background:var(--card);
  border:1px solid var(--border);
  border-radius:14px;
}

.calendar{padding:10px;overflow:hidden}

.weekdays,.grid{
  display:grid;
  grid-template-columns:repeat(7,1fr);
  gap:4px;
}

.weekdays span{
  text-align:center;
  font-size:11px;
  font-weight:500;
  letter-spacing:0.04em;
  text-transform:uppercase;
  color:var(--muted-foreground);
  padding-bottom:6px;
}

.day{
  position:relative;
  aspect-ratio:1;
  display:flex;
  flex-direction:column;
  align-items:center;
  justify-content:center;
  gap:4px;
  border-radius:8px;
  font-size:14px;
  font-variant-numeric:tabular-nums;
  border:1px solid transparent;
}

.day.pad{color:var(--muted-foreground);opacity:.4}
.day.today{border-color:var(--ring);font-weight:600}
.day.has{background:var(--muted)}
.day.selected{background:var(--primary);color:var(--primary-foreground)}
.day:active{background:var(--accent)}
.day.selected:active{background:var(--primary)}

.dots{display:flex;gap:3px;height:5px}

.dot{
  width:5px;
  height:5px;
  border-radius:50%;
  background:var(--foreground);
}

.day.selected .dot{background:var(--primary-foreground)}
.day.pad .dot{background:var(--muted-foreground)}

.month-actions{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
  margin-top:14px;
}

.hint{margin-left:auto;text-align:right}

/* ---------- buttons ---------- */

.btn,.btn-ghost,.btn-danger{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  height:40px;
  padding:0 16px;
  border-radius:var(--radius);
  font-size:14px;
  font-weight:500;
  border:1px solid transparent;
}

.btn{background:var(--primary);color:var(--primary-foreground)}
.btn:active{opacity:.9}

.btn-ghost{background:var(--card);border-color:var(--border)}
.btn-ghost:active{background:var(--accent)}

.btn-danger{background:var(--card);border-color:var(--border);color:var(--destructive)}
.btn-danger:active{background:var(--accent)}

.btn-block{width:100%}

/* ---------- upcoming ---------- */

.section-head{
  display:flex;
  align-items:flex-start;
  justify-content:space-between;
  gap:12px;
  margin-bottom:14px;
}

.group-label{
  font-size:11px;
  font-weight:600;
  letter-spacing:0.06em;
  text-transform:uppercase;
  color:var(--muted-foreground);
  margin:20px 0 8px;
}

.group-label:first-child{margin-top:0}

.journey-card{
  display:block;
  width:100%;
  text-align:left;
  background:var(--card);
  border:1px solid var(--border);
  border-radius:14px;
  padding:14px;
  margin-bottom:10px;
}

.journey-card:active{background:var(--accent)}

.journey-top{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:10px;
  margin-bottom:12px;
}

.journey-title{font-size:15px;font-weight:600}

.badge{
  flex:none;
  font-size:11px;
  font-weight:500;
  padding:3px 8px;
  border-radius:999px;
  background:var(--muted);
  color:var(--muted-foreground);
  white-space:nowrap;
}

.route{
  display:grid;
  grid-template-columns:1fr auto 1fr;
  align-items:start;
  gap:10px;
}

.stop{min-width:0}
.stop.arrive{text-align:right}

.stop-label{
  font-size:10px;
  font-weight:600;
  letter-spacing:0.06em;
  text-transform:uppercase;
  color:var(--muted-foreground);
}

.stop-name{
  font-size:15px;
  font-weight:600;
  overflow:hidden;
  text-overflow:ellipsis;
  white-space:nowrap;
}

.stop-when{font-size:12px;color:var(--muted-foreground);font-variant-numeric:tabular-nums}

.leg{
  align-self:start;
  padding-top:22px;
  text-align:center;
  color:var(--muted-foreground);
  min-width:64px;
}

.leg-arrow{display:flex;align-items:center}

.leg-line{
  flex:1;
  height:1px;
  background:currentColor;
}

.leg-arrow svg{
  flex:none;
  fill:none;
  stroke:currentColor;
  stroke-width:1.5;
  stroke-linecap:round;
  stroke-linejoin:round;
}

.leg-note{
  font-size:11px;
  margin-top:4px;
  font-variant-numeric:tabular-nums;
}

.meta-row{
  display:flex;
  flex-wrap:wrap;
  gap:6px;
  margin-top:12px;
  padding-top:10px;
  border-top:1px solid var(--border);
}

.empty{
  border:1px dashed var(--border);
  border-radius:14px;
  padding:28px 16px;
  text-align:center;
  color:var(--muted-foreground);
  font-size:14px;
}

/* ---------- sheet ---------- */

.overlay{
  position:fixed;
  inset:0;
  z-index:40;
  background:rgba(0,0,0,.45);
  display:flex;
  align-items:flex-end;
  justify-content:center;
}

.sheet{
  width:100%;
  max-width:560px;
  max-height:92vh;
  display:flex;
  flex-direction:column;
  background:var(--card);
  border:1px solid var(--border);
  border-radius:16px 16px 0 0;
}

@media (min-width:640px){
  .overlay{align-items:center;padding:24px}
  .sheet{border-radius:16px}
}

.sheet-head{
  display:flex;
  align-items:flex-start;
  justify-content:space-between;
  gap:12px;
  padding:16px 16px 12px;
  border-bottom:1px solid var(--border);
}

.sheet-body{
  padding:16px;
  overflow-y:auto;
  -webkit-overflow-scrolling:touch;
  padding-bottom:calc(16px + env(safe-area-inset-bottom));
}

/* ---------- form ---------- */

.import{
  display:flex;
  align-items:center;
  gap:12px;
  padding:12px;
  margin-bottom:16px;
  border:1px dashed var(--border);
  border-radius:var(--radius);
}

.import-text{min-width:0;flex:1}
.import-title{font-size:13px;font-weight:500}
.import .muted{overflow-wrap:anywhere}
.import button{flex:none;height:36px}
.import button:disabled{opacity:.6}

.field{margin-bottom:12px}

.field label{
  display:block;
  font-size:13px;
  font-weight:500;
  margin-bottom:6px;
}

.field input{
  width:100%;
  height:40px;
  padding:0 12px;
  background:var(--background);
  border:1px solid var(--input);
  border-radius:var(--radius);
  outline:none;
}

.field input:focus{border-color:var(--ring)}
.field input::placeholder{color:var(--muted-foreground)}

.pair{display:grid;grid-template-columns:1fr 1fr;gap:10px}

.form-actions{display:flex;gap:10px;margin-top:18px}
.form-actions .btn{flex:1}

.error{color:var(--destructive);font-size:13px;margin-bottom:12px}

/* ---------- toast ---------- */

.toast{
  position:fixed;
  left:50%;
  bottom:24px;
  transform:translateX(-50%);
  z-index:60;
  background:var(--primary);
  color:var(--primary-foreground);
  font-size:13px;
  padding:9px 14px;
  border-radius:var(--radius);
  max-width:90vw;
}

/* ---------- print ---------- */

@media print{
  .topbar,.month-actions,.section-head button,.overlay,.toast{display:none !important}
  body{background:#fff;color:#000}
  .page{max-width:none;padding:0}
  .journey-card{break-inside:avoid;border-color:#000}
}
