:root {
  --bg: #0f1218;
  --panel: #161b24;
  --border: #2a3344;
  --text: #e8ecf1;
  --muted: #8b97ab;
  --accent: #5b8cff;
  --accent2: #3ecf8e;
  --warn: #e6a23c;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.45;
  font-size: 15px;
}
header {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.75rem 1.25rem;
  justify-content: space-between;
}
header h1 {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 650;
  letter-spacing: -0.02em;
}
header .meta { color: var(--muted); font-size: 0.9rem; }
.header-actions { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; }
.header-actions a { color: var(--accent); font-size: 0.9rem; }
.wrap { max-width: 1100px; margin: 0 auto; padding: 1.25rem 1.5rem 2.5rem; }
section {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1rem 1.1rem;
  margin-bottom: 1rem;
}
section h2 {
  margin: 0 0 0.65rem;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  font-weight: 600;
}
.hint { color: var(--muted); font-size: 0.82rem; margin-top: 0.5rem; }
ul.compact { margin: 0.35rem 0 0 1.1rem; padding: 0; font-size: 0.88rem; color: var(--muted); }
ul.compact li { margin: 0.2rem 0; }

/* —— 24h histogram (bar = labels only; rail = mirrored flex times) —— */
.tl { margin-top: 0.5rem; }
.tl__stack {
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.14);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.45);
  background: #0a0d14;
}
.tl__bar {
  display: flex;
  width: 100%;
  min-height: 52px;
  height: 52px;
  border-radius: 0;
  overflow: hidden;
  border: none;
  box-shadow: inset 0 -1px 0 rgba(0, 0, 0, 0.55);
}
.tl__seg {
  min-width: 0;
  flex-shrink: 0;
  position: relative;
  transition: filter 0.12s ease, box-shadow 0.12s ease;
  display: flex;
  align-items: stretch;
  justify-content: center;
  box-shadow: inset -1px 0 0 rgba(0, 0, 0, 0.65);
}
.tl__seg:last-child { box-shadow: none; }
.tl__seg:hover {
  filter: brightness(1.1) saturate(1.12);
  z-index: 1;
  box-shadow:
    inset -1px 0 0 rgba(0, 0, 0, 0.65),
    0 0 0 1px rgba(255, 255, 255, 0.45);
}
.tl__seg-body {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 0.25rem 0.2rem;
  width: 100%;
  min-width: 0;
  text-align: center;
}
.tl__label {
  font-size: clamp(0.55rem, 0.9vw + 0.45rem, 0.78rem);
  font-weight: 700;
  color: #ffffff;
  text-shadow:
    0 0 3px rgba(0, 0, 0, 1),
    0 1px 4px rgba(0, 0, 0, 0.95);
  line-height: 1.15;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 100%;
}
.tl__seg--tight .tl__label {
  font-size: clamp(0.48rem, 0.5vw + 0.38rem, 0.62rem);
  font-weight: 800;
}
.tl__seg--tiny .tl__label {
  font-size: 0.5rem;
  letter-spacing: -0.03em;
}

.tl__rail {
  display: flex;
  width: 100%;
  padding: 0.4rem 0.15rem 0.55rem;
  background: linear-gradient(180deg, #070910 0%, #0d111c 100%);
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}
.tl__rail-cell {
  min-width: 0;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  gap: 0.12rem;
  padding: 0.08rem 0.05rem;
  text-align: center;
  box-shadow: inset -1px 0 0 rgba(255, 255, 255, 0.06);
}
.tl__rail-cell:last-child { box-shadow: none; }
.tl__rail-time {
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  line-height: 1.05;
  color: #6ee7b7;
  text-shadow:
    0 0 2px rgba(0, 0, 0, 1),
    0 0 10px rgba(16, 185, 129, 0.35);
}
.tl__rail-time--start { font-size: clamp(0.52rem, 0.55vw + 0.42rem, 0.72rem); }
.tl__rail-time--end {
  font-size: clamp(0.5rem, 0.5vw + 0.38rem, 0.68rem);
  color: #5eead4;
  opacity: 0.95;
}
.tl__rail-cell--narrow .tl__rail-time--start { font-size: 0.55rem; }
.tl__rail-cell--narrow .tl__rail-time--end { font-size: 0.52rem; }
.tl__rail-cell--cramped .tl__rail-time {
  font-size: 0.48rem;
  letter-spacing: -0.04em;
  font-weight: 800;
}

.tl__legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem 1rem;
  margin-top: 0.85rem;
  font-size: 0.78rem;
  color: var(--text);
}
.tl__legend span {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}
.tl__swatch {
  width: 11px;
  height: 11px;
  border-radius: 3px;
  flex-shrink: 0;
  border: 1px solid rgba(255, 255, 255, 0.25);
}

