:root {
  --bg: #f4f5f7;
  --card-bg: #ffffff;
  --text: #1c1e21;
  --text-muted: #6b7280;
  --border: #e5e7eb;
  --primary: #2563eb;
  --primary-light: #eff4ff;
  --error-bg: #fef2f2;
  --error-text: #b91c1c;
  --error-border: #fecaca;
  --sand-1: #f5b942;
  --sand-2: #b9750f;
  --glass-stroke: #94a3b8;
  --radius: 14px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #14161a;
    --card-bg: #1e2126;
    --text: #f0f1f3;
    --text-muted: #9aa0ab;
    --border: #2c3036;
    --primary: #5b8def;
    --primary-light: #1c2636;
    --error-bg: #2a1616;
    --error-text: #f87171;
    --error-border: #4c1f1f;
    --glass-stroke: #6b7684;
  }
}

:root[data-theme="dark"] {
  --bg: #14161a;
  --card-bg: #1e2126;
  --text: #f0f1f3;
  --text-muted: #9aa0ab;
  --border: #2c3036;
  --primary: #5b8def;
  --primary-light: #1c2636;
  --error-bg: #2a1616;
  --error-text: #f87171;
  --error-border: #4c1f1f;
  --glass-stroke: #6b7684;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

.page {
  max-width: 560px;
  margin: 0 auto;
  padding: 32px 16px 48px;
}

.breadcrumb {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 16px;
}

.breadcrumb a {
  color: var(--text-muted);
  text-decoration: none;
}

.breadcrumb a:hover {
  color: var(--primary);
  text-decoration: underline;
}

.header {
  text-align: center;
  margin-bottom: 24px;
}

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

.subtitle {
  color: var(--text-muted);
  margin: 0;
  font-size: 0.95rem;
}

.intro {
  color: var(--text-muted);
  margin: 10px 0 0;
  font-size: 0.85rem;
  line-height: 1.5;
}

.card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
}

.ad-slot {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100px;
  border: 1px dashed var(--border);
  border-radius: 10px;
  color: var(--text-muted);
  font-size: 0.75rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.ad-slot-top {
  margin-bottom: 20px;
}

.ad-slot-bottom {
  margin-top: 20px;
}

.field {
  margin-bottom: 18px;
}

.field > label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 8px;
  color: var(--text-muted);
  text-align: center;
}

.duration-group {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg);
  padding: 10px 14px;
  max-width: 220px;
  margin: 0 auto;
  transition: border-color 0.15s ease;
}

.duration-group:focus-within {
  border-color: var(--primary);
}

.duration-group input {
  width: 3.2ch;
  border: none;
  background: transparent;
  text-align: center;
  font-size: 1.8rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--text);
  padding: 4px 0;
}

.duration-group input:focus {
  outline: none;
}

.duration-group input:disabled {
  color: var(--text-muted);
}

.duration-sep {
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--text-muted);
  transform: translateY(-2px);
}

.duration-labels {
  display: flex;
  justify-content: center;
  gap: 48px;
  margin-top: 4px;
  font-size: 0.72rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.error {
  background: var(--error-bg);
  border: 1px solid var(--error-border);
  color: var(--error-text);
  border-radius: 10px;
  padding: 12px 14px;
  font-size: 0.85rem;
  margin-bottom: 18px;
  text-align: center;
}

.hidden {
  display: none;
}

.hourglass-wrap {
  display: flex;
  justify-content: center;
  padding: 8px 0 4px;
  border-radius: 12px;
  transition: box-shadow 0.4s ease;
}

.hourglass-wrap.finished {
  animation: finished-pulse 1.1s ease-in-out infinite;
}

@keyframes finished-pulse {
  0%, 100% { filter: drop-shadow(0 0 6px rgba(239, 68, 68, 0.35)); }
  50% { filter: drop-shadow(0 0 18px rgba(239, 68, 68, 0.75)); }
}

#hourglass-canvas {
  display: block;
  max-width: 100%;
}

.digital-display {
  text-align: center;
  font-size: 2.4rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.04em;
  color: var(--text);
  margin-top: 6px;
}

.status-message {
  text-align: center;
  color: var(--error-text);
  font-weight: 600;
  font-size: 0.95rem;
  margin: 6px 0 0;
}

.controls {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin-top: 20px;
  flex-wrap: wrap;
}

.btn {
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 11px 20px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s ease, transform 0.05s ease;
}

.btn:active {
  transform: scale(0.97);
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
}

.btn-outline {
  background: transparent;
  border-color: var(--border);
  color: var(--text);
}

.btn-secondary {
  background: var(--primary-light);
  color: var(--primary);
}

.footer {
  text-align: center;
  color: var(--text-muted);
  font-size: 0.8rem;
  margin-top: 20px;
}
