:root {
  --ink: #10221f;
  --muted: #5a6b67;
  --line: #c9d7d0;
  --paper: #fbfcf7;
  --panel: #ffffff;
  --panel-strong: #f3f7ef;
  --brand: #14352f;
  --brand-2: #1f5b4f;
  --accent: #d88b1f;
  --accent-2: #f4c25d;
  --danger: #b3261e;
  --danger-bg: #fff0eb;
  --shadow: 0 24px 80px rgba(16, 34, 31, 0.14);
  --radius: 8px;
  --control: 60px;
  color-scheme: light;
  font-family: Atkinson Hyperlegible, Verdana, Tahoma, sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  overflow-x: hidden;
  background: var(--paper);
  color: var(--ink);
}

body {
  min-height: 100vh;
  margin: 0;
  overflow-x: hidden;
  font-size: 20px;
  line-height: 1.45;
  letter-spacing: 0;
}

button,
input,
select,
textarea {
  font: inherit;
  letter-spacing: 0;
}

button {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.54;
}

.app-shell {
  min-height: 100vh;
  overflow-x: hidden;
  background:
    linear-gradient(90deg, rgba(20, 53, 47, 0.05) 1px, transparent 1px),
    linear-gradient(0deg, rgba(20, 53, 47, 0.04) 1px, transparent 1px),
    var(--paper);
  background-size: 44px 44px;
}

.app-shell[data-theme="night"] {
  --ink: #f4fbf4;
  --muted: #b5c7bf;
  --line: #39534d;
  --paper: #0f1e1b;
  --panel: #162a26;
  --panel-strong: #1f3a34;
  --brand: #cfe7d8;
  --brand-2: #9bd7bf;
  --accent: #f0b24d;
  --accent-2: #ffe2a3;
  --danger: #ffb5a7;
  --danger-bg: #3d1d18;
  --shadow: 0 24px 80px rgba(0, 0, 0, 0.38);
  color-scheme: dark;
}

.app-shell[data-theme="contrast"] {
  --ink: #000000;
  --muted: #111111;
  --line: #000000;
  --paper: #ffffff;
  --panel: #ffffff;
  --panel-strong: #f3f3f3;
  --brand: #000000;
  --brand-2: #000000;
  --accent: #d06b00;
  --accent-2: #ffcf33;
  --danger: #c00000;
  --danger-bg: #ffffff;
  --shadow: none;
}

.app-shell[data-density="xl"] {
  font-size: 23px;
  --control: 68px;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: minmax(210px, 1fr) auto;
  align-items: center;
  gap: 20px;
  padding: 16px clamp(18px, 4vw, 44px);
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--paper) 92%, transparent);
  backdrop-filter: blur(16px);
}

.brand {
  display: inline-flex;
  min-width: 0;
  align-items: center;
  gap: 12px;
  color: var(--ink);
  text-decoration: none;
}

.brand-mark {
  display: grid;
  width: 52px;
  height: 52px;
  flex: 0 0 auto;
  place-items: center;
  border: 3px solid var(--brand);
  border-radius: var(--radius);
  color: var(--brand);
  font-size: 18px;
  font-weight: 900;
}

.brand strong,
.brand small {
  display: block;
}

.brand strong {
  font-size: 24px;
  line-height: 1;
}

.brand small {
  margin-top: 3px;
  color: var(--muted);
  font-size: 14px;
}

.mode-tabs {
  display: flex;
  gap: 6px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
}

.panel-stack .mode-tabs {
  width: max-content;
  margin-bottom: 14px;
}

.mode-tab {
  min-height: 48px;
  padding: 0 18px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-weight: 800;
}

.mode-tab.is-active {
  background: var(--brand);
  color: var(--paper);
}

.top-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.icon-button,
.quiet-button,
.small-button,
.secondary-button,
.primary-button,
.snooze-button,
.stop-button {
  min-height: var(--control);
  border-radius: var(--radius);
  font-weight: 900;
}

.icon-button {
  width: var(--control);
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink);
  font-size: 26px;
}

.quiet-button,
.small-button,
.secondary-button {
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink);
}

.quiet-button,
.small-button {
  padding: 0 18px;
}

.primary-button,
.secondary-button,
.snooze-button,
.stop-button {
  padding: 0 24px;
}

