:root{
  --bg: #0b0f17;
  --panel: #0f1624;
  --panel2:#101a2c;
  --text:#e9eefb;
  --muted:#aab6d3;
  --line:#23304a;
  --accent:#7aa2ff;
  --accent-soft: rgba(122,162,255,.14);
  --accent-strong: rgba(122,162,255,.22);
  --accent-border: rgba(122,162,255,.40);
  --accent-shadow: rgba(122,162,255,.35);

  --panel-border: rgba(255,255,255,.08);
  --panel-border-strong: rgba(255,255,255,.12);
  --panel-border-soft: rgba(255,255,255,.06);
  --panel-soft: rgba(255,255,255,.06);
  --panel-soft-strong: rgba(255,255,255,.10);
  --panel-surface: rgba(16,26,44,.55);
  --panel-surface-strong: rgba(15,22,36,.70);
  --panel-surface-alt: rgba(15,22,36,.55);
  --panel-surface-deep: rgba(15,22,36,.92);

  --ink-strong: rgba(233,238,251,.92);
  --ink: rgba(233,238,251,.82);
  --ink-muted: rgba(233,238,251,.72);
  --ink-dim: rgba(233,238,251,.68);
  --ink-soft: rgba(233,238,251,.78);
  --row-hover: rgba(255,255,255,.04);

  --food:#3ddc97;
  --activity:#7aa2ff;
  --transport:#f6c177;
  --event:#ff7aa2;
  --rest:#9aa0b5;

  --shadow: 0 14px 40px rgba(0,0,0,.45);
  --radius: 18px;
}

body[data-theme="light"]{
  --bg: #f4f6fb;
  --panel: #ffffff;
  --panel2:#eef2f8;
  --text:#1b2333;
  --muted:#51607a;
  --line:#d6deeb;
  --accent:#3b6df6;
  --accent-soft: rgba(59,109,246,.12);
  --accent-strong: rgba(59,109,246,.18);
  --accent-border: rgba(59,109,246,.38);
  --accent-shadow: rgba(59,109,246,.25);

  --panel-border: rgba(15,25,40,.12);
  --panel-border-strong: rgba(15,25,40,.16);
  --panel-border-soft: rgba(15,25,40,.08);
  --panel-soft: rgba(15,25,40,.05);
  --panel-soft-strong: rgba(15,25,40,.10);
  --panel-surface: rgba(255,255,255,.78);
  --panel-surface-strong: rgba(255,255,255,.92);
  --panel-surface-alt: rgba(245,247,252,.92);
  --panel-surface-deep: rgba(255,255,255,.98);

  --ink-strong: rgba(27,35,51,.96);
  --ink: rgba(27,35,51,.86);
  --ink-muted: rgba(27,35,51,.72);
  --ink-dim: rgba(27,35,51,.62);
  --ink-soft: rgba(27,35,51,.78);
  --row-hover: rgba(15,25,40,.04);

  --shadow: 0 12px 32px rgba(18,25,38,.16);
}

*{ box-sizing:border-box; }
html,body{ height:100%; }
body{
  margin:0;
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, "Apple Color Emoji","Segoe UI Emoji";
  background: radial-gradient(900px 600px at 30% -10%, rgba(122,162,255,.22), transparent 50%),
              radial-gradient(900px 600px at 90% 10%, rgba(61,220,151,.14), transparent 55%),
              var(--bg);
  color:var(--text);
  overflow:hidden;
  display:flex;
  flex-direction:column;
}
body[data-theme="light"]{
  background: radial-gradient(900px 600px at 20% -10%, rgba(59,109,246,.12), transparent 55%),
              radial-gradient(900px 600px at 95% 8%, rgba(61,220,151,.16), transparent 60%),
              var(--bg);
}

.app{
  flex:1;
  min-height:0;
  display:grid;
  grid-template-columns: 440px 520px 1fr;
}

.sidebar{
  display:flex;
  flex-direction:column;
  background: linear-gradient(180deg, var(--panel-surface-strong), var(--panel-surface));
  border-right:1px solid var(--panel-border-soft);
  min-width: 320px;
  min-height:0;
  overflow:hidden;
}

.sidebar__header{
  padding:12px 16px 8px;
  border-bottom:1px solid var(--panel-border-soft);
}

