:root {
  --bg-sand: #f6efe3;
  --bg-cream: #fff8ec;
  --ink: #2d2418;
  --ink-soft: #6f6252;
  --line: rgba(62, 48, 29, 0.12);
  --panel: rgba(255, 250, 240, 0.82);
  --panel-strong: rgba(255, 247, 231, 0.95);
  --shadow: 0 18px 48px rgba(83, 58, 24, 0.12);
  --ok: #3f7d20;
  --warn: #cf8a13;
  --alert: #d4442f;
  --muted: #7d8595;
}

* {
  box-sizing: border-box;
}

body.heiniklo-page {
  margin: 0;
  min-height: 100vh;
  font-family: "Trebuchet MS", "Gill Sans", "Segoe UI", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at top left, rgba(176, 218, 183, 0.45), transparent 24%),
    radial-gradient(circle at top right, rgba(255, 202, 125, 0.35), transparent 28%),
    linear-gradient(180deg, var(--bg-cream), var(--bg-sand));
}

body.heiniklo-page::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(88, 68, 35, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(88, 68, 35, 0.035) 1px, transparent 1px);
  background-size: 32px 32px;
  mask-image: linear-gradient(180deg, rgba(0, 0, 0, 0.18), transparent 88%);
}

.topbar,
.status-shell,
.control-shell {
  position: relative;
  z-index: 1;
}

.topbar {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 1.25rem;
  align-items: start;
  padding: 2rem clamp(1rem, 3vw, 2.4rem) 1rem;
}

.home-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.85rem 1.1rem;
  border-radius: 999px;
  color: var(--ink);
  text-decoration: none;
  font-weight: 700;
  background: rgba(255, 255, 255, 0.68);
  border: 1px solid rgba(62, 48, 29, 0.12);
  box-shadow: 0 10px 25px rgba(90, 68, 34, 0.08);
}

.topbar-copy h1 {
  margin: 0.2rem 0 0.35rem;
  font-size: clamp(2rem, 4vw, 3.4rem);
  line-height: 0.96;
}

.topbar-copy p,
.section-hint,
.server-time,
.current-summary,
.countdown-subline,
.field-footer,
.form-message {
  color: var(--ink-soft);
}

.topbar-copy p {
  margin: 0;
  max-width: 60ch;
  font-size: 1rem;
}

.eyebrow,
.section-kicker {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  font-size: 0.78rem;
  color: #86663b;
  font-weight: 700;
}

.status-pill {
  align-self: center;
  padding: 0.95rem 1.2rem;
  border-radius: 999px;
  font-weight: 800;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  background: rgba(255, 255, 255, 0.7);
  border: 1px solid rgba(62, 48, 29, 0.12);
}

.status-pill[data-state="loading"] {
  color: #8b6f40;
}

.status-pill[data-state="ok"] {
  background: rgba(108, 183, 81, 0.16);
  color: var(--ok);
}

.status-pill[data-state="expired"],
.status-pill[data-state="cleared"] {
  background: rgba(255, 216, 128, 0.22);
  color: #9a6500;
}

.status-pill[data-state="active"] {
  background: rgba(228, 82, 59, 0.18);
  color: var(--alert);
}

.page-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(320px, 0.95fr);
  gap: clamp(1rem, 2vw, 1.6rem);
  padding: 0 clamp(1rem, 3vw, 2.4rem) 2.4rem;
}

.status-shell,
.control-shell {
  padding: clamp(1rem, 2vw, 1.5rem);
  border-radius: 28px;
  border: 1px solid var(--line);
  background: var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
}

.control-shell {
  background:
    radial-gradient(circle at top right, rgba(240, 173, 78, 0.12), transparent 36%),
    var(--panel-strong);
}

.section-topline {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: center;
  margin-bottom: 1rem;
}

.hero-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
}

.history-shell {
  margin-top: 1rem;
}

.hero-card {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  padding: 1.25rem;
  border-radius: 24px;
  border: 1px solid rgba(62, 48, 29, 0.1);
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.72), rgba(255, 248, 234, 0.86));
}