.primary-button {
  border: 2px solid var(--brand);
  background: var(--brand);
  color: var(--paper);
}

.secondary-button {
  border: 2px solid var(--brand);
  background: var(--panel);
  color: var(--brand);
}

.primary-button.fill {
  width: 100%;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(360px, 420px);
  grid-template-areas:
    "clock controls"
    "manage controls";
  gap: 20px 24px;
  width: min(1480px, 100%);
  margin: 0 auto;
  padding: 28px clamp(18px, 4vw, 44px) 44px;
}

.clock-stage {
  grid-area: clock;
  min-width: 0;
}

.clock-card {
  display: flex;
  min-height: 500px;
  flex-direction: column;
  justify-content: center;
  padding: clamp(26px, 4vw, 58px);
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background:
    linear-gradient(180deg, color-mix(in srgb, var(--panel) 96%, var(--accent-2)), var(--panel-strong));
  box-shadow: var(--shadow);
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.current-time {
  display: flex;
  align-items: baseline;
  gap: 14px;
  margin: 0;
  color: var(--brand);
  font-variant-numeric: tabular-nums;
  font-size: clamp(86px, 12vw, 172px);
  font-weight: 900;
  line-height: 0.86;
  white-space: nowrap;
}

.current-time small {
  font-size: clamp(26px, 3vw, 38px);
  font-weight: 900;
}

.date-line {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-top: 18px;
  color: var(--muted);
  font-size: clamp(19px, 2vw, 30px);
  font-weight: 800;
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
}

.next-alarm {
  margin-top: 28px;
  padding: 18px 20px;
  border-left: 8px solid var(--accent);
  background: color-mix(in srgb, var(--accent-2) 26%, var(--panel));
  color: var(--ink);
  font-size: clamp(22px, 2.2vw, 34px);
  font-weight: 900;
}

.primary-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 28px;
}

.panel-stack,
.side-rail {
  min-width: 0;
}

.panel-stack {
  grid-area: manage;
}

.side-rail {
  grid-area: controls;
  align-self: start;
}

.tool-panel,
.compact-panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
}

.tool-panel {
  min-height: 320px;
  padding: 28px;
}

.compact-panel {
  padding: 22px;
}

.alarm-form {
  margin-top: 18px;
}

.compact-panel + .compact-panel {
  margin-top: 16px;
}

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

.panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 22px;
}

.panel-heading h1,
.compact-panel h2,
.sheet-card h2,
.ringing-content h2 {
  margin: 0;
  font-size: clamp(30px, 3vw, 44px);
  line-height: 1;
}

.compact-panel h2 {
  font-size: 26px;
}

.is-hidden {
  display: none !important;
}

.timeline,
.set-list,
.import-list {
  display: grid;
  gap: 12px;
}

.timeline {
  grid-template-columns: repeat(auto-fit, minmax(360px, 1fr));
}

.empty-state {
  padding: 28px;
  border: 2px dashed var(--line);
  border-radius: var(--radius);
  color: var(--muted);
  font-weight: 800;
}

.alarm-row,
.set-row,
.import-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 16px;
  align-items: center;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel-strong);
}

.alarm-row .row-actions {
  grid-column: 1 / -1;
}

.time-pill {
  min-width: 126px;
  padding: 12px 16px;
  border-radius: var(--radius);
  background: var(--brand);
  color: var(--paper);
  font-size: 30px;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
  text-align: center;
}

.row-title {
  display: block;
  overflow-wrap: anywhere;
  font-size: 22px;
  font-weight: 900;
}

.row-meta {
  display: block;
  margin-top: 6px;
  color: var(--muted);
  font-size: 17px;
  font-weight: 800;
}

.row-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

.row-actions button {
  min-width: 52px;
  min-height: 52px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  color: var(--ink);
  font-size: 20px;
  font-weight: 900;
}

.set-row {
  grid-template-columns: minmax(0, 1fr) auto;
}

.set-row.is-paused {
  opacity: 0.68;
}

.set-badge {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 0 10px;
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--accent-2) 34%, var(--panel));
  color: var(--ink);
  font-size: 14px;
  font-weight: 900;
}