.titleBlock h1{
  margin:0;
  font-size:14px;
  letter-spacing:.2px;
  white-space:nowrap;
  overflow:hidden;
  text-overflow:ellipsis;
}

.controls{
  margin-top:10px;
  display:grid;
  gap:8px;
}

.control{
  display:grid;
  gap:4px;
}
.control span{
  font-size:11px;
  color:var(--muted);
}
.control--toggle{
  grid-template-columns: auto 1fr;
  align-items:center;
  gap:10px;
  display:grid;
}
.control--toggle input{
  width:16px;
  height:16px;
  accent-color: var(--accent);
}
input[type="search"]{
  width:100%;
  padding:8px 10px;
  border-radius:10px;
  border:1px solid var(--panel-border);
  background: var(--panel-surface);
  color:var(--text);
  outline:none;
}
select{
  width:100%;
  padding:8px 10px;
  border-radius:10px;
  border:1px solid var(--panel-border);
  background: var(--panel-surface);
  color:var(--text);
  outline:none;
}
input[type="search"]:focus{
  border-color: var(--accent-border);
  box-shadow: 0 0 0 4px var(--accent-soft);
}
select:focus{
  border-color: var(--accent-border);
  box-shadow: 0 0 0 4px var(--accent-soft);
}

.dayBarWrap{ display:flex; }
.dayBar{
  display:flex;
  flex-wrap:wrap;
  gap:2px;
  width:100%;
}
.dayBtn{
  padding:3px 6px;
  border-radius:999px;
  border:1px solid var(--panel-border);
  background: var(--panel-soft);
  color:var(--ink-strong);
  cursor:pointer;
  transition: .12s transform ease, .12s background ease, .12s border ease;
  font-size:10px;
  user-select:none;
  white-space:nowrap;
}
.dayBtn:hover{
  transform: translateY(-1px);
  background: var(--accent-soft);
  border-color: var(--accent-border);
}
.dayBtn:active{ transform: translateY(0); }
.dayBtn[aria-pressed="true"]{
  background: var(--accent-strong);
  border-color: var(--accent-border);
}
.dayBtn--meta{
  background: var(--panel-soft);
  border-color: var(--panel-border);
  color: var(--ink-soft);
}

.btnRow{
  display:flex;
  gap:8px;
}
.btn{
  flex:1;
  padding:8px 10px;
  border-radius:10px;
  border:1px solid var(--panel-border);
  background: var(--accent-soft);
  color:var(--text);
  cursor:pointer;
  transition:.15s transform ease, .15s background ease, .15s border ease;
}
.btn:hover{
  transform: translateY(-1px);
  background: var(--accent-strong);
  border-color: var(--accent-border);
}
.btn:active{ transform: translateY(0); }

.btn--ghost{
  background: var(--panel-soft);
}
.btn--ghost:hover{
  background: var(--panel-soft-strong);
  border-color: var(--panel-border-strong);
}

.legend{
  margin-top:10px;
  padding:10px;
  border-radius:12px;
  border:1px solid var(--panel-border);
  background: var(--panel-surface);
}
.legend__title{
  font-size:11px;
  color:var(--muted);
  margin-bottom:6px;
}
.legend__grid{
  display:flex;
  flex-wrap:nowrap;
  gap:4px;
}
.chip{
  font-size:10px;
  padding:3px 6px;
  border-radius:999px;
  border:1px solid var(--panel-border-strong);
  background: var(--panel-soft);
  color: var(--ink-strong);
  cursor:pointer;
  transition: .12s transform ease, .12s background ease, .12s opacity ease;
  white-space:nowrap;
}
.chip:hover{ transform: translateY(-1px); }
.chip:active{ transform: translateY(0); }
.chip[aria-pressed="false"]{ opacity: .45; }

.chip--food{ border-color: rgba(61,220,151,.35); }
.chip--activity{ border-color: rgba(122,162,255,.40); }
.chip--transport{ border-color: rgba(246,193,119,.42); }
.chip--event{ border-color: rgba(255,122,162,.40); }
.chip--rest{ border-color: rgba(154,160,181,.40); }

.legend__hint{
  margin-top:8px;
  font-size:11px;
  color:var(--ink-soft);
  line-height:1.35;
}

