/* Metis: the miPortal look (the same style as Keep). Light theme only. */

:root {
  --bg: #FAFAFA;
  --surface: #FFFFFF;
  --text: #1B1B1B;
  --muted: #6B6B6B;
  --border: #E8E8E8;
  --divider: #F0F0F0;
  --primary: #1B3A4B;
  --primary-soft: #EBF0F3;
  --accent: #C6975B;
  --accent-soft: #FBF6EF;
  --danger: #C0392B; /* only as a fill behind white text */

  --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --size-body: 14px;
  --size-label: 12px;
  --size-title: 18px;

  --radius: 8px;
  --topbar-height: 56px;
  --tabbar-height: 56px;
  --content-width: 672px;
  --gutter: 16px;
  --tap: 44px;

  --safe-top: env(safe-area-inset-top, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --side-left: max(var(--gutter), calc(var(--safe-left) + var(--gutter)));
  --side-right: max(var(--gutter), calc(var(--safe-right) + var(--gutter)));

  color-scheme: light;
}

*, *::before, *::after { box-sizing: border-box; }

html {
  background: var(--bg);
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: var(--size-body);
  line-height: 1.4;
  -webkit-tap-highlight-color: transparent;
}

h1, h2, h3, p { margin: 0; }

button, input, select, textarea { font: inherit; color: inherit; }

button { cursor: pointer; }

a { color: inherit; }

:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

.icon { display: block; flex: none; }

/* Top bar: 56 px, white, clear of the notch. */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  padding-top: var(--safe-top);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.topbar-inner {
  display: flex;
  align-items: center;
  gap: 8px;
  height: var(--topbar-height);
  max-width: var(--content-width);
  margin: 0 auto;
  padding: 0 var(--side-right) 0 var(--side-left);
}

.topbar-title {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  font-size: var(--size-title);
  font-weight: 600;
  white-space: nowrap;
  text-overflow: ellipsis;
}

/* Home icon (left) and text actions such as Edit (right) in the top bar. */
.topbar-home {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: var(--tap);
  height: var(--tap);
  margin-left: -10px;
  border-radius: var(--radius);
  color: var(--text);
  text-decoration: none;
}

.topbar-action {
  min-height: var(--tap);
  margin-right: -8px;
  padding: 0 8px;
  border: 0;
  border-radius: var(--radius);
  background: none;
  color: var(--text);
  font-weight: 600;
}

/* Page container: up to 672 px wide with 16 px sides, clear of the tab bar and the home bar. */
.page {
  max-width: var(--content-width);
  margin: 0 auto;
  padding: 24px var(--side-right) calc(24px + var(--tabbar-height) + var(--safe-bottom)) var(--side-left);
}

/* Bottom tab bar: the five tools, the current one in the primary colour, clear of the home bar. */
.tabbar {
  position: fixed;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 20;
  padding: 0 var(--safe-right) var(--safe-bottom) var(--safe-left);
  background: var(--surface);
  border-top: 1px solid var(--border);
}

.tabbar-inner {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  max-width: var(--content-width);
  margin: 0 auto;
}

.tab {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-width: 0;
  height: var(--tabbar-height);
  color: var(--muted);
  font-size: var(--size-label);
  text-decoration: none;
}

.tab-label {
  max-width: 100%;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.tab.is-current {
  color: var(--primary);
  font-weight: 600;
}

/* Shared building blocks. */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: none;
}

.section-label {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: var(--size-label);
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.muted { color: var(--muted); }

.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: var(--tap);
  min-height: var(--tap);
  padding: 0;
  border: 0;
  border-radius: var(--radius);
  background: none;
  color: var(--text);
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* Home */
.greeting { margin-bottom: 24px; padding: 0 2px; }

.greeting-date {
  font-size: 22px;
  font-weight: 600;
  line-height: 1.3;
}

.greeting-sub {
  margin-top: 2px;
  color: var(--muted);
}

/* Home tiles: 2 per row on a phone, 3 on a wide window. */
.tiles {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

@media (min-width: 600px) {
  .tiles { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

.tile {
  display: flex;
  flex-direction: column;
  min-width: 0;
  padding: 16px;
  color: var(--text);
  text-decoration: none;
}

.tile-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  margin-bottom: 20px;
  border-radius: var(--radius);
  background: var(--primary-soft);
  color: var(--primary);
}

.tile-name { font-weight: 600; }

.tile-description {
  display: -webkit-box;
  margin-top: 4px;
  overflow: hidden;
  color: var(--muted);
  font-size: var(--size-label);
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

/* Placeholder for a tool that is still to come. */
.placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 32px 16px;
  color: var(--muted);
  text-align: center;
}

.placeholder .tile-icon { margin-bottom: 12px; }

/* Units */
.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
}

.chip {
  min-height: var(--tap);
  padding: 0 16px;
  border: 1px solid var(--border);
  border-radius: 22px;
  background: var(--surface);
  color: var(--text);
}

.chip[aria-pressed="true"] {
  border-color: var(--primary);
  background: var(--primary);
  color: #FFFFFF;
  font-weight: 600;
}

.converter { padding: 16px; }

.field-label {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: var(--size-label);
  font-weight: 600;
}

.converter-row {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr);
  gap: 8px;
}

.field {
  display: flex;
  align-items: center;
  width: 100%;
  min-width: 0;
  height: 52px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

.field:focus { border-color: var(--primary); outline: none; }

.field-value {
  font-size: 20px;
  font-weight: 500;
}

.field-result {
  overflow: hidden;
  background: var(--bg);
  white-space: nowrap;
  text-overflow: ellipsis;
}

.field-unit {
  padding-right: 32px;
  appearance: none;
  -webkit-appearance: none;
  background: var(--surface) no-repeat right 12px center / 16px
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%236B6B6B' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
}

/* The unit picker's own text is hidden; a label on top shows the unit and may wrap to two
   lines, so long names keep their abbreviation on a phone. */
.unit-picker {
  position: relative;
  min-width: 0;
}

.unit-picker .field-unit { color: transparent; }

.unit-picker .field-unit option { color: var(--text); }

.unit-picker-label {
  position: absolute;
  inset: 1px 32px 1px 13px;
  display: flex;
  align-items: center;
  overflow: hidden;
  line-height: 1.2;
  overflow-wrap: anywhere;
  pointer-events: none;
}

.unit-picker-text { min-width: 0; }

.unit-short { white-space: nowrap; }

.converter-swap {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 8px 0;
}

.converter-swap::before,
.converter-swap::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--divider);
}

.swap-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: var(--tap);
  height: var(--tap);
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: var(--surface);
  color: var(--primary);
}