.hero-card-primary {
  background:
    radial-gradient(circle at top left, rgba(153, 219, 148, 0.24), transparent 32%),
    linear-gradient(145deg, rgba(255, 255, 255, 0.82), rgba(245, 238, 225, 0.95));
}

.hero-card-timer {
  background:
    radial-gradient(circle at top left, rgba(255, 188, 124, 0.24), transparent 32%),
    linear-gradient(145deg, rgba(255, 252, 246, 0.86), rgba(248, 235, 215, 0.95));
}

.hero-label {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  color: #8c6e44;
  font-weight: 800;
}

.current-type {
  font-size: clamp(1.5rem, 3vw, 2.4rem);
  line-height: 0.95;
  font-weight: 900;
}

.current-severity {
  display: inline-flex;
  align-self: flex-start;
  padding: 0.4rem 0.75rem;
  border-radius: 999px;
  background: rgba(62, 48, 29, 0.08);
  font-weight: 700;
}

.current-summary {
  margin: 0;
  min-height: 3.3rem;
}

.current-note {
  min-height: 4.2rem;
  padding: 0.9rem 1rem;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.62);
  border: 1px dashed rgba(62, 48, 29, 0.18);
  line-height: 1.45;
}

.current-note.is-empty {
  color: var(--muted);
}

.countdown-clock {
  font-family: "Courier New", monospace;
  font-size: clamp(2rem, 4.5vw, 3rem);
  font-weight: 900;
  letter-spacing: 0.04em;
}

.progress-track {
  width: 100%;
  height: 12px;
  border-radius: 999px;
  overflow: hidden;
  background: rgba(80, 60, 35, 0.1);
}

.progress-bar {
  height: 100%;
  width: 0;
  border-radius: inherit;
  background: linear-gradient(90deg, #4caf50, #f59e0b, #dc2626);
  transition: width 180ms ease;
}

.meta-list {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.75rem;
  margin: 0;
}

.meta-list div {
  padding: 0.8rem 0.9rem;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.64);
  border: 1px solid rgba(62, 48, 29, 0.08);
}

.meta-list dt {
  margin-bottom: 0.3rem;
  font-size: 0.76rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: #8b7450;
}

.meta-list dd {
  margin: 0;
  font-weight: 700;
  line-height: 1.3;
}

.section-topline-history {
  margin-bottom: 0.85rem;
}

.history-list {
  display: grid;
  gap: 0.85rem;
}

.history-entry,
.history-empty {
  border-radius: 22px;
  border: 1px solid rgba(62, 48, 29, 0.1);
  background: rgba(255, 255, 255, 0.72);
  box-shadow: 0 10px 18px rgba(101, 75, 39, 0.06);
}

.history-entry {
  --accent: #c08457;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  padding: 1rem 1.05rem;
  border-left: 4px solid var(--accent);
}

.history-empty {
  padding: 1rem 1.05rem;
  color: var(--ink-soft);
}

.history-entry-head {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  align-items: center;
}

