:root {
  --bg-body: #f4f6fb;
  --bg-card: rgba(255, 255, 255, 0.88);
  --bg-card-strong: #ffffff;
  --bg-soft: #eef2ff;
  --text-main: #172033;
  --text-muted: #66738a;
  --primary: #d7263d;
  --primary-soft: rgba(215, 38, 61, 0.1);
  --accent: #d7263d;
  --border: rgba(23, 32, 51, 0.12);
  --shadow: 0 24px 70px rgba(26, 38, 74, 0.15);
  --passing-bg: #fff6e5;
  --passing-primary: #c86a00;
  --timer-bg: #fff4cc;
  --timer-border: #e6a700;
}

body.dark-theme {
  --bg-body: #111827;
  --bg-card: rgba(22, 29, 45, 0.92);
  --bg-card-strong: #182133;
  --bg-soft: #202c44;
  --text-main: #f3f7ff;
  --text-muted: #b7c2d8;
  --primary: #ff8ea0;
  --primary-soft: rgba(255, 142, 160, 0.15);
  --accent: #ff8ea0;
  --border: rgba(255, 255, 255, 0.1);
  --shadow: 0 24px 70px rgba(0, 0, 0, 0.45);
  --passing-bg: #3a2b12;
  --passing-primary: #ffbf66;
  --timer-bg: #3f3420;
  --timer-border: #ffbf66;
}

body.passing-period {
  --bg-body: var(--passing-bg);
  --primary: var(--passing-primary);
  --accent: var(--passing-primary);
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  font-family: "Inter", "Segoe UI", system-ui, sans-serif;
  color: var(--text-main);
  background:
    radial-gradient(circle at top left, rgba(215, 38, 61, 0.1), transparent 28%),
    radial-gradient(circle at bottom right, rgba(43, 108, 176, 0.12), transparent 24%),
    var(--bg-body);
  transition: background-color 180ms ease, color 180ms ease, border-color 180ms ease;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.page-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 28px 20px;
}

.app-card {
  width: min(920px, 100%);
  border-radius: 28px;
  border: 1px solid var(--border);
  background: var(--bg-card);
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
  overflow: hidden;
}

.app-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  padding: 24px 28px 18px;
  border-bottom: 1px solid var(--border);
}

.header-copy {
  min-width: 0;
}

.eyebrow {
  margin: 0 0 6px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--text-muted);
}

h1,
h2 {
  margin: 0;
}

#schoolName {
  font-size: clamp(2rem, 4vw, 2.9rem);
  line-height: 0.95;
  letter-spacing: -0.03em;
}

.header-detail {
  margin: 10px 0 0;
  color: var(--text-muted);
}

.header-controls {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
}

.compact-control,
.icon-button,
.field select,
.field input,
.timer-display input {
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--bg-card-strong);
  color: var(--text-main);
}

.compact-control {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 12px;
  color: var(--text-muted);
}

.compact-control select {
  border: 0;
  background: transparent;
  color: var(--text-main);
}

.toggle-control input {
  accent-color: var(--primary);
}

.icon-button {
  min-height: 44px;
  padding: 0 14px;
  font-weight: 600;
}

.icon-button:hover,
.action-button:hover,
.timer-presets button:hover {
  transform: translateY(-1px);
}

.app-main {
  display: grid;
  gap: 18px;
  padding: 20px 24px 24px;
}

.timer-panel,
.clock-panel,
.modal-card,
.settings-block {
  border: 1px solid var(--border);
  background: var(--bg-card-strong);
}

.timer-panel {
  display: grid;
  gap: 16px;
  padding: 18px;
  border-radius: 22px;
  background: var(--timer-bg);
  border-color: var(--timer-border);
}

.timer-panel-title {
  font-size: 1.15rem;
  font-weight: 700;
}

.timer-panel-hint,
.settings-help,
.timer-shortcut-note {
  color: var(--text-muted);
  font-size: 0.95rem;
  line-height: 1.45;
}

.timer-display {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  font-size: clamp(4rem, 10vw, 6.5rem);
  font-weight: 800;
  letter-spacing: -0.06em;
}