.units-summary {
  margin-top: 24px;
  text-align: center;
}

.units-equation {
  font-size: var(--size-title);
  font-weight: 600;
}

.units-rate {
  margin-top: 2px;
  color: var(--muted);
  font-size: var(--size-label);
}

/* Currency: rate status, amount card, the saved list and the Add currency sheet. */
[hidden] { display: none !important; }

.cur-status {
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: 20px;
  margin: -8px 0 12px;
  color: var(--muted);
  font-size: var(--size-label);
}

/* Offline or unavailable: highlighted in bronze, never the error colour. */
.cur-status.is-offline {
  padding: 10px 12px;
  border: 1px solid var(--accent);
  border-left-width: 4px;
  border-radius: var(--radius);
  background: var(--accent-soft);
  color: var(--text);
  font-weight: 600;
}

.cur-avatar {
  display: inline-flex;
  flex: none;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--primary-soft);
  color: var(--primary);
  font-size: 13px;
  font-weight: 600;
}

.cur-amount {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
}

.cur-amount:focus-within { border-color: var(--primary); }

.cur-amount-input {
  flex: 1;
  min-width: 0;
  height: 44px;
  padding: 0;
  border: 0;
  background: none;
  font-size: 28px;
  font-weight: 600;
  outline: none;
}

.cur-amount-code { font-size: 16px; font-weight: 600; }

.cur-hint {
  margin: 8px 2px 0;
  color: var(--muted);
  font-size: var(--size-label);
}

.cur-list-head {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin: 24px 2px 0;
}

.cur-list-base { text-transform: none; letter-spacing: 0; }

.cur-list {
  margin: 0;
  padding: 0;
  overflow: hidden;
  list-style: none;
}

.cur-row {
  display: flex;
  align-items: center;
  border-top: 1px solid var(--divider);
}

.cur-row:first-child { border-top: 0; }

.cur-row.is-source {
  box-shadow: inset 3px 0 0 var(--accent);
  background: var(--accent-soft);
}

.cur-row-main {
  display: flex;
  flex: 1;
  align-items: center;
  gap: 12px;
  min-width: 0;
  min-height: 60px;
  padding: 10px 16px;
  border: 0;
  background: none;
  text-align: left;
}

