:root {
  --header-height: 6.5vh;
  --bg: #0f1b2d;
  --header-bg: #13294b;
  --accent: #ffb703;
  --card-bg: #ffffff;
  --card-fg: #14213d;
  --card-border: #e2e8f0;
  --today-bg: #fff3cd;
  --muted: #6b7280;
  --grid-gap: 1.2vh;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--card-fg);
  font-family: "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  overflow: hidden;
}

/* ---------- Board (display.html) ---------- */

.board {
  display: flex;
  flex-direction: column;
  height: 100vh;
  width: 100vw;
}

.board-header {
  height: var(--header-height);
  min-height: 56px;
  background: var(--header-bg);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 clamp(16px, 2vw, 40px);
  flex-shrink: 0;
}

.board-header .class-name {
  font-size: clamp(22px, 3.4vw, 48px);
  font-weight: 700;
  letter-spacing: 0.02em;
}

.board-header .clock {
  font-size: clamp(18px, 2.4vw, 34px);
  font-variant-numeric: tabular-nums;
  color: var(--accent);
  font-weight: 600;
}

.board-main {
  flex: 1;
  padding: var(--grid-gap);
  display: grid;
  grid-template-columns: repeat(var(--grid-columns, 3), 1fr);
  grid-auto-rows: 1fr;
  gap: var(--grid-gap);
  overflow: hidden;
}

.board-empty {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #cbd5e1;
  font-size: clamp(18px, 2vw, 28px);
}

.widget-card {
  background: var(--card-bg);
  color: var(--card-fg);
  border-radius: 14px;
  padding: clamp(10px, 1.4vw, 22px);
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
  box-shadow: 0 2px 10px rgba(0,0,0,0.18);
  border-top: 4px solid var(--accent);
}

.widget-title {
  display: flex;
  align-items: center;
  gap: 0.4em;
  font-size: clamp(16px, 1.6vw, 26px);
  font-weight: 700;
  margin: 0 0 0.5em 0;
  color: var(--header-bg);
  flex-shrink: 0;
}

.widget-icon {
  display: inline-flex;
  flex-shrink: 0;
  color: var(--accent);
  background: rgba(255, 183, 3, 0.16);
  background: color-mix(in srgb, var(--accent) 16%, transparent);
  border-radius: 8px;
  padding: 0.25em;
}
.widget-icon svg {
  display: block;
  width: 1em;
  height: 1em;
}

.widget-body {
  flex: 1;
  min-height: 0;
  overflow: auto;
  font-size: clamp(13px, 1.25vw, 20px);
}