/* Saturated fills — stronger separation */
.tone-sleep { background: linear-gradient(180deg, #3730a3, #1e1b4b); }
.tone-wake { background: linear-gradient(180deg, #64748b, #334155); }
.tone-dog {
  background: linear-gradient(180deg, #d97706, #92400e);
  box-shadow: inset 0 0 0 1px rgba(253, 224, 71, 0.55);
}
.tone-coffee { background: linear-gradient(180deg, #57534e, #292524); }
.tone-hara { background: linear-gradient(180deg, #3b82f6, #1d4ed8); }
.tone-nexo-em { background: linear-gradient(180deg, #14b8a6, #0f766e); }
.tone-nexo { background: linear-gradient(180deg, #0f766e, #042f2e); }
.tone-family { background: linear-gradient(180deg, #22c55e, #166534); }
.tone-alone { background: linear-gradient(180deg, #a855f7, #6b21a8); }
.tone-partner { background: linear-gradient(180deg, #ec4899, #9d174d); }
.tone-buffer { background: linear-gradient(180deg, #52525b, #27272a); }

.cal-status { font-size: 0.85rem; color: var(--muted); margin-top: 0.5rem; }
.cal-status.ok { color: var(--accent2); }

.grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 0.5rem;
}
@media (max-width: 820px) {
  .grid { grid-template-columns: 1fr; }
}
.day {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.65rem 0.75rem;
  background: rgba(0,0,0,0.15);
}
.day h3 {
  margin: 0 0 0.35rem;
  font-size: 0.95rem;
}
.day .slot {
  color: var(--muted);
  font-size: 0.85rem;
  margin-bottom: 0.5rem;
}
label {
  display: flex;
  align-items: flex-start;
  gap: 0.45rem;
  cursor: pointer;
  font-size: 0.88rem;
  margin: 0.25rem 0;
}
input[type="checkbox"] {
  margin-top: 0.2rem;
  accent-color: var(--accent);
}
.pill {
  display: inline-block;
  font-size: 0.72rem;
  padding: 0.12rem 0.45rem;
  border-radius: 999px;
  background: rgba(91, 140, 255, 0.15);
  color: #a8c4ff;
  margin-bottom: 0.35rem;
}
.pill.convert { background: rgba(62, 207, 142, 0.12); color: #8fe8c2; }
.pill.warn { background: rgba(230, 162, 60, 0.15); color: #f0c78a; }
textarea, .textin {
  width: 100%;
  min-height: 3.25rem;
  resize: vertical;
  background: #0c0f14;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  padding: 0.5rem 0.6rem;
  font-family: inherit;
  font-size: 0.9rem;
}
.textin { min-height: 2rem; }
.row2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}
@media (max-width: 720px) { .row2 { grid-template-columns: 1fr; } }
.weekend-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}
@media (max-width: 640px) { .weekend-row { grid-template-columns: 1fr; } }
.weekend-box {
  border: 1px dashed var(--border);
  border-radius: 8px;
  padding: 0.65rem 0.75rem;
  background: rgba(0,0,0,0.12);
}
.weekend-box h3 { margin: 0 0 0.5rem; font-size: 0.95rem; }
footer {
  margin-top: 1.5rem;
  color: var(--muted);
  font-size: 0.8rem;
}
a { color: var(--accent); }

.hidden { display: none !important; }

/* —— Google Calendar week (compact week view) —— */
.cal-week {
  display: flex;
  gap: 0.35rem;
  margin-top: 0.5rem;
  overflow-x: auto;
  padding-bottom: 0.25rem;
}
.cal-week__gutter {
  flex: 0 0 2.25rem;
  display: flex;
  flex-direction: column;
  font-size: 0.65rem;
  color: var(--muted);
  text-align: right;
  padding-right: 0.15rem;
  user-select: none;
}
.cal-week__gutter-spacer {
  height: 2.1rem;
  flex-shrink: 0;
}
.cal-week__gutter-spacer--tall {
  height: 4.5rem;
}
.cal-week__ticks {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-height: 476px;
  padding-top: 0.15rem;
  line-height: 1;
}
.cal-week__cols {
  display: flex;
  gap: 0.35rem;
  flex: 1;
  min-width: min(100%, 52rem);
}
.cal-col {
  flex: 1 1 0;
  min-width: 5.5rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  background: #0c0f14;
  display: flex;
  flex-direction: column;
}
.cal-col__hd {
  padding: 0.35rem 0.4rem;
  font-size: 0.72rem;
  font-weight: 650;
  text-align: center;
  border-bottom: 1px solid var(--border);
  background: rgba(91, 140, 255, 0.08);
  color: var(--text);
}
.cal-col__hd small {
  display: block;
  font-weight: 500;
  color: var(--muted);
  font-size: 0.65rem;
  margin-top: 0.12rem;
}
.cal-col__allday {
  min-height: 1.6rem;
  padding: 0.25rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  display: flex;
  flex-wrap: wrap;
  gap: 0.2rem;
}
.cal-chip {
  font-size: 0.62rem;
  line-height: 1.2;
  padding: 0.12rem 0.28rem;
  border-radius: 4px;
  background: rgba(230, 162, 60, 0.2);
  color: #f0c78a;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.cal-col__grid {
  position: relative;
  flex: 1;
  min-height: 476px;
}
.cal-col__hours {
  position: absolute;
  inset: 0;
  background-image: repeating-linear-gradient(
    to bottom,
    transparent,
    transparent calc(28px - 1px),
    rgba(255, 255, 255, 0.06) calc(28px - 1px),
    rgba(255, 255, 255, 0.06) 28px
  );
  pointer-events: none;
}
.cal-col__now {
  position: absolute;
  left: 0;
  right: 0;
  height: 2px;
  background: #e85d5d;
  z-index: 2;
  pointer-events: none;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.35);
}
.cal-col__events {
  position: absolute;
  inset: 0;
  z-index: 1;
}
.cal-ev {
  position: absolute;
  left: 3px;
  right: 3px;
  border-radius: 4px;
  padding: 2px 4px;
  font-size: 0.62rem;
  line-height: 1.2;
  overflow: hidden;
  background: rgba(91, 140, 255, 0.35);
  border: 1px solid rgba(91, 140, 255, 0.55);
  color: #e8ecf1;
  cursor: default;
}
.cal-ev a {
  color: inherit;
  text-decoration: none;
}
.cal-ev a:hover {
  text-decoration: underline;
}

/* —— Admin —— */
.admin-wrap { max-width: 960px; margin: 0 auto; padding: 1.25rem 1.5rem 2rem; }
.admin-table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: 8px; }
.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}
.admin-table th,
.admin-table td {
  padding: 0.45rem 0.5rem;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: middle;
}
.admin-table th {
  color: var(--muted);
  font-weight: 600;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.admin-table tr:last-child td { border-bottom: none; }
.admin-table code { font-size: 0.72rem; color: var(--muted); }
.admin-msg { margin-top: 0.75rem; font-size: 0.85rem; color: var(--muted); }
.admin-msg.ok { color: var(--accent2); }
.admin-msg.err { color: #f0a0a0; }