.cur-row-text {
  display: flex;
  flex: 1;
  flex-direction: column;
  min-width: 0;
}

.cur-row-code { font-weight: 600; }

.cur-tag {
  margin-left: 4px;
  color: var(--accent);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.cur-row-detail {
  overflow: hidden;
  color: var(--muted);
  font-size: var(--size-label);
  white-space: nowrap;
  text-overflow: ellipsis;
}

.cur-row-value {
  flex: none;
  font-size: 18px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.cur-remove {
  flex: none;
  width: var(--tap);
  height: var(--tap);
  margin-left: 8px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: none;
  color: var(--primary);
  font-size: 22px;
  font-weight: 600;
}

.cur-empty { margin-top: 8px; padding: 0 2px; }

.cur-add {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  min-height: 48px;
  margin-top: 12px;
  border: 1px dashed #CFCFCF;
  border-radius: var(--radius);
  background: none;
  color: var(--primary);
  font-weight: 600;
}

/* Bottom sheet: slides up over the page, up to the content width. */
.sheet {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.sheet-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(27, 27, 27, 0.35);
}

.sheet-panel {
  position: relative;
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: var(--content-width);
  max-height: 80vh;
  padding: 8px var(--side-right) calc(16px + var(--safe-bottom)) var(--side-left);
  border-radius: 16px 16px 0 0;
  background: var(--surface);
}

.sheet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.sheet-title { font-size: 16px; font-weight: 600; }

.sheet-search { flex: none; height: 44px; font-size: 16px; }

.sheet-results {
  margin-top: 8px;
  overflow-y: auto;
}

.sheet-item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 52px;
  padding: 4px 4px;
  border: 0;
  border-bottom: 1px solid var(--divider);
  background: none;
  text-align: left;
}

.sheet-item-code { flex: none; width: 40px; font-weight: 600; }

.sheet-item-name {
  min-width: 0;
  overflow: hidden;
  color: var(--muted);
  white-space: nowrap;
  text-overflow: ellipsis;
}

.sheet-empty { padding: 16px 4px; }

/* Weather: a card per city, its detail with the 7-day forecast, and the Add city results. */
.wx-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.wx-item {
  display: flex;
  align-items: center;
}

.wx-item .cur-remove { margin-right: -8px; }

.wx-item .wx-retry { margin-right: 16px; }

.wx-card {
  display: flex;
  flex: 1;
  align-items: center;
  gap: 16px;
  min-width: 0;
  min-height: 88px;
  padding: 12px 16px;
  border: 0;
  border-radius: var(--radius);
  background: none;
  color: var(--text);
  text-align: left;
}

.wx-card > .icon { color: var(--muted); }

.wx-icon {
  display: inline-flex;
  flex: none;
  color: var(--primary);
}

.wx-icon.is-sun { color: var(--accent); }
.wx-icon.is-loading, .wx-icon.is-error { color: var(--muted); }

.wx-text {
  display: flex;
  flex: 1;
  flex-direction: column;
  min-width: 0;
}

.wx-name { font-weight: 600; }

.wx-line {
  overflow: hidden;
  color: var(--muted);
  font-size: var(--size-label);
  white-space: nowrap;
  text-overflow: ellipsis;
}

/* The error wraps rather than ending in an ellipsis next to the Retry button on a narrow screen. */
.wx-error { color: var(--text); font-weight: 600; white-space: normal; }

.wx-temp {
  flex: none;
  font-size: 32px;
  font-weight: 300;
  font-variant-numeric: tabular-nums;
}

.wx-retry {
  flex: none;
  min-width: 72px;
  min-height: var(--tap);
  padding: 0 16px;
  border: 1px solid var(--primary);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--primary);
  font-weight: 600;
}

.wx-back {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-height: var(--tap);
  margin: -12px 0 8px -8px;
  padding: 0 12px 0 4px;
  border: 0;
  border-radius: var(--radius);
  background: none;
  color: var(--primary);
  font-weight: 600;
}

.wx-hero { padding: 16px; }

.wx-hero .wx-retry { margin-top: 12px; }

.wx-detail-name { font-size: var(--size-title); font-weight: 600; }

.wx-detail-sub { font-size: var(--size-label); }

.wx-hero-main {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-top: 12px;
}

.wx-hero-temp {
  font-size: 48px;
  font-weight: 300;
  line-height: 1.1;
}