.field {
  display: grid;
  gap: 8px;
  color: var(--ink);
  font-weight: 900;
}

.field-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.field-line small {
  color: var(--muted);
  font-size: 14px;
  font-weight: 900;
}

.field + .field,
.time-grid + .field,
.field + .primary-button {
  margin-top: 14px;
}

.settings-panel .field {
  margin-bottom: 18px;
}

.field span {
  color: var(--muted);
  font-size: 15px;
  text-transform: uppercase;
}

input,
select,
textarea {
  width: 100%;
  min-height: var(--control);
  border: 2px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  color: var(--ink);
  padding: 0 16px;
  font-weight: 800;
}

textarea {
  min-height: 120px;
  padding: 14px 16px;
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus,
button:focus-visible {
  outline: 4px solid color-mix(in srgb, var(--accent) 70%, transparent);
  outline-offset: 3px;
}

.time-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1.14fr;
  gap: 12px;
  margin-top: 14px;
}

.toggle-list {
  display: grid;
  gap: 12px;
}

.switch-row {
  display: flex;
  min-height: var(--control);
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
  font-weight: 900;
}

.switch-row:last-child {
  border-bottom: 0;
}

.switch-row input {
  width: 34px;
  min-height: 34px;
  accent-color: var(--brand);
}

.share-layout {
  display: grid;
  gap: 16px;
  max-width: 820px;
}

.helper {
  margin: 0;
  color: var(--muted);
  font-size: 16px;
  font-weight: 800;
}

.import-sheet,
.ringing-screen {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 22px;
  background: rgba(6, 18, 16, 0.62);
}

.sheet-card {
  width: min(760px, 100%);
  max-height: min(820px, 92vh);
  overflow: auto;
  padding: clamp(24px, 4vw, 40px);
  border-radius: var(--radius);
  background: var(--panel);
  color: var(--ink);
  box-shadow: var(--shadow);
}

.sheet-summary {
  margin: 14px 0 22px;
  color: var(--muted);
  font-size: 22px;
  font-weight: 900;
}

.sheet-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 24px;
}

.import-row {
  grid-template-columns: auto minmax(0, 1fr);
}

.import-row input {
  width: 30px;
  min-height: 30px;
  accent-color: var(--brand);
}

.ringing-screen {
  background: var(--danger-bg);
}

.ringing-content {
  width: min(980px, 100%);
  text-align: center;
}

.ringing-content h2 {
  overflow-wrap: anywhere;
  color: var(--danger);
  font-size: clamp(46px, 8vw, 104px);
}

.ringing-content time {
  display: block;
  margin: 18px 0 28px;
  color: var(--ink);
  font-size: clamp(58px, 10vw, 140px);
  font-weight: 900;
  font-variant-numeric: tabular-nums;
  line-height: 0.95;
}

.ringing-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
}

.snooze-button,
.stop-button {
  min-height: 96px;
  font-size: clamp(24px, 3vw, 38px);
}

.snooze-button {
  border: 3px solid var(--accent);
  background: var(--accent-2);
  color: #1f1605;
}

.stop-button {
  border: 3px solid var(--danger);
  background: var(--danger);
  color: #ffffff;
}

.toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 70;
  max-width: min(420px, calc(100vw - 44px));
  transform: translateY(150%);
  padding: 16px 18px;
  border-radius: var(--radius);
  background: var(--brand);
  color: var(--paper);
  font-weight: 900;
  box-shadow: var(--shadow);
  transition: transform 180ms ease;
}

.toast.is-visible {
  transform: translateY(0);
}

.site-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  width: min(1480px, 100%);
  margin: 0 auto;
  padding: 28px clamp(18px, 4vw, 44px) 38px;
  color: var(--muted);
  font-size: 16px;
  font-weight: 800;
}

.site-footer strong,
.site-footer span {
  display: block;
}

.site-footer nav {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
}

.site-footer a {
  color: var(--brand);
  font-weight: 900;
  text-decoration: none;
}

.info-page {
  width: min(960px, 100%);
  margin: 0 auto;
  padding: 44px clamp(18px, 4vw, 44px);
}

.info-card {
  padding: clamp(28px, 5vw, 56px);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: var(--shadow);
}

.info-card h1 {
  margin: 0 0 18px;
  font-size: clamp(42px, 6vw, 76px);
  line-height: 1;
}