.scheduleColumn{
  display:flex;
  flex-direction:column;
  background: linear-gradient(180deg, var(--panel-surface-strong), var(--panel-surface));
  border-right:1px solid var(--panel-border-soft);
  min-height:0;
}

/* Scrollbar on the LEFT */
.tableWrap{
  flex:1;
  overflow:auto;
  direction: rtl;
  min-height:0;
  overscroll-behavior: contain;
}
.tableInner{
  direction: ltr;
  padding: 10px 16px 16px;
  display:grid;
  gap: 8px;
}

.dayNode{
  border:1px solid var(--panel-border);
  background: var(--panel-surface);
  border-radius: 16px;
  overflow:hidden;
}
.dayNode summary{
  list-style:none;
  cursor:pointer;
  padding:8px 10px;
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:10px;
}
.dayNode summary::-webkit-details-marker{ display:none; }
.daySummaryLeft{ display:flex; flex-direction:column; gap:2px; }
.daySummaryTitle{ font-weight:750; font-size:12px; }
.daySummarySub{ color: var(--ink-muted); font-size:11px; }
.daySummaryMeta{ color: var(--ink-dim); font-size:11px; white-space:nowrap; }

.dayTable{
  width:100%;
  border-collapse:collapse;
  font-size:12px;
}
.dayTable thead th{
  text-align:left;
  padding:8px 8px;
  background: var(--panel-surface-alt);
  border-top:1px solid var(--panel-border-soft);
  border-bottom:1px solid var(--panel-border-soft);
  color:var(--muted);
  font-weight:650;
}
.dayTable tbody td{
  padding:8px 8px;
  border-bottom:1px solid var(--panel-border-soft);
  vertical-align:top;
}

.colTime{ width:66px; white-space:nowrap; }
.colType{ width:110px; }
.colArea{ width:120px; }
.colLinks{ width:160px; }

.row{
  cursor:pointer;
  transition: background .12s ease;
}
.row:hover{ background: var(--row-hover); }
.row--active{
  background: var(--accent-soft) !important;
  outline: 1px solid var(--accent-border);
}
.row--filtered{
  opacity:0.12;
  pointer-events:none;
}

.badge{
  display:inline-flex;
  align-items:center;
  gap:6px;
  font-size:11px;
  padding:3px 8px;
  border-radius:999px;
  border:1px solid var(--panel-border-strong);
  background: var(--panel-soft);
}
.dot{ width:8px; height:8px; border-radius:50%; background: rgba(255,255,255,.35); }
.badge--food .dot{ background: var(--food); }
.badge--activity .dot{ background: var(--activity); }
.badge--transport .dot{ background: var(--transport); }
.badge--event .dot{ background: var(--event); }
.badge--rest .dot{ background: var(--rest); }

.titleCell .mainTitle{ font-weight: 650; }
.titleCell .mainTitle{
  white-space:nowrap;
  overflow:hidden;
  text-overflow:ellipsis;
  line-height:1.2;
  height:1.2em;
}
.titleCell .itemDetails{
  display:none;
  margin-top:6px;
}
.row--active .titleCell .mainTitle{
  white-space:normal;
  height:auto;
}
.row--active .titleCell .itemDetails{
  display:block;
}
.titleCell .detailTitle{
  font-size:11px;
  color: var(--ink);
  margin-bottom:4px;
}
.titleCell .notes{
  margin-top:4px;
  font-size:11px;
  color: var(--ink-dim);
  line-height:1.25;
  display:-webkit-box;
  -webkit-line-clamp:1;
  -webkit-box-orient: vertical;
  overflow:hidden;
}
body.show-full-descriptions .titleCell .notes{
  display:block;
  -webkit-line-clamp: unset;
  overflow:visible;
}
.row--active .titleCell .notes{
  display:block;
  -webkit-line-clamp: unset;
  overflow:visible;
}
.titleCell .detailArea{
  margin-top:4px;
  font-size:11px;
  color: var(--ink-dim);
}

.links a{
  color: var(--accent);
  text-decoration:none;
  border-bottom:1px solid var(--accent-soft);
}
.links a:hover{ border-bottom-color: var(--accent-border); }

.sidebar__footer{
  padding:10px 16px 12px;
  border-top:1px solid var(--panel-border-soft);
}
.note{ color:var(--ink-muted); font-size:11px; line-height:1.35; }

