:root {
  color-scheme: light;
  --bg: #d5dfeb;
  --bg-end: #c9d7e6;
  --surface: #dee7f0;
  --header: #d8e3ee;
  --border: #b4c5d7;
  --text: #263c56;
  --muted: #586f89;
  --accent: #3e648f;
  --hover: #cedceb;
  --selected: #c1d3e8;
  --star: #947038;
  --secondary: #637b94;
  --icons: #637b94;
  --separator: rgba(88, 111, 137, .16);
}

body.night {
  color-scheme: dark;
  --bg: #172536;
  --bg-end: #172536;
  --surface: #203146;
  --header: #203146;
  --border: #3c5067;
  --text: #d8e6f5;
  --muted: #99adc4;
  --accent: #a1c4ed;
  --hover: #30465f;
  --selected: #304965;
  --star: #b28947;
  --secondary: #8b9cb0;
  --icons: #7894b3;
  --separator: rgba(153, 173, 196, .15);
}

body.rose {
  --bg: #e7d7e2;
  --bg-end: #d9cee8;
  --surface: #f0e3ec;
  --header: #e9dbe7;
  --border: #cdb3c8;
  --text: #50394f;
  --muted: #876580;
  --accent: #a04e81;
  --hover: #e7cedf;
  --selected: #dfbfd6;
  --star: #af7a47;
  --secondary: #94738d;
  --icons: #94738d;
  --separator: rgba(135, 101, 128, .16);
  --logo-bg: #a16c92;
}

body.rose.night {
  --bg: #281f30;
  --bg-end: #30223a;
  --surface: #36283e;
  --header: #302438;
  --border: #604660;
  --text: #f0e0ed;
  --muted: #bba0b7;
  --accent: #e5a6cf;
  --hover: #4b3352;
  --selected: #513951;
  --star: #d8ad79;
  --secondary: #b294af;
  --icons: #b294af;
  --separator: #513c55;
  --logo-bg: #8d5c83;
}

* { box-sizing: border-box; }

body {
  min-height: 100vh;
  margin: 0;
  background: linear-gradient(120deg, var(--bg), var(--bg-end));
  color: var(--text);
  font: 13px/1.45 "Segoe UI", system-ui, sans-serif;
}

button, input, a { font: inherit; }
button, input {
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--surface);
  color: var(--text);
}
button { cursor: pointer; }
a { color: inherit; text-decoration: none; }
button:hover, a:hover { background: var(--hover); }
button:disabled { cursor: not-allowed; opacity: .5; }
:where(button, input, a):focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}
input::placeholder { color: var(--muted); opacity: 1; }
svg { display: inline-block; flex: none; vertical-align: middle; }