/* dinner-menu widget */
.dinner-day-heading {
  font-size: clamp(16px, 1.6vw, 24px);
  font-weight: 700;
  margin: 0 0 0.6em 0;
  color: var(--header-bg);
}
.dinner-options { display: flex; flex-direction: column; gap: 0.6em; }
.dinner-option {
  display: flex;
  align-items: flex-start;
  gap: 0.7em;
  padding: 0.55em 0.7em;
  border-radius: 10px;
  background: #f8f9fb;
}
.dinner-option-badge {
  flex-shrink: 0;
  font-size: 0.78em;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: #fff;
  padding: 0.3em 0.7em;
  border-radius: 999px;
  min-width: 3.6em;
  text-align: center;
}
.dinner-option-red .dinner-option-badge { background: #c0392b; }
.dinner-option-green .dinner-option-badge { background: #2f8f4e; }
.dinner-option-blue .dinner-option-badge { background: #2f6fb8; }
.dinner-option-text { flex: 1; }
.dinner-status { color: var(--muted); font-style: italic; }
.dinner-error { color: #b91c1c; }
.dinner-empty { color: var(--muted); font-style: italic; }

/* countdown widget */
.countdown-widget {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: clamp(10px, 2vh, 22px);
  text-align: center;
}
.countdown-display {
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  font-size: clamp(40px, 8vw, 110px);
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  color: var(--header-bg);
  letter-spacing: 0.02em;
  line-height: 1;
}
.countdown-widget.countdown-done .countdown-display {
  color: #b91c1c;
  animation: countdown-pulse 1s ease-in-out infinite;
}
@keyframes countdown-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.35; }
}
.countdown-presets {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5em;
  justify-content: center;
}
.countdown-preset {
  font-family: inherit;
  font-size: clamp(13px, 1.3vw, 19px);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  padding: 0.5em 0.9em;
  min-width: 2.6em;
  border-radius: 10px;
  border: 2px solid var(--header-bg);
  background: #fff;
  color: var(--header-bg);
  text-align: center;
}
button.countdown-preset { cursor: pointer; }
button.countdown-preset:hover { background: var(--header-bg); color: #fff; }
button.countdown-preset:active { transform: scale(0.95); }
.countdown-preset-static { opacity: 0.85; }
.countdown-reset {
  font-size: clamp(15px, 1.5vw, 21px);
  line-height: 1;
  padding: 0.45em 0.65em;
  border-radius: 10px;
  border: 2px solid var(--card-border);
  background: #fff;
  color: var(--muted);
  cursor: pointer;
}
.countdown-reset:hover { border-color: var(--muted); color: var(--card-fg); }

/* word-of-the-week widget */
.word-headline {
  font-size: clamp(24px, 3vw, 44px);
  font-weight: 800;
  margin: 0 0 0.25em 0;
  color: var(--header-bg);
  text-transform: capitalize;
}
.word-definition { margin: 0 0 0.5em 0; }
.word-example { margin: 0; font-style: italic; color: var(--muted); }
.word-status { color: var(--muted); font-style: italic; }
.word-error { color: #b91c1c; }

/* weather widget */
.weather-location { font-weight: 700; margin: 0 0 0.6em 0; color: var(--header-bg); }
.weather-slots { display: flex; flex-wrap: wrap; gap: 0.9em; }
.weather-slot {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.15em;
  min-width: 4em;
  flex: 1 1 4em;
}
.weather-time { font-size: 0.82em; color: var(--muted); font-variant-numeric: tabular-nums; }
.weather-icon svg { display: block; width: clamp(26px, 3vw, 44px); height: clamp(26px, 3vw, 44px); }
.weather-temp { font-weight: 700; font-size: 1.05em; }
.weather-status { color: var(--muted); font-style: italic; }
.weather-error { color: #b91c1c; }

/* announcements widget */
.announcements-list { margin: 0; padding-left: 1.2em; }
.announcements-list li { margin-bottom: 0.5em; }
.announcements-empty { color: var(--muted); font-style: italic; }

/* start-of-day widget */
.sotd-widget {
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}
.sotd-image { max-width: 100%; max-height: 100%; object-fit: contain; border-radius: 8px; }
.sotd-empty { color: var(--muted); font-style: italic; text-align: center; }

/* ---------- Admin (admin.html) ---------- */

.admin-wrap {
  max-width: 960px;
  margin: 0 auto;
  padding: 24px 20px 80px;
  overflow-y: auto;
  height: 100vh;
}

.admin-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
}

.admin-header h1 { font-size: 1.6rem; margin: 0; }

.card {
  background: #fff;
  border: 1px solid var(--card-border);
  border-radius: 12px;
  padding: 20px;
  margin-bottom: 20px;
}

.card h2 { margin-top: 0; font-size: 1.15rem; }

.field { display: block; margin-bottom: 14px; }
.field span { display: block; font-weight: 600; margin-bottom: 4px; font-size: 0.92rem; }
.field input[type="text"],
.field input[type="password"],
.field input[type="time"],
.field input[type="number"],
.field select,
.field textarea {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--card-border);
  border-radius: 8px;
  font-size: 0.95rem;
  font-family: inherit;
}
.field textarea { resize: vertical; }

.row { display: flex; gap: 14px; flex-wrap: wrap; }
.row .field { flex: 1; min-width: 140px; }

.widget-editor {
  border: 1px solid var(--card-border);
  border-radius: 10px;
  padding: 16px;
  margin-bottom: 16px;
  position: relative;
}
.widget-editor-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}
.widget-editor-head strong { font-size: 1.02rem; }

/* start-of-day admin upload UI */
.batch-zone {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  border: 2px dashed var(--card-border);
  border-radius: 10px;
  padding: 12px 14px;
  margin-bottom: 14px;
  transition: border-color 0.15s, background 0.15s;
}
.batch-zone.drag-over { border-color: var(--accent); background: rgba(255, 183, 3, 0.08); }
.batch-zone-text strong { display: block; font-size: 0.9rem; }
.batch-zone-text span { color: var(--muted); font-size: 0.78rem; }

.sotd-day-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 12px; margin-bottom: 12px; }
@media (max-width: 700px) { .sotd-day-grid { grid-template-columns: repeat(2, 1fr); } }

.day-card {
  border: 1px solid var(--card-border);
  border-radius: 10px;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.day-name { font-weight: 700; font-size: 0.85rem; }
.day-thumb {
  aspect-ratio: 16 / 9;
  background: #eef1f6;
  border-radius: 6px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}
.day-thumb img { width: 100%; height: 100%; object-fit: contain; display: block; }
.sotd-form-status { color: var(--muted); font-size: 0.76rem; font-style: italic; margin: 0; padding: 0 4px; text-align: center; }
.day-updated { font-size: 0.72rem; }
.day-updated.fresh { color: #2f8f4e; }
.day-updated.aging { color: var(--muted); }
.day-updated.stale { color: #b91c1c; font-style: italic; }
.day-replace {
  font-family: inherit;
  font-size: 0.75rem;
  font-weight: 600;
  border: 1px solid var(--card-border);
  background: #fff;
  color: var(--card-fg);
  border-radius: 6px;
  padding: 5px 6px;
  cursor: pointer;
}
.day-replace:hover { border-color: var(--header-bg); }

button {
  cursor: pointer;
  border: none;
  border-radius: 8px;
  padding: 9px 16px;
  font-size: 0.92rem;
  font-weight: 600;
  font-family: inherit;
}
.btn-primary { background: var(--header-bg); color: #fff; }
.btn-primary:hover { background: #0d1e3a; }
.btn-secondary { background: #eef1f5; color: var(--card-fg); }
.btn-secondary:hover { background: #e2e6eb; }
.btn-danger { background: #fee2e2; color: #991b1b; }
.btn-danger:hover { background: #fecaca; }
.btn-small { padding: 6px 10px; font-size: 0.82rem; }

.status-msg {
  margin-top: 10px;
  font-size: 0.9rem;
  padding: 10px 12px;
  border-radius: 8px;
}
.status-msg.ok { background: #dcfce7; color: #14532d; }
.status-msg.err { background: #fee2e2; color: #7f1d1d; }
.status-msg.info { background: #e0f2fe; color: #075985; }

.login-wrap {
  height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
}
.login-card {
  background: #fff;
  border-radius: 14px;
  padding: 32px;
  width: 320px;
  text-align: center;
}
.login-card h1 { font-size: 1.3rem; margin-top: 0; }

.hint { color: var(--muted); font-size: 0.85rem; margin-top: 4px; }

.preview-frame-wrap {
  border: 1px solid var(--card-border);
  border-radius: 10px;
  overflow: hidden;
  background: var(--bg);
}