.main{
  position:relative;
  display:flex;
  flex-direction:column;
  min-height:0;
  overflow:hidden;
}
.mapTopBar{ padding:14px 14px 10px; }
.hud{
  display:flex;
  flex-direction:column;
  gap:2px;
  padding:10px 12px;
  border-radius: var(--radius);
  background: var(--panel-surface-strong);
  border:1px solid var(--panel-border);
  box-shadow: var(--shadow);
  backdrop-filter: blur(8px);
}
.hud__title{ font-weight:800; font-size:13px; }
.hud__sub{ color:var(--ink-muted); font-size:11px; }

.map{
  flex:1;
  margin:0 14px 14px;
  border-radius: var(--radius);
  overflow:hidden;
  border:1px solid var(--panel-border);
  box-shadow: var(--shadow);
}

.callout{
  margin-top:10px;
  padding:10px;
  border-radius:12px;
  border:1px solid var(--panel-border);
  background: var(--panel-surface);
  display:grid;
  gap:6px;
}
.callout__title{
  font-size:12px;
  font-weight:700;
}
.callout__sub{
  font-size:11px;
  color: var(--ink-muted);
  line-height:1.35;
}
.callout__meta{
  display:flex;
  flex-wrap:wrap;
  gap:6px;
}
.callout__pill{
  font-size:11px;
  padding:4px 8px;
  border-radius:999px;
  border:1px solid var(--panel-border-strong);
  background: var(--panel-soft);
}
.callout__links a{
  color: var(--accent);
  text-decoration:none;
  border-bottom:1px solid var(--accent-soft);
}
.callout__links a:hover{ border-bottom-color: var(--accent-border); }

.custom-marker{
  background: transparent;
  border: none;
}
.marker-badge{
  width:26px;
  height:26px;
  border-radius:50%;
  display:flex;
  align-items:center;
  justify-content:center;
  background: var(--marker-color, rgba(122,162,255,.9));
  border:2px solid rgba(255,255,255,.9);
  box-shadow: 0 6px 16px rgba(0,0,0,.35);
  position:relative;
  transition: transform .15s ease, box-shadow .15s ease;
}
.marker-emoji{
  font-size:14px;
  line-height:1;
}
.marker-order{
  position:absolute;
  bottom:-6px;
  right:-6px;
  width:16px;
  height:16px;
  border-radius:999px;
  background: var(--panel-surface-deep);
  border:1px solid var(--panel-border-strong);
  color: var(--text);
  font-size:9px;
  font-weight:700;
  display:none;
  align-items:center;
  justify-content:center;
}
body.single-day .marker-order{ display:flex; }
.custom-marker.marker--active .marker-badge{
  transform: scale(1.08);
  box-shadow: 0 0 0 4px var(--accent-shadow), 0 8px 20px rgba(0,0,0,.45);
}
.custom-marker.marker--hover .marker-badge{
  transform: scale(1.05);
  box-shadow: 0 0 0 3px rgba(255,255,255,.28), 0 8px 18px rgba(0,0,0,.45);
}

/* Leaflet tweaks */
.leaflet-control-attribution{
  background: var(--panel-surface-alt) !important;
  color: var(--ink-muted) !important;
  border-radius:10px !important;
  border:1px solid var(--panel-border-soft) !important;
}
.leaflet-popup-content-wrapper{
  background: var(--panel-surface-deep);
  color: var(--text);
  border:1px solid var(--panel-border);
}
.leaflet-popup-tip{ background: var(--panel-surface-deep); }
.leaflet-popup.map-callout .leaflet-popup-tip{
  border:1px solid var(--panel-border-strong);
  box-shadow: 0 0 0 2px var(--accent-soft);
}
.leaflet-popup.map-callout .leaflet-popup-tip-container{
  position:relative;
}
.leaflet-popup.map-callout .leaflet-popup-tip-container::after{
  content:"";
  position:absolute;
  top:12px;
  left:50%;
  width:2px;
  height:18px;
  transform: translateX(-50%);
  background: linear-gradient(180deg, rgba(122,162,255,.65), rgba(122,162,255,0));
}

@media (max-width: 1040px){
  .app{ grid-template-columns: 1fr; }
  .scheduleColumn{ border-right:none; border-top:1px solid var(--panel-border-soft); }
  .map{ min-height: 46vh; }
}