.history-badge {
  display: inline-flex;
  align-items: center;
  padding: 0.3rem 0.65rem;
  border-radius: 999px;
  background: color-mix(in srgb, var(--accent) 14%, white);
  color: #5d4122;
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.history-time,
.history-entry-meta {
  color: var(--ink-soft);
  font-size: 0.92rem;
}

.history-entry-title {
  font-size: 1.05rem;
  font-weight: 900;
}

.history-entry-summary {
  margin: 0;
  line-height: 1.4;
}

.history-entry-note {
  padding: 0.75rem 0.85rem;
  border-radius: 16px;
  background: rgba(248, 242, 231, 0.92);
  border: 1px dashed rgba(62, 48, 29, 0.16);
  color: var(--ink-soft);
  line-height: 1.45;
}

.control-form {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.field-block {
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
}

.field-label {
  font-size: 0.96rem;
  font-weight: 800;
}

.scale-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.8rem;
}

.scale-card {
  --accent: #d97706;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding: 1rem;
  border-radius: 22px;
  border: 1px solid rgba(62, 48, 29, 0.1);
  background: rgba(255, 255, 255, 0.72);
  cursor: pointer;
  text-align: left;
  transition: transform 180ms ease, box-shadow 180ms ease, border-color 180ms ease;
  box-shadow: 0 10px 18px rgba(101, 75, 39, 0.06);
}

.scale-card:hover,
.scale-card:focus-visible {
  transform: translateY(-2px);
  box-shadow: 0 16px 28px rgba(101, 75, 39, 0.14);
  outline: none;
}

.scale-card.is-selected {
  border-color: var(--accent);
  box-shadow: 0 16px 32px color-mix(in srgb, var(--accent) 28%, transparent);
}

.scale-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.scale-card-number {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.2rem;
  height: 2.2rem;
  border-radius: 50%;
  background: color-mix(in srgb, var(--accent) 16%, white);
  color: #3a2b17;
  font-weight: 900;
}

.scale-card-title {
  font-weight: 900;
}

.scale-card-severity {
  font-weight: 700;
  color: #7c5832;
}

.scale-card-description {
  font-size: 0.95rem;
  line-height: 1.4;
  color: var(--ink-soft);
}

.preset-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
}

.preset-button,
.duration-input,
.note-input,
.action-button {
  font: inherit;
}

.preset-button {
  min-width: 3.2rem;
  padding: 0.65rem 0.85rem;
  border-radius: 999px;
  border: 1px solid rgba(62, 48, 29, 0.12);
  background: rgba(255, 255, 255, 0.8);
  cursor: pointer;
  font-weight: 700;
}

.preset-button.is-selected {
  background: rgba(91, 161, 78, 0.18);
  border-color: rgba(63, 125, 32, 0.38);
  color: var(--ok);
}

.duration-input,
.note-input {
  width: 100%;
  border-radius: 18px;
  border: 1px solid rgba(62, 48, 29, 0.14);
  background: rgba(255, 255, 255, 0.86);
  padding: 0.95rem 1rem;
  color: var(--ink);
}

.duration-input {
  font-size: 1.1rem;
  font-weight: 800;
}

.note-input {
  resize: vertical;
  min-height: 6.8rem;
  line-height: 1.45;
}

.field-footer {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  font-size: 0.9rem;
}

.action-row {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.action-button {
  padding: 0.95rem 1.2rem;
  border: none;
  border-radius: 18px;
  cursor: pointer;
  font-weight: 900;
  letter-spacing: 0.01em;
}

.action-button:disabled {
  opacity: 0.55;
  cursor: wait;
}

.action-button-primary {
  color: #fff7ec;
  background: linear-gradient(135deg, #b5561d, #df6a25);
  box-shadow: 0 14px 28px rgba(189, 87, 24, 0.22);
}

.action-button-secondary {
  color: var(--ink);
  background: rgba(255, 255, 255, 0.82);
  border: 1px solid rgba(62, 48, 29, 0.12);
}

.form-message {
  min-height: 1.4rem;
  margin: 0;
  font-weight: 700;
}

.form-message.is-success {
  color: var(--ok);
}

.form-message.is-error {
  color: var(--alert);
}

.noscript-banner {
  margin: 0 1rem 1rem;
  padding: 1rem;
  border-radius: 18px;
  background: rgba(212, 68, 47, 0.14);
  color: #8c2f23;
  font-weight: 700;
}

@media (max-width: 980px) {
  .page-grid,
  .hero-grid,
  .topbar {
    grid-template-columns: 1fr;
  }

  .status-pill {
    justify-self: start;
  }
}

@media (max-width: 640px) {
  .meta-list,
  .scale-grid {
    grid-template-columns: 1fr;
  }

  .field-footer {
    flex-direction: column;
  }

  .action-row {
    flex-direction: column;
  }

  .action-button {
    width: 100%;
  }
}
