/* World Time — warm amber aesthetic */
:root {
  --bg: #fdf8f0;
  --bg-2: #f7efe1;
  --paper: #fffbf3;
  --ink: #2a1d0d;
  --ink-2: #4a3920;
  --ink-3: #7a6a4f;
  --ink-4: #b6a684;
  --line: #ead9b8;
  --line-2: #f0e2c4;
  --amber: #c2410c;
  --amber-2: #ea580c;
  --amber-3: #f97316;
  --amber-soft: #fed7aa;
  --amber-tint: #ffedd5;

  /* Day/night gradient palette (cell backgrounds) */
  --night-deep: #1a1430;
  --night: #2a1f4a;
  --twilight: #5a3a5e;
  --sunrise-1: #b8475e;
  --sunrise-2: #e0734a;
  --day-warm: #ffd9a8;
  --day-bright: #fff7e6;
  --day-cool: #fff3d4;
  --sunset-1: #f59e5a;
  --sunset-2: #c4452a;
  --dusk: #4a2548;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: 'Inter Tight', ui-sans-serif, system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-feature-settings: 'ss01', 'cv11';
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
.mono { font-family: 'JetBrains Mono', ui-monospace, monospace; font-feature-settings: 'zero'; }

/* ───────────── App shell ───────────── */
.app {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Header */
.hdr {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 18px 28px;
  border-bottom: 1px solid var(--line);
  background: var(--paper);
  position: sticky; top: 0; z-index: 50;
}
.hdr-brand {
  display: flex; align-items: center; gap: 10px;
  font-weight: 600; letter-spacing: -0.01em; font-size: 17px;
}
.hdr-mark {
  width: 26px; height: 26px; border-radius: 50%;
  background: conic-gradient(from 180deg, var(--amber-3), var(--sunrise-1), var(--night), var(--day-warm), var(--amber-3));
  position: relative;
}
.hdr-mark::after {
  content: ""; position: absolute; inset: 6px; background: var(--paper); border-radius: 50%;
}
.hdr-mark::before {
  content: ""; position: absolute; left: 50%; top: 50%; width: 1.5px; height: 7px;
  background: var(--amber); transform-origin: bottom center; transform: translate(-50%, -100%) rotate(45deg);
  z-index: 1;
}
.hdr-title { font-size: 17px; font-weight: 600; }
.hdr-sub { color: var(--ink-3); font-size: 13px; margin-left: 2px; }
.hdr-spacer { flex: 1; }

.hdr-btn {
  appearance: none; border: 1px solid var(--line); background: var(--paper);
  color: var(--ink-2); padding: 8px 14px; border-radius: 999px; font: inherit; font-size: 13px;
  cursor: pointer; display: inline-flex; align-items: center; gap: 8px;
  transition: all .15s ease;
}
.hdr-btn:hover { border-color: var(--amber-soft); background: var(--amber-tint); color: var(--amber); }
.hdr-btn.primary { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.hdr-btn.primary:hover { background: var(--amber); border-color: var(--amber); color: white; }

.hdr-clock { font-size: 13px; color: var(--ink-3); display: inline-flex; align-items: baseline; gap: 8px; }
.hdr-clock b { color: var(--ink); font-weight: 600; font-variant-numeric: tabular-nums; }

/* ───────────── Toolbar ───────────── */
.toolbar {
  display: flex; align-items: center; gap: 14px;
  padding: 14px 28px;
  border-bottom: 1px solid var(--line);
  background: var(--bg);
  flex-wrap: wrap;
}
.tb-group { display: inline-flex; align-items: center; gap: 8px; }
.tb-label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--ink-3); font-weight: 600; }

.date-pill {
  display: inline-flex; align-items: center; gap: 10px;
  padding: 6px 6px 6px 14px;
  background: var(--paper); border: 1px solid var(--line); border-radius: 999px;
  cursor: pointer; user-select: none; font-size: 13px;
}
.date-pill:hover { border-color: var(--amber-soft); }
.date-pill .step {
  width: 26px; height: 26px; border-radius: 50%; border: 0;
  background: transparent; color: var(--ink-3); cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
}
.date-pill .step:hover { background: var(--amber-tint); color: var(--amber); }
.date-pill .today {
  font-size: 11px; padding: 4px 10px; border-radius: 999px; background: var(--ink); color: var(--paper);
  border: 0; cursor: pointer; margin-right: 4px;
}
.date-pill b { font-weight: 600; font-variant-numeric: tabular-nums; }

.search-wrap { position: relative; flex: 1; min-width: 220px; max-width: 380px; }
.search {
  width: 100%; padding: 9px 14px 9px 36px;
  border: 1px solid var(--line); border-radius: 999px; background: var(--paper);
  color: var(--ink); font: inherit; font-size: 13px; outline: none;
}
.search:focus { border-color: var(--amber); background: white; box-shadow: 0 0 0 3px var(--amber-tint); }
.search-icon {
  position: absolute; left: 13px; top: 50%; transform: translateY(-50%);
  color: var(--ink-3); pointer-events: none;
}
.search-results {
  position: absolute; top: calc(100% + 6px); left: 0; right: 0;
  background: var(--paper); border: 1px solid var(--line); border-radius: 14px;
  padding: 6px; z-index: 100; max-height: 320px; overflow: auto;
  box-shadow: 0 12px 32px rgba(40, 20, 0, 0.08);
}
.search-results:empty { display: none; }
.search-result {
  padding: 10px 12px; border-radius: 10px; cursor: pointer;
  display: flex; justify-content: space-between; align-items: baseline; gap: 12px;
}
.search-result:hover, .search-result.active { background: var(--amber-tint); }
.search-result .city { font-size: 14px; font-weight: 500; }
.search-result .meta { font-size: 11px; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.search-result.search-empty { color: var(--ink-3); font-size: 13px; cursor: default; }
.search-result.search-empty:hover { background: transparent; }
.geo-badge { display: inline-block; font-size: 9px; font-weight: 600; letter-spacing: .04em;
  color: var(--amber); opacity: .7; vertical-align: middle; margin-left: 2px; }

.meeting-toggle {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 7px 14px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--paper); cursor: pointer; font-size: 13px;
}
.meeting-toggle:hover { border-color: var(--amber-soft); }
.meeting-toggle.on { background: var(--ink); color: var(--paper); border-color: var(--ink); }

/* ───────────── Comparison grid ───────────── */
.grid-wrap { padding: 18px 28px 80px; max-width: 1600px; margin: 0 auto; width: 100%; }

.now-marker-rail {
  position: relative;
  margin-left: var(--label-w, 240px);
  height: 22px;
  margin-bottom: 4px;
  font-size: 11px;
  color: var(--ink-3);
}
.now-marker-rail .now {
  position: absolute; transform: translateX(-50%);
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--ink); color: var(--paper);
  padding: 3px 10px; border-radius: 999px;
  font-weight: 600; font-size: 10px; letter-spacing: 0.05em; text-transform: uppercase;
  white-space: nowrap;
}
.now-marker-rail .now::after {
  content: ""; position: absolute; left: 50%; bottom: -5px;
  width: 0; height: 0; border-left: 4px solid transparent; border-right: 4px solid transparent;
  border-top: 5px solid var(--ink); transform: translateX(-50%);
}

