:root {
  --planned: #6f42c1;
  --planned-bg: #ede7f6;
  --bg: #f5f7fa;
  --surface: #ffffff;
  --border: #dee2e6;
  --text: #1a1a2e;
  --text-muted: #6c757d;
  --ok: #198754;
  --ok-bg: #d1e7dd;
  --outage: #dc3545;
  --outage-bg: #f8d7da;
  --partial: #fd7e14;
  --partial-bg: #ffe5d0;
  --stale: #ffc107;
  --stale-bg: #fff3cd;
  --unknown: #adb5bd;
  --unknown-bg: #f0f0f0;
  --accent: #0d6efd;
  --radius: 8px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --planned-bg: #2d1b69;
    --bg: #111827;
    --surface: #1f2937;
    --border: #374151;
    --text: #f3f4f6;
    --text-muted: #9ca3af;
    --ok-bg: #052e16;
    --outage-bg: #450a0a;
    --partial-bg: #431407;
    --stale-bg: #422006;
    --unknown-bg: #1f2937;
  }
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  padding: 0 1rem;
  max-width: 1100px;
  margin: 0 auto;
}

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

/* Header */
header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.25rem 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 2rem;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.site-title {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text);
}

.nav {
  display: flex;
  align-items: center;
  gap: 1rem;
  font-size: 0.9rem;
}

.nav-email {
  color: var(--text-muted);
  font-size: 0.85rem;
}

.nav a.nav-active {
  font-weight: 600;
  color: var(--text);
  text-decoration: none;
  pointer-events: none;
}

/* Footer */
footer {
  border-top: 1px solid var(--border);
  padding: 1.5rem 0;
  margin-top: 3rem;
  font-size: 0.85rem;
  color: var(--text-muted);
}

/* Phase cards */
.phases {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
  margin-bottom: 2.5rem;
}

.phase-card {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.1rem;
}

.phase-card.highlight {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(13,110,253,0.15);
}

.phase-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.4rem;
}

.phase-label {
  font-weight: 600;
  font-size: 0.95rem;
}

.phase-meta {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
}

.phase-meta.warning { color: var(--stale); }

/* Status badges */
.badge {
  display: inline-block;
  padding: 0.2rem 0.65rem;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 600;
}
.badge-ok      { background: var(--ok-bg);      color: var(--ok); }
.badge-outage  { background: var(--outage-bg);   color: var(--outage); }
.badge-partial { background: var(--partial-bg);  color: var(--partial); }
.badge-stale   { background: var(--stale-bg);    color: #92400e; }
.badge-unknown { background: var(--unknown-bg);  color: var(--text-muted); }

/* Timeline strip */
.timeline {
  display: flex;
  gap: 1px;
  height: 14px;
  border-radius: 4px;
  overflow: hidden;
  background: var(--border);
  margin-top: 0.5rem;
}

.timeline-slot {
  flex: 1;
  background: var(--border);
}
.timeline-slot[data-status="ok"]      { background: var(--ok); opacity: 0.7; }
.timeline-slot[data-status="outage"]  { background: var(--outage); }
.timeline-slot[data-status="partial"] { background: var(--partial); }
.timeline-slot[data-status="stale"]   { background: var(--stale); }

.timeline-legend {
  display: flex;
  justify-content: space-between;
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-top: 0.2rem;
}

/* Messages */
.section { margin-bottom: 2rem; }
.section h2 { margin-bottom: 1rem; }

.post-form { margin-bottom: 1.5rem; }
textarea {
  display: block;
  width: 100%;
  max-width: 600px;
  min-height: 80px;
  padding: 0.6rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font-family: inherit;
  font-size: 0.95rem;
  resize: vertical;
  margin-bottom: 0.5rem;
}

.post-actions {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.char-hint { font-size: 0.8rem; color: var(--text-muted); }

.login-prompt { font-size: 0.9rem; color: var(--text-muted); margin-bottom: 1rem; }
.empty { color: var(--text-muted); font-size: 0.9rem; }

.message-list { display: flex; flex-direction: column; gap: 0.75rem; }

.message {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.75rem 1rem;
}

.message-meta {
  display: flex;
  gap: 0.75rem;
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 0.35rem;
}

.message-meta strong { color: var(--text); }
.message-category {
  background: var(--surface-raised, var(--border));
  border-radius: 4px;
  padding: 0 0.4rem;
  font-size: 0.75rem;
  white-space: nowrap;
}

.category-select {
  display: block;
  max-width: 600px;
  width: 100%;
  margin-bottom: 0.5rem;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font-size: 0.95rem;
  font-family: inherit;
}

/* Buttons and inputs */
button, input[type=submit] {
  background: var(--accent);
  color: #fff;
  border: none;
  padding: 0.45rem 1.1rem;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.9rem;
  font-family: inherit;
}

button:hover { opacity: 0.88; }

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border);
  font-size: 0.85rem;
  padding: 0.3rem 0.75rem;
}