.wx-hero-cond { margin-top: 4px; color: var(--muted); }

.wx-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin: 12px 0 0;
}

.wx-stats div {
  padding: 12px 16px;
  border-left: 1px solid var(--divider);
}

.wx-stats div:first-child { border-left: 0; }

.wx-stats dt {
  color: var(--muted);
  font-size: var(--size-label);
}

.wx-stats dd {
  margin: 2px 0 0;
  font-size: 16px;
  font-weight: 600;
  white-space: nowrap;
}

.wx-days-label { margin: 24px 2px 8px; }

.wx-days {
  margin: 0;
  padding: 0;
  list-style: none;
}

.wx-day {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 52px;
  padding: 4px 16px;
  border-top: 1px solid var(--divider);
}

.wx-day:first-child { border-top: 0; }

.wx-day-name { flex: none; width: 48px; font-weight: 600; }

.wx-day-cond {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  color: var(--muted);
  white-space: nowrap;
  text-overflow: ellipsis;
}

.wx-day-temps {
  display: flex;
  flex: none;
  gap: 8px;
  font-variant-numeric: tabular-nums;
}

.wx-result { justify-content: space-between; }

.wx-result-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.wx-result-name { font-weight: 600; }

.wx-result.is-saved .wx-result-text { opacity: 0.6; }

/* Time: section tabs, the world clock, the timer and the ring-only-while-open notes. */
.topbar-plus { margin-right: -10px; }

.segments {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 2px;
  margin-bottom: 20px;
  padding: 3px;
  border-radius: var(--radius);
  background: #EFEFEF;
}

.segment {
  min-width: 0;
  min-height: var(--tap);
  padding: 0 8px;
  border: 0;
  border-radius: 6px;
  background: none;
  color: var(--muted);
  font-weight: 600;
  white-space: nowrap;
}

.segment[aria-selected="true"] {
  background: var(--surface);
  box-shadow: 0 1px 2px rgba(27, 27, 27, 0.08);
  color: var(--text);
}

.tc-own {
  padding: 20px 16px;
  text-align: center;
}

.tc-own-label {
  color: var(--muted);
  font-size: var(--size-label);
  font-weight: 600;
}

.tc-own-time {
  margin-top: 2px;
  font-size: 48px;
  font-weight: 300;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}

.tc-own-date { color: var(--muted); }

.tc-list {
  margin: 16px 0 0;
  padding: 0;
  overflow: hidden;
  list-style: none;
}

.tc-row {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 60px;
  padding: 8px 16px;
  border-top: 1px solid var(--divider);
}

.tc-row:first-child { border-top: 0; }

.tc-row .cur-remove { margin: 0 -8px 0 -12px; }

.tc-row-grid {
  display: grid;
  flex: 1;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  column-gap: 12px;
  min-width: 0;
}

.tc-row-name { grid-area: 1 / 1; }

.tc-row-line { grid-area: 2 / 1; }

.tc-row-time { grid-area: 1 / 2 / 3 / 3; }