.row {
  display: grid;
  grid-template-columns: var(--label-w, 240px) 1fr;
  align-items: stretch;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 16px;
  margin-bottom: 10px;
  overflow: hidden;
  position: relative;
}
.row.home { border-color: var(--amber-soft); box-shadow: 0 0 0 1px var(--amber-soft) inset; }

/* Drag and drop */
.row[draggable="true"] { cursor: default; }
.row.dragging { opacity: 0.4; }
.row.drop-before { box-shadow: 0 -3px 0 var(--amber-3); }
.row.drop-after { box-shadow: 0 3px 0 var(--amber-3); }
.row.home.drop-before { box-shadow: 0 -3px 0 var(--amber-3), 0 0 0 1px var(--amber-soft) inset; }
.row.home.drop-after { box-shadow: 0 3px 0 var(--amber-3), 0 0 0 1px var(--amber-soft) inset; }

.row-label {
  padding: 14px 16px;
  display: flex; flex-direction: column; gap: 4px;
  border-right: 1px solid var(--line);
  background: linear-gradient(180deg, var(--paper), var(--bg-2));
  position: relative;
}
.row-label .drag-handle {
  position: absolute; left: 4px; top: 50%; transform: translateY(-50%);
  color: var(--ink-4); cursor: grab; opacity: 0; transition: opacity 0.15s;
  display: flex; align-items: center; padding: 4px 2px;
}
.row:hover .row-label .drag-handle { opacity: 1; }
.row-label .drag-handle:hover { color: var(--ink-3); }
.row-label .drag-handle:active { cursor: grabbing; }
.row-label .top {
  display: flex; align-items: center; gap: 8px;
}
.row-label .city {
  font-size: 17px; font-weight: 600; letter-spacing: -0.01em;
  color: var(--ink);
}
.row-label .home-pin {
  display: inline-flex; align-items: center; justify-content: center;
  width: 16px; height: 16px; color: var(--amber);
}
.row-label .meta {
  font-size: 11px; color: var(--ink-3); display: flex; gap: 8px;
  font-variant-numeric: tabular-nums;
}
.row-label .meta .tz { font-weight: 600; color: var(--ink-2); }
.row-label .big-time {
  font-size: 22px; font-weight: 600; letter-spacing: -0.02em;
  color: var(--ink); font-variant-numeric: tabular-nums;
  margin-top: 2px;
}
.row-label .big-time .ampm { font-size: 12px; color: var(--ink-3); margin-left: 4px; font-weight: 500; }
.row-label .day-tag {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 10px; padding: 2px 7px; border-radius: 4px;
  background: var(--bg-2); color: var(--ink-3);
  text-transform: uppercase; letter-spacing: 0.05em; font-weight: 600;
  align-self: flex-start;
}
.row-label .actions {
  position: absolute; top: 10px; right: 10px;
  display: flex; gap: 4px; opacity: 0; transition: opacity .15s;
}
.row:hover .row-label .actions { opacity: 1; }
.row-label .ico-btn {
  width: 24px; height: 24px; border-radius: 6px; border: 0; background: transparent;
  cursor: pointer; color: var(--ink-3); display: inline-flex; align-items: center; justify-content: center;
}
.row-label .ico-btn:hover { background: var(--bg-2); color: var(--ink); }
.row-label .ico-btn.danger:hover { background: #fee2e2; color: #dc2626; }
.row-label .ico-btn.home-btn.active { color: var(--amber); }

/* Hour strip */
.strip {
  position: relative;
  display: grid;
  grid-template-columns: repeat(24, 1fr);
  height: 100%;
  min-height: 80px;
}

.cell {
  position: relative;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  border-right: 1px solid rgba(255,255,255,0.18);
  cursor: pointer;
  user-select: none;
  transition: filter .15s;
  overflow: hidden;
}
.cell:last-child { border-right: 0; }
.cell .h {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 14px; font-weight: 600;
  font-variant-numeric: tabular-nums;
  line-height: 1;
}
.cell .ap {
  font-size: 9px;
  letter-spacing: 0.06em;
  margin-top: 2px;
  opacity: 0.75;
  text-transform: lowercase;
}
.cell .day-flip {
  position: absolute; top: 3px; right: 4px;
  font-size: 8px; font-weight: 700; letter-spacing: 0.05em;
  text-transform: uppercase;
  padding: 1px 4px; border-radius: 3px;
  background: rgba(255,255,255,0.85); color: var(--ink);
}
.cell:hover { filter: brightness(1.1); }
.cell.now {
  outline: 2px solid var(--ink);
  outline-offset: -2px;
  z-index: 2;
}
.cell.selected {
  outline: 2px solid var(--amber);
  outline-offset: -2px;
  z-index: 3;
}
.cell.selected.range-start { border-radius: 8px 0 0 8px; }
.cell.selected.range-end   { border-radius: 0 8px 8px 0; }

.cell.in-overlap::before {
  content: ""; position: absolute; inset: 0;
  background: repeating-linear-gradient(45deg,
    rgba(34, 197, 94, 0.15) 0 6px,
    rgba(34, 197, 94, 0.0) 6px 12px);
  pointer-events: none;
}
.cell.good-overlap {
  box-shadow: inset 0 -3px 0 #22c55e;
}

/* working hours subtle band */
.cell.working::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 3px;
  background: var(--amber-3);
  opacity: 0.7;
}