.btn-danger {
  background: var(--outage);
  font-size: 0.8rem;
  padding: 0.2rem 0.6rem;
}

input[type=email], input[type=text] {
  padding: 0.45rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  font-size: 0.95rem;
  font-family: inherit;
}

select {
  padding: 0.45rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  font-size: 0.95rem;
  font-family: inherit;
}

.form-group { margin-bottom: 1rem; }
label { display: block; font-size: 0.85rem; margin-bottom: 0.3rem; color: var(--text-muted); }

.flash {
  background: var(--surface);
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  padding: 0.75rem 1rem;
  margin-bottom: 1.25rem;
  font-size: 0.9rem;
}

.flash-key {
  border-color: var(--ok);
  background: var(--ok-bg);
}

.key-display {
  font-family: monospace;
  font-size: 0.85rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.5rem 0.75rem;
  margin: 0.5rem 0;
  word-break: break-all;
  user-select: all;
}

/* Narrow forms (login) */
.narrow-form {
  max-width: 400px;
  margin: 0 auto;
  padding: 2rem 0;
}
.narrow-form h2 { margin-bottom: 0.5rem; }
.narrow-form .page-meta { margin-bottom: 1.5rem; color: var(--text-muted); font-size: 0.9rem; }
.narrow-form input[type=email] { width: 100%; margin-bottom: 1rem; }

/* Admin */
table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
th, td { text-align: left; padding: 0.5rem 0.75rem; border-bottom: 1px solid var(--border); }
th { font-weight: 600; background: var(--bg); }

.inline-form {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  margin-top: 0.75rem;
}
.inline-form input, .inline-form select { width: auto; }

h3 { font-size: 1.05rem; margin-bottom: 0.75rem; }
h4 { font-size: 0.95rem; color: var(--text-muted); }

/* History week-aligned grid */
.week-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 5px;
  margin-top: 1rem;
}

.dow-header {
  text-align: center;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  padding-bottom: 0.25rem;
}

.day-cell {
  border-radius: 6px;
  padding: 0.45rem 0.3rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.15rem;
  border: 1px solid transparent;
  min-width: 0;
}

.day-cell-ok                  { background: var(--ok-bg);       border-color: var(--ok);       color: var(--ok); }
.day-cell-outage-unplanned { background: var(--outage-bg);  border-color: var(--outage);  color: var(--outage); }
.day-cell-outage-planned   { background: var(--planned-bg); border-color: var(--planned); color: var(--planned); }
.day-cell-unknown             { background: var(--unknown-bg);  border-color: var(--border);   color: var(--text-muted); }
.day-cell-pad                 { background: transparent;        border-color: transparent; }

/* Slightly taller cells when admin classify controls are present */
.day-cell-admin { padding-bottom: 0.3rem; }

.day-label  { font-size: 0.68rem; font-weight: 600; white-space: nowrap; }
.day-status { font-size: 0.6rem; }

.classify-form   { width: 100%; margin-top: 3px; }
.classify-select {
  width: 100%;
  font-size: 0.6rem;
  padding: 1px 2px;
  border: 1px solid currentColor;
  border-radius: 3px;
  background: transparent;
  color: inherit;
  cursor: pointer;
  opacity: 0.85;
}

/* Legend */
.history-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  margin-top: 1rem;
  font-size: 0.8rem;
  color: var(--text-muted);
}
.legend-item { display: flex; align-items: center; gap: 0.35rem; }
.legend-swatch {
  width: 14px; height: 14px;
  border-radius: 3px;
  border: 1px solid transparent;
  flex-shrink: 0;
}
.swatch-outage-unplanned { background: var(--outage-bg);  border-color: var(--outage); }
.swatch-outage-planned   { background: var(--planned-bg); border-color: var(--planned); }
.swatch-ok               { background: var(--ok-bg);      border-color: var(--ok); }
.swatch-unknown          { background: var(--unknown-bg); border-color: var(--border); }

/* Stats */
.stat { display: inline-block; font-weight: 600; font-size: 0.85rem; }
.stat-ok                    { color: var(--ok); }
.stat-outage-unplanned { color: var(--outage); }
.stat-outage-planned   { color: var(--planned); }
.stat-unknown               { color: var(--text-muted); }

.page-meta { color: var(--text-muted); font-size: 0.9rem; margin-bottom: 1rem; }