.timer-display input {
  width: 1.9em;
  padding: 6px 8px;
  font-size: inherit;
  font-weight: inherit;
  text-align: center;
}

#timerMinutes.is-wide {
  width: 2.8em;
}

.timer-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.timer-presets,
.timer-actions,
.settings-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.timer-presets button,
.action-button {
  border: 0;
  border-radius: 12px;
  padding: 10px 14px;
  font-weight: 700;
}

.timer-presets button {
  background: var(--bg-card-strong);
  color: var(--text-main);
  border: 1px solid var(--border);
}

.action-button {
  color: white;
}

.action-start {
  background: #1d9b5b;
}

.action-pause {
  background: #9b5c13;
}

.action-reset {
  background: #5d6b82;
}

.timer-shortcut-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  padding-top: 4px;
}

.clock-panel {
  border-radius: 24px;
  padding: 22px;
}

.time-display {
  text-align: center;
}

#clockTime {
  font-size: clamp(4rem, 10vw, 6.6rem);
  font-weight: 800;
  letter-spacing: -0.06em;
  line-height: 0.95;
}

#clockDate {
  margin-top: 10px;
  color: var(--text-muted);
  font-size: 1.2rem;
}

.status-display {
  text-align: center;
  padding: 22px 0 8px;
}

#statusTitle {
  font-size: 1.4rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
}

#statusSubtitle {
  margin-top: 6px;
  font-size: clamp(2.8rem, 6vw, 4.7rem);
  font-weight: 800;
  line-height: 1.05;
  color: var(--primary);
}

.progress-panel {
  margin-top: 18px;
}

.progress-header {
  display: flex;
  justify-content: space-between;
  margin-bottom: 10px;
  font-weight: 700;
  color: var(--text-muted);
}

.progress-track {
  position: relative;
  height: 18px;
  border-radius: 999px;
  background: var(--bg-soft);
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  width: 0%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--primary), color-mix(in srgb, var(--primary) 72%, white));
  transition: width 900ms linear;
}

.progress-mark {
  position: absolute;
  top: 2px;
  bottom: 2px;
  width: 2px;
  background: rgba(255, 255, 255, 0.65);
  border-radius: 999px;
}

.modal {
  border: 0;
  padding: 0;
  background: transparent;
  width: min(760px, calc(100vw - 24px));
}

.modal::backdrop {
  background: rgba(12, 18, 31, 0.45);
  backdrop-filter: blur(8px);
}

.modal-card {
  border-radius: 24px;
  padding: 20px;
  box-shadow: var(--shadow);
}

.modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 18px;
}

.field {
  display: grid;
  gap: 8px;
}

.field span,
.settings-label {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text-muted);
}

.field select,
.field input {
  min-height: 44px;
  padding: 0 12px;
}

.settings-grid {
  display: grid;
  gap: 14px;
}

.settings-block {
  border-radius: 18px;
  padding: 16px;
}

.settings-value {
  margin-top: 6px;
  font-size: 1.15rem;
  font-weight: 700;
}

.schedule-list {
  display: grid;
  gap: 10px;
  margin-top: 16px;
}

.schedule-row {
  display: grid;
  grid-template-columns: 110px 1fr;
  gap: 14px;
  align-items: center;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--bg-card-strong);
}

.schedule-time {
  font-weight: 700;
  color: var(--text-muted);
}

.schedule-period {
  font-size: 1.05rem;
  font-weight: 700;
}

.schedule-note {
  color: var(--text-muted);
  margin-top: 2px;
  font-size: 0.92rem;
}

.timer-display.flashing input {
  animation: flash 450ms ease-in-out 6;
}

@keyframes flash {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.28;
  }
}

@media (max-width: 800px) {
  .app-header,
  .timer-toolbar {
    flex-direction: column;
    align-items: stretch;
  }

  .header-controls {
    justify-content: flex-start;
  }

  .schedule-row {
    grid-template-columns: 1fr;
  }

  .timer-shortcut-bar {
    align-items: flex-start;
    flex-direction: column;
  }
}