/* ─── Empty state ─── */
.empty {
  padding: 60px 28px; text-align: center; color: var(--ink-3);
  border: 1px dashed var(--line); border-radius: 16px; background: var(--paper);
}
.empty h3 { font-size: 17px; color: var(--ink); margin: 0 0 6px; font-weight: 600; }
.empty p { margin: 0 0 16px; font-size: 13px; }

/* ───────────── Selection summary ───────────── */
.summary {
  position: sticky; bottom: 16px;
  margin: 16px auto 0; max-width: 1544px;
  display: flex; align-items: center; gap: 16px;
  padding: 14px 20px;
  background: var(--ink); color: var(--paper);
  border-radius: 14px;
  box-shadow: 0 12px 32px rgba(40, 20, 0, 0.25);
}
.summary .row-times { display: flex; gap: 18px; flex: 1; flex-wrap: wrap; }
.summary .item { display: flex; flex-direction: column; gap: 2px; }
.summary .item .c { font-size: 11px; color: rgba(255,255,255,0.55); text-transform: uppercase; letter-spacing: 0.05em; }
.summary .item .t { font-size: 14px; font-weight: 600; font-variant-numeric: tabular-nums; }
.summary .clear {
  appearance: none; border: 1px solid rgba(255,255,255,0.2); background: transparent; color: var(--paper);
  padding: 7px 14px; border-radius: 999px; cursor: pointer; font: inherit; font-size: 12px;
}
.summary .clear:hover { background: rgba(255,255,255,0.1); }