.info-card p {
  max-width: 760px;
  margin: 18px 0 0;
  color: var(--muted);
  font-size: clamp(22px, 2vw, 28px);
  font-weight: 800;
}

.info-mode .top-actions {
  display: none;
}

.display-mode .panel-stack,
.display-mode .side-rail,
.display-mode .site-footer {
  display: none;
}

.display-mode .topbar {
  position: fixed;
  top: 18px;
  right: 18px;
  left: auto;
  display: block;
  padding: 0;
  border: 0;
  background: transparent;
  backdrop-filter: none;
}

.display-mode .brand,
.display-mode .icon-button {
  display: none;
}

.display-mode .workspace {
  display: block;
  width: 100%;
  padding: 0;
}

.display-mode .clock-card {
  min-height: 100vh;
  border: 0;
  border-radius: 0;
  box-shadow: none;
}

.display-mode .quiet-button {
  background: var(--panel);
}

@media (max-width: 1100px) {
  .workspace {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas:
      "clock"
      "controls"
      "manage";
  }

  .clock-card {
    min-height: 430px;
  }

  .side-rail {
    display: block;
  }

  .compact-panel + .compact-panel {
    margin-top: 0;
  }

  .side-rail .compact-panel {
    max-width: 760px;
  }
}

@media (max-width: 820px) {
  body {
    font-size: 19px;
  }

  .topbar {
    position: static;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 14px;
    overflow: hidden;
  }

  .topbar > * {
    min-width: 0;
    max-width: 100%;
  }

  .brand small {
    display: none;
  }

  .brand strong {
    font-size: 26px;
  }

  .brand-mark {
    width: 50px;
    height: 50px;
  }

  .top-actions {
    width: 100%;
    min-width: 0;
  }

  .panel-stack .mode-tabs {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 4px;
    padding: 4px;
    width: 100%;
  }

  .mode-tab {
    min-width: 0;
    padding: 0 4px;
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: 20px;
  }

  .icon-button {
    flex: 0 0 var(--control);
  }

  .quiet-button {
    display: none;
    min-width: 0;
    overflow: hidden;
  }

  .workspace {
    gap: 18px;
    padding: 18px;
    width: 100%;
  }

  .clock-card,
  .tool-panel,
  .compact-panel {
    padding: 18px;
    overflow: hidden;
  }

  .clock-card {
    min-height: auto;
  }

  .current-time {
    font-size: clamp(64px, 20vw, 104px);
    gap: 8px;
  }

  .current-time small {
    font-size: 25px;
  }

  .date-line {
    display: grid;
    gap: 3px;
    font-size: 21px;
  }

  .date-line .dot {
    display: none;
  }

  .next-alarm {
    font-size: 24px;
    overflow-wrap: anywhere;
  }

  .primary-actions {
    display: grid;
    grid-template-columns: 1fr;
  }

  .panel-heading {
    align-items: flex-start;
  }

  .side-rail {
    grid-template-columns: 1fr;
  }

  .timeline {
    grid-template-columns: 1fr;
  }

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

  .time-pill {
    width: 100%;
    min-width: 0;
  }

  .row-actions {
    width: 100%;
  }

  .row-actions button {
    flex: 1;
  }

  .ringing-actions {
    grid-template-columns: 1fr;
  }

  .site-footer {
    display: grid;
  }
}

@media (max-width: 420px) {
  .topbar {
    padding: 16px 18px;
  }

  .mode-tab {
    font-size: 17px;
  }

  .current-time {
    font-size: clamp(58px, 18vw, 82px);
  }

  .current-time small {
    font-size: 22px;
  }

  .date-line {
    font-size: 19px;
  }

  .next-alarm {
    font-size: 22px;
  }

  .primary-actions,
  .sheet-actions {
    display: grid;
  }

  .primary-button,
  .secondary-button,
  .small-button {
    width: 100%;
  }

  .time-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 600px) {
  .topbar {
    grid-template-columns: 1fr;
  }

  .top-actions {
    display: none;
  }

  .quiet-button {
    display: none;
  }

  .time-grid {
    grid-template-columns: 1fr;
  }

  input,
  select,
  textarea {
    min-width: 0;
  }
}