.tc-row-name {
  overflow: hidden;
  font-weight: 600;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.tc-row-line {
  color: var(--muted);
  font-size: var(--size-label);
  white-space: nowrap;
}

.tc-diff {
  margin-left: 2px;
  padding: 1px 5px;
  border-radius: 4px;
  background: var(--divider);
  color: var(--text);
  font-size: 11px;
  font-weight: 600;
}

.tc-row-time {
  flex: none;
  font-size: 28px;
  font-weight: 300;
  font-variant-numeric: tabular-nums;
}

#tc-empty { margin-top: 16px; }

.tc-note {
  margin: 12px 2px 0;
  color: var(--muted);
  font-size: var(--size-label);
  text-align: center;
}

.tm-setup, .tm-run { padding: 16px; }

.tm-steppers {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.tm-stepper {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.tm-step {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: var(--tap);
  height: var(--tap);
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: var(--surface);
  color: var(--primary);
}

.tm-value {
  font-size: 40px;
  font-weight: 300;
  line-height: 1.2;
  font-variant-numeric: tabular-nums;
}

.tm-unit {
  color: var(--muted);
  font-size: var(--size-label);
}

.tm-presets {
  justify-content: center;
  margin: 20px 0 16px;
}

.tm-primary, .tm-secondary {
  min-height: 48px;
  padding: 0 24px;
  border: 1px solid var(--primary);
  border-radius: var(--radius);
  font-weight: 600;
}

.tm-primary {
  width: 100%;
  background: var(--primary);
  color: #FFFFFF;
}

.tm-primary:disabled { opacity: 0.4; cursor: default; }

.tm-secondary {
  background: var(--surface);
  color: var(--primary);
}

.tm-ring {
  position: relative;
  width: min(240px, 100%);
  margin: 0 auto;
}

.tm-ring svg { display: block; width: 100%; height: auto; }

.tm-ring circle { fill: none; stroke-width: 8; }

.tm-ring-track { stroke: var(--divider); }

.tm-ring-bar {
  stroke: var(--accent);
  stroke-linecap: round;
  transition: stroke-dashoffset 0.25s linear;
}

.tm-run.is-paused .tm-ring-bar { stroke: var(--muted); }

.tm-ring-text {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
}

.tm-left {
  font-size: 44px;
  font-weight: 300;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}

.tm-run.is-ringing .tm-left {
  color: var(--primary);
  font-size: 32px;
  font-weight: 600;
}

.tm-ends {
  margin-top: 4px;
  color: var(--muted);
}

.tm-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 20px;
}

.tm-actions .tm-stop { grid-column: span 2; }

/* Alarms: the list with on/off switches, the Add alarm sheet and the ringing layer. */
.al-list {
  margin: 0;
  padding: 0;
  overflow: hidden;
  list-style: none;
}

.al-row {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 72px;
  padding: 8px 16px;
  border-top: 1px solid var(--divider);
}

.al-row:first-child { border-top: 0; }

.al-row .cur-remove { margin: 0 -8px 0 -12px; }

.al-text {
  display: flex;
  flex: 1;
  flex-direction: column;
  min-width: 0;
}

.al-time {
  font-size: 32px;
  font-weight: 300;
  line-height: 1.15;
  font-variant-numeric: tabular-nums;
}

.al-line {
  overflow: hidden;
  color: var(--muted);
  font-size: var(--size-label);
  white-space: nowrap;
  text-overflow: ellipsis;
}

.al-row.is-off .al-time { color: var(--muted); }

.al-switch {
  position: relative;
  flex: none;
  width: 52px;
  height: var(--tap);
  padding: 0;
  border: 0;
  background: none;
}

.al-switch::before {
  content: "";
  position: absolute;
  top: 6px;
  left: 0;
  width: 52px;
  height: 32px;
  border-radius: 16px;
  background: #DADADA;
  transition: background 0.15s;
}

.al-switch[aria-checked="true"]::before { background: var(--primary); }

.al-knob {
  position: absolute;
  top: 8px;
  left: 2px;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: #FFFFFF;
  box-shadow: 0 1px 2px rgba(27, 27, 27, 0.2);
  transition: transform 0.15s;
}

.al-switch[aria-checked="true"] .al-knob { transform: translateX(20px); }

#al-empty { margin-top: 0; }

.al-form { gap: 0; overflow-y: auto; }

.al-form .field { flex: none; margin-bottom: 16px; font-size: 16px; }

.al-days {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 6px;
}

.al-day {
  min-width: 0;
  min-height: var(--tap);
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 22px;
  background: var(--surface);
  color: var(--text);
  font-size: var(--size-label);
}

.al-day[aria-pressed="true"] {
  border-color: var(--primary);
  background: var(--primary);
  color: #FFFFFF;
  font-weight: 600;
}

.al-repeat {
  margin: 8px 2px 16px;
  font-size: var(--size-label);
}

.alarm-ring {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: calc(16px + var(--safe-top)) var(--side-right) calc(16px + var(--safe-bottom)) var(--side-left);
  background: rgba(27, 27, 27, 0.55);
}

.alarm-ring-panel {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  max-width: 360px;
  padding: 24px 16px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  text-align: center;
}

.alarm-ring-icon { color: var(--accent); }

.alarm-ring-icon .icon { width: 40px; height: 40px; }

.alarm-ring-kicker {
  margin-top: 8px;
  color: var(--muted);
  font-size: var(--size-label);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.alarm-ring-time {
  font-size: 56px;
  font-weight: 300;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}

.alarm-ring-label {
  max-width: 100%;
  margin-bottom: 20px;
  overflow-wrap: anywhere;
  font-size: 16px;
  font-weight: 600;
}

/* Calculator: display, memory slots, memory keys and keypad. The keys take the height that is
   left between the top bar and the tab bar: from 44 px on a short screen up to 64 px. */
.calc-page {
  padding-top: var(--calc-space);
  padding-bottom: calc(var(--calc-space) + var(--tabbar-height) + var(--safe-bottom));
}

.calc-page, .calc {
  --calc-space: 16px;
  --calc-gap: 8px;
  --display-height: 116px;
  --slot-height: 60px;
  --result-size: 44;
}

.calc {
  --chrome: calc(var(--topbar-height) + var(--tabbar-height) + var(--safe-top) + var(--safe-bottom) + 2 * var(--calc-space));
  --free: calc(100vh - var(--chrome) - var(--display-height) - var(--slot-height) - var(--tap) - 8 * var(--calc-gap));
  --key-height: clamp(var(--tap), calc(var(--free) / 6), 64px);
  display: flex;
  flex-direction: column;
  gap: var(--calc-gap);
  max-width: 420px;
  margin: 0 auto;
}

@supports (height: 100dvh) {
  .calc { --free: calc(100dvh - var(--chrome) - var(--display-height) - var(--slot-height) - var(--tap) - 8 * var(--calc-gap)); }
}

@media (max-height: 740px) {
  .calc-page, .calc {
    --calc-space: 8px;
    --calc-gap: 6px;
    --display-height: 92px;
    --slot-height: 48px;
    --result-size: 34;
  }
}

.calc-display {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  height: var(--display-height);
  padding: 8px 16px;
  overflow: hidden;
}

.calc-tags {
  position: absolute;
  top: 8px;
  left: 12px;
  display: flex;
  gap: 4px;
}

.calc-tag {
  padding: 0 4px;
  border: 1px solid var(--accent);
  border-radius: 4px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 11px;
  line-height: 15px;
}

/* One line each; a long line keeps its end in view. */
.calc-expression, .calc-result {
  display: flex;
  justify-content: flex-end;
  overflow: hidden;
  white-space: nowrap;
}

.calc-expression {
  min-height: 22px;
  color: var(--muted);
  font-size: 16px;
}

.calc-result {
  min-height: calc(var(--result-size) * 1.2px);
  align-items: center;
  font-size: calc(var(--result-size) * 1px);
  font-weight: 300;
  line-height: 1.2;
}

.calc-result.is-error { font-weight: 400; }

.calc-slots {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.calc-slot {
  display: flex;
  min-width: 0;
  min-height: var(--slot-height);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  cursor: pointer;
  transition: background-color 0.3s;
}

.calc-slot.is-selected {
  border-color: var(--primary);
  background: var(--primary-soft);
}

.calc-slot.is-flash { background: var(--accent-soft); }

.calc-slot-select {
  display: flex;
  flex: 1;
  flex-direction: column;
  justify-content: center;
  min-width: 0;
  min-height: var(--tap);
  padding: 4px 0 4px 10px;
  border: 0;
  border-radius: var(--radius);
  background: none;
  text-align: left;
}

.calc-slot-name {
  font-size: var(--size-label);
  font-weight: 600;
}

.calc-slot-value {
  max-width: 100%;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.calc-slot-value.is-empty { color: var(--muted); }

.calc-slot-clear {
  display: flex;
  flex: none;
  align-items: flex-start;
  justify-content: flex-end;
  width: var(--tap);
  height: var(--tap);
  padding: 8px 8px 0 0;
  border: 0;
  border-radius: var(--radius);
  background: none;
  color: var(--muted);
}

.calc-memkeys {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
}

.calc-mkey {
  min-width: 0;
  height: var(--tap);
  padding: 0 4px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--primary);
  font-weight: 600;
}

.calc-mkey-clear { font-size: var(--size-label); }

.calc-mkey:disabled {
  color: #B5B5B5;
  cursor: default;
}

.calc-keys {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: var(--calc-gap);
}

.key {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
  height: var(--key-height);
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font-size: 22px;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
}

.key sup {
  margin-left: 1px;
  font-size: 0.7em;
  line-height: 0;
  vertical-align: 0.7em;
}

.key-fn {
  background: var(--divider);
  font-size: 16px;
  font-weight: 600;
}

.key-op {
  background: var(--primary-soft);
  color: var(--primary);
}

.key-eq {
  border-color: var(--primary);
  background: var(--primary);
  color: #FFFFFF;
}

.key-zero { grid-column: span 2; }

.key:active, .key.is-active, .calc-mkey:enabled:active { filter: brightness(0.92); }