.bar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  padding: 12px 18px;
  border-bottom: 1px solid var(--border);
  background: var(--header);
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  white-space: nowrap;
  font-size: 20px;
  font-weight: 750;
  letter-spacing: -.7px;
}
.logo {
  display: grid;
  place-items: center;
  width: 33px;
  height: 33px;
  border-radius: 4px;
  background: var(--logo-bg, #527aa8);
  color: #fff;
  font-size: 20px;
}
.logo svg { width: 24px; height: 24px; }
.clocks { display: flex; gap: 12px; color: var(--muted); font-size: 11px; }
.clock { white-space: nowrap; }
.clock svg, .converter-label svg { width: 14px; height: 11px; }
.clock strong {
  display: block;
  color: var(--text);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}
.converter {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-left: auto;
}
.converter label { display: grid; gap: 1px; margin: 0; }
.converter-label {
  display: flex;
  align-items: center;
  gap: 4px;
  color: var(--muted);
  font-size: 10px;
}
.converter input[type="time"] {
  width: 100px;
  min-width: 100px;
  height: 26px;
  padding: 2px 3px 2px 0;
  border: 0;
  border-bottom: 1px solid var(--border);
  border-radius: 0;
  background: transparent;
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.converter input[type="time"]::-webkit-calendar-picker-indicator {
  flex-shrink: 0;
  width: 13px;
  margin-left: 6px;
  padding: 0;
  opacity: .55;
  cursor: pointer;
}
#dayNote { max-width: 110px; color: var(--muted); font-size: 9px; }
.header-right { display: flex; align-items: center; gap: 7px; }
.header-right button, .header-right a {
  display: grid;
  place-items: center;
  width: 35px;
  height: 35px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--surface);
  font-size: 19px;
}
.header-right button:hover, .header-right a:hover { background: var(--hover); }
.header-right svg { width: 19px; height: 19px; }

main { max-width: 1920px; margin: auto; padding: 16px 18px 42px; }
.board-controls {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}
.board-controls .search { flex: 1; min-width: 140px; height: 37px; padding: 8px 13px; }
.character-label {
  display: flex;
  flex: none;
  align-items: center;
  gap: 9px;
  color: var(--muted);
  font-size: 12px;
}
.character-label input { width: 150px; height: 37px; padding: 8px 11px; }
.toolbar { display: flex; flex: none; align-items: center; gap: 8px; }
.toolbar button { display: inline-flex; align-items: center; justify-content: center; gap: 4px; height: 37px; padding: 7px 11px; white-space: nowrap; }
.toolbar .active, .toolbar .selected, .toolbar button[aria-pressed="true"] {
  border-color: var(--accent);
  background: var(--selected);
  color: var(--accent);
}
#myBtn, #allBtn { gap: 4px; }
#myBtn svg, #allBtn svg { width: 17px; height: 17px; }
.favorites-text, .reveal-text {
  max-width: 0;
  overflow: hidden;
  opacity: 0;
  white-space: nowrap;
  transition: max-width .2s ease, opacity .2s ease;
}
#myBtn:hover .favorites-text, #myBtn:focus-visible .favorites-text,
#allBtn:hover .reveal-text, #allBtn:focus-visible .reveal-text {
  max-width: 105px;
  opacity: 1;
}
#favoriteCount { font-size: 11px; }
.status-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
#status { color: var(--muted); font-size: 10px; }
.list { display: grid; grid-template-columns: repeat(auto-fill, minmax(185px, 1fr)); gap: 8px; align-items: start; }
.spawn { min-width: 0; overflow: hidden; border: 1px solid var(--border); border-radius: 5px; background: var(--surface); }
.spawn-head { display: flex; align-items: center; gap: 4px; padding: 8px 6px; }
.summary-btn {
  display: flex;
  flex: 1;
  align-items: center;
  gap: 5px;
  min-width: 0;
  padding: 0;
  border: 0;
  background: transparent;
  text-align: left;
}
.summary-btn:hover { background: transparent; }
.title { display: block; min-width: 0; flex: 1; }
.chev { flex: none; color: var(--icons); }
.chev svg { width: 12px; height: 12px; }
.name, .area { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.name { font-size: 11px; font-weight: 700; }
.area { margin-top: 3px; color: var(--muted); font-size: 9px; letter-spacing: 1.3px; text-transform: uppercase; }
.claim-btn, .save-btn {
  display: grid;
  flex: none;
  place-items: center;
  width: 23px;
  height: 23px;
  padding: 0;
  border-color: transparent;
  border-radius: 3px;
  background: transparent;
  color: var(--icons);
}
.claim-btn:hover, .save-btn:hover { color: var(--accent); }
.claim-btn svg, .save-btn svg { width: 16px; height: 16px; }
.save-btn.active, .save-btn.selected, .save-btn[aria-pressed="true"] { color: var(--star); }
.save-btn.active svg, .save-btn.selected svg, .save-btn[aria-pressed="true"] svg { fill: currentColor; }
.rows { display: none; margin: 0 7px 0 12px; }
.spawn.open .rows, .spawn:has(.summary-btn[aria-expanded="true"]) .rows { display: block; }
.row {
  display: grid;
  grid-template-columns: 96px minmax(0, 1fr);
  align-items: center;
  gap: 4px;
  min-height: 43px;
  border-top: 1px solid var(--separator);
}
.time-stack { min-width: 0; font-size: 9px; font-variant-numeric: tabular-nums; line-height: 1.6; }
.time-sub { display: block; color: var(--secondary); font-size: 8px; }
.claimant {
  display: block;
  min-width: 0;
  overflow: hidden;
  color: var(--accent);
  font-size: 10px;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.empty { padding: 15px 0 17px; border-top: 1px solid var(--separator); color: var(--muted); font-size: 11px; }
#toast {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 10;
  max-width: calc(100vw - 32px);
  padding: 10px 13px;
  border: 1px solid var(--border);
  border-radius: 5px;
  background: var(--surface);
  color: var(--text);
  opacity: 0;
  pointer-events: none;
  transform: translateY(8px);
  transition: opacity .16s ease, transform .16s ease;
}
#toast.show { opacity: 1; transform: translateY(0); }


@media (max-width: 1100px) {
  .bar { gap: 12px; }
  .header-right { margin-left: 0; }
}
@media (max-width: 800px) {
  .bar { gap: 10px; padding: 12px; }
  .brand { font-size: 17px; }
  .logo { width: 27px; height: 27px; }
  .clocks { gap: 9px; font-size: 9px; }
  .clock strong { font-size: 11px; }
  .converter { gap: 8px; }
  .converter input[type="time"] { width: 92px; min-width: 92px; font-size: 11px; }
  .converter-label { font-size: 9px; }
  #dayNote { max-width: 75px; }
  .board-controls { gap: 7px; }
  .board-controls .search { font-size: 11px; }
  .character-label { gap: 5px; }
  .character-label input { width: 115px; }
  .toolbar { gap: 5px; }
  .toolbar button { padding: 7px; }
}
@media (max-width: 650px) {
  .board-controls { flex-wrap: wrap; }
  .board-controls .search { flex: 1 1 55%; }
  .character-label { flex: 1; }
  .character-label input { flex: 1; min-width: 0; width: 90px; }
  .toolbar { width: 100%; }
  #toggleAllBtn { margin-left: auto; }
  .converter { order: 4; flex-basis: 100%; margin-left: 0; }
  .header-right { margin-left: auto; }
}
@media (max-width: 430px) {
  main { padding: 12px; }
  .list { grid-template-columns: 1fr; }
  .row { grid-template-columns: 116px minmax(0, 1fr); }
  .time-stack, .claimant { font-size: 11px; }
  .time-sub { font-size: 10px; }
}
@media (prefers-reduced-motion: reduce) {
  .favorites-text, .reveal-text, #toast { transition: none; }
}
