:root {
  color-scheme: light dark;

  --bg:        #f1f0ec;
  --panel:     #fbfbf9;
  --fg:        #1b1b1b;
  --fg-dim:    #60605c;
  --line:      #c5c3bc;
  --line-soft: #dedcd5;
  --accent:    #0072b2;
  --sel-bg:    #0072b2;
  --sel-fg:    #ffffff;
  --bad:       #b3261e;
  --grid:      #dedcd5;
  --today:     #b35c00;

  --mono: "DejaVu Sans Mono", "Liberation Mono", "Menlo", "Consolas", monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg:        #141416;
    --panel:     #1c1c1f;
    --fg:        #d6d6d0;
    --fg-dim:    #86867f;
    --line:      #3a3a3f;
    --line-soft: #2a2a2e;
    --accent:    #5ab4ea;
    --sel-bg:    #5ab4ea;
    --sel-fg:    #141416;
    --bad:       #ef5350;
    --grid:      #2a2a2e;
    --today:     #e0a93f;
  }
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--mono);
  font-size: 13px;
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
}

#app {
  max-width: 1180px;
  margin: 0 auto;
  padding: 16px 14px 28px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

a { color: var(--accent); }
a:hover { text-decoration: none; }

:focus-visible { outline: 1px dotted var(--fg); outline-offset: 1px; }

/* head */

.head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding-bottom: 2px;
}

.head h1 { margin: 0; font-size: 15px; font-weight: 700; letter-spacing: 0.02em; }

/* location picker */

.locrow {
  display: flex;
  align-items: flex-end;
  gap: 8px 20px;
}

.updated {
  flex: 0 0 auto;
  margin-left: auto;
  color: var(--fg-dim);
  font-size: 12px;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.updated.stale { color: var(--bad); font-weight: 700; }

.locs {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 16px;
  min-height: 20px;
}

.locs .item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  white-space: nowrap;
}
.locs .item input { accent-color: var(--accent); margin: 0; }
.locs .item .sw { width: 13px; height: 3px; }
.locs .item.off { color: var(--fg-dim); }
.locs .item.off .sw { opacity: 0.3; }

.locs .brk { flex-basis: 100%; height: 0; }

/* toolbar */

.bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 18px;
  border: 1px solid var(--line);
  background: var(--panel);
  padding: 7px 9px;
}

.grp { display: flex; align-items: center; gap: 6px; }

.views label { display: inline-flex; align-items: center; gap: 4px; cursor: pointer; color: var(--fg-dim); }
.views label:has(:checked) { color: var(--fg); font-weight: 700; }
.views input { accent-color: var(--accent); margin: 0; }

button {
  font: inherit;
  font-size: 12px;
  color: var(--fg);
  background: var(--panel);
  border: 1px solid var(--line);
  padding: 2px 9px;
  cursor: pointer;
  line-height: 1.4;
}
button:hover:not(:disabled) { background: var(--line-soft); }
button:active:not(:disabled) { background: var(--line); }
button:disabled { color: var(--fg-dim); cursor: default; opacity: 0.45; }

#date-btn { min-width: 13.5em; font-variant-numeric: tabular-nums; }

/* calendar popup */

.pick { position: relative; }

.popup {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  z-index: 20;
  background: var(--panel);
  border: 1px solid var(--line);
  padding: 7px;
}

.cal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
  padding-bottom: 5px;
  border-bottom: 1px solid var(--line-soft);
}
.cal-head span { font-weight: 700; flex: 1; text-align: center; white-space: nowrap; }

table.cal { border-collapse: collapse; font-variant-numeric: tabular-nums; }

table.cal th {
  font-weight: 400;
  color: var(--fg-dim);
  font-size: 11px;
  padding: 1px 0 4px;
  text-align: center;
}

table.cal td { padding: 0; }

table.cal button {
  width: 2.25em;
  padding: 2px 0;
  text-align: center;
  border-color: transparent;
  background: none;
}
table.cal button:hover:not(:disabled):not(.on) { border-color: var(--line); background: var(--line-soft); }
table.cal--week tr:hover button:not(:disabled):not(.on) { background: var(--line-soft); }
table.cal button.out { color: var(--fg-dim); opacity: 0.55; }
table.cal button.today { color: var(--today); font-weight: 700; }
table.cal button.range { background: var(--line-soft); }
table.cal button.on { background: var(--sel-bg); border-color: var(--sel-bg); color: var(--sel-fg); font-weight: 700; }
table.cal button:disabled { opacity: 0.3; }

/* chart */

.chart-box {
  position: relative;
  border: 1px solid var(--line);
  background: var(--panel);
  padding: 8px 8px 4px;
  min-height: 300px;
}

#chart { width: 100%; }

.empty {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--fg-dim);
  pointer-events: none;
}

.u-cursor-x, .u-cursor-y { border-color: var(--fg-dim); }
.u-select { background: rgba(0, 114, 178, 0.16); }

/* hover tooltip */

.tip {
  position: absolute;
  z-index: 5;
  pointer-events: none;
  background: var(--panel);
  border: 1px solid var(--line);
  padding: 5px 8px 6px;
  font-size: 12px;
  line-height: 1.5;
  white-space: nowrap;
}

.tip .when {
  color: var(--fg-dim);
  margin-bottom: 3px;
  font-variant-numeric: tabular-nums;
}

.tip .row {
  display: grid;
  grid-template-columns: 13px 1fr auto;
  align-items: center;
  gap: 0 8px;
}
.tip .row i { height: 3px; }
.tip .row b { font-weight: 700; font-variant-numeric: tabular-nums; text-align: right; }

/* foot */

.foot {
  display: flex;
  justify-content: flex-end;
  gap: 14px;
  color: var(--fg-dim);
  font-size: 12px;
}

@media (max-width: 560px) {
  #app { padding: 12px 10px 20px; }
  .grp.right { margin-left: 0; }
  #date-btn { min-width: 11em; }
}