/* ───────────── Mobile (≤720px) ───────────── */
@media (max-width: 720px) {
  .hdr { padding: 14px 16px; gap: 8px; }
  .hdr-sub, .hdr-clock .lbl { display: none; }
  .toolbar { padding: 10px 16px; gap: 8px; }
  .grid-wrap { padding: 12px 12px 100px; }
  .row { grid-template-columns: 1fr; }
  .row-label { border-right: 0; border-bottom: 1px solid var(--line); padding: 12px 14px; }
  .row-label .actions { opacity: 1; }
  .strip { overflow-x: auto; min-height: 64px; scroll-snap-type: x mandatory; }
  .strip > .cell { min-width: 44px; scroll-snap-align: start; }
  .now-marker-rail { display: none; }
  .summary { left: 12px; right: 12px; bottom: 12px; margin: 12px 0 0; padding: 12px 14px; flex-wrap: wrap; }
  .summary .row-times { gap: 10px; }
  .summary .item .t { font-size: 13px; }
}

/* compact density */
.density-compact .row-label { padding: 10px 14px; }
.density-compact .row-label .city { font-size: 15px; }
.density-compact .row-label .big-time { font-size: 18px; }
.density-compact .strip { min-height: 60px; }
.density-compact .cell .h { font-size: 13px; }

/* layout: continuous */
.layout-continuous .cell { border-right: 0; }
.layout-continuous .cell::before {
  content: ""; position: absolute; inset: 0;
  background: inherit;
}

/* layout: dotted */
.layout-dotted .cell { border-right: 1px dashed rgba(255,255,255,0.25); }

/* dark mode flip */
body.dark { --bg: #1a140a; --bg-2: #221a0e; --paper: #261d10; --ink: #fdf8f0; --ink-2: #ead9b8; --ink-3: #b6a684; --line: #3a2c18; --line-2: #2e2212; }
body.dark .hdr-mark::after { background: var(--paper); }
body.dark .summary { background: #0a0603; }

/* Select-able for ranges */
.cell { -webkit-tap-highlight-color: transparent; }
