html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  overflow-x: clip;
}

body {
  overflow-x: clip;
  -webkit-tap-highlight-color: transparent;
}

dialog {
  max-width: calc(100% - 1.4rem);
  max-height: min(92dvh, 100%);
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  box-shadow:
    0 14px 40px rgba(11, 28, 36, 0.24),
    0 2px 10px rgba(11, 28, 36, 0.1);
}

/* Dim + soft blur so popups separate from busy page graphics. */
dialog::backdrop {
  background: rgba(11, 28, 36, 0.55);
  -webkit-backdrop-filter: blur(3px) saturate(0.9);
  backdrop-filter: blur(3px) saturate(0.9);
}

@media (prefers-reduced-transparency: reduce) {
  dialog::backdrop {
    background: rgba(11, 28, 36, 0.66);
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
  }
}

.dili-app-header {
  position: sticky;
  top: 0;
  z-index: 40;
  padding-top: env(safe-area-inset-top, 0px);
  border-bottom: 1px solid var(--line);
  background: var(--bar, rgba(238, 242, 244, 0.92));
  backdrop-filter: blur(8px);
}

body.dili-shell .dili-door {
  padding-top: 1.1rem;
}

.dili-app-header-inner {
  max-width: var(--app-max, 40rem); /* 640px */
  margin: 0 auto;
  padding: 0.45rem 0.9rem 0.35rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.dili-app-header-inner > .dili-brand {
  flex: none;
  text-decoration: none;
  color: var(--ink);
}

.dili-brand { display: block; line-height: 0; }
.dili-brand .dl-logo { display: block; flex: none; width: 2rem; height: 2rem; }
.dili-brand[aria-current="page"] { opacity: 0.45; pointer-events: none; }

.dili-app-id { flex: 1 1 auto; min-width: 0; }

.dili-header-timers {
  flex: 0 1 auto;
  min-width: 0;
  max-width: 48%;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: flex-end;
  gap: 0.05rem;
}

.dili-header-timers.hidden {
  display: none;
}

.dili-header-timer {
  display: inline-flex;
  align-items: baseline;
  gap: 0.28rem;
  max-width: 100%;
  min-width: 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--ink);
  text-decoration: none;
  line-height: 1.1;
}

.dili-header-timer:hover .dili-header-timer-type,
.dili-header-timer:focus-visible .dili-header-timer-type {
  text-decoration: underline;
}

.dili-header-timer-type {
  color: var(--ink-soft);
  font-size: 0.68rem;
  font-weight: 400;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dili-header-timer-num {
  flex: none;
  font-size: 0.68rem;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.01em;
}

.dili-header-timer.is-due .dili-header-timer-num,
.dili-header-timer.is-due .dili-header-timer-type {
  color: var(--signal, #c45b2a);
  font-weight: 600;
}

.dili-header-timer.is-paused .dili-header-timer-type {
  font-style: italic;
}

.dili-header-timer.is-paused .dili-header-timer-num {
  opacity: 0.7;
}

.dili-app-title {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.45rem;
  font-weight: 400;
  line-height: 1.1;
  color: var(--ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.who {
  margin: 0.1rem 0 0;
  display: flex;
  align-items: center;
  min-width: 0;
  gap: 0.4rem;
  color: var(--ink-soft);
  font-size: 0.8rem;
  font-weight: 300;
}

.who-family {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.who-sep { flex: none; opacity: 0.6; }
#who-name {
  flex: 1 1 auto;
  min-width: 0;
  max-width: 12rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dili-char-count {
  margin: 0.2rem 0 0;
  font-size: 0.875rem;
  color: var(--muted, #334155);
  text-align: right;
}
.dili-char-count.is-warn { color: #b45309; }
.dili-char-count.is-over { color: #b91c1c; }

.dot {
  width: 0.55rem;
  height: 0.55rem;
  border-radius: 50%;
  flex-shrink: 0;
  background: var(--sea);
}

.dot.blue { background: var(--user-blue); }
.dot.red { background: var(--user-red); }
.dot.green { background: var(--user-green); }
.dot.amber { background: var(--user-amber); }
.dot.teal { background: var(--user-teal); }
.dot.plum { background: var(--user-plum); }

.icon-btn {
  width: 2.4rem;
  height: 2.4rem;
  border: 1px solid var(--line);
  border-radius: 0.35rem;
  background: var(--card);
  display: grid;
  place-content: center;
  gap: 0.25rem;
  cursor: pointer;
  flex-shrink: 0;
  padding: 0;
}

.icon-btn span {
  display: block;
  width: 1.1rem;
  height: 2px;
  background: var(--ink);
  border-radius: 1px;
}

.appbar {
  max-width: var(--app-max, 40rem);
  margin: 0 auto;
  padding: 0 0.9rem 0.55rem;
}

.dili-app-header .dili-switch {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-start;
  align-items: center;
  gap: 0.4rem;
  margin: 0;
}

.dili-app-header .dili-switch a,
.dili-app-header .dili-switch span {
  display: inline-flex;
  align-items: center;
  min-height: 2rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.28rem 0.75rem;
  text-decoration: none;
  font-size: 0.92rem;
  color: var(--ink);
  background: var(--card);
}

.dili-app-header .dili-switch .is-current {
  background: var(--sea-deep);
  color: #fff;
  border-color: transparent;
}

.dili-app-header .dili-switch .is-soon {
  opacity: 0.55;
}

.dili-app-header .dili-install {
  margin: 0.45rem 0 0;
  color: var(--ink-soft);
  font-size: 0.85rem;
  font-weight: 300;
}

@media (min-width: 800px) {
  .dili-app-header .dili-install { display: none; }
}

.menu-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(11, 28, 36, 0.25);
  z-index: 30;
}

.menu-panel {
  position: fixed;
  z-index: 60;
  width: max-content;
  min-width: 13.5rem;
  max-width: min(18rem, calc(100% - 1.8rem));
  max-height: 75dvh;
  overflow: auto;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 0.35rem;
  padding: 0.35rem;
  display: grid;
  box-shadow: 0 12px 32px rgba(11, 28, 36, 0.12);
}

.menu-label {
  margin: 0.65rem 0.55rem 0.15rem;
  padding: 0.55rem 0.35rem 0;
  border-top: 1px solid var(--line);
  color: var(--ink-soft);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.menu-panel .menu-label:first-child {
  margin-top: 0.2rem;
  padding-top: 0.15rem;
  border-top: 0;
}

.menu-panel a.menu-logout {
  margin-top: 0.35rem;
  border-top: 1px solid var(--line);
  border-radius: 0;
}

.menu-panel button,
.menu-panel a {
  appearance: none;
  border: 0;
  background: transparent;
  text-align: left;
  padding: 0.75rem 0.9rem;
  border-radius: 0.25rem;
  font: inherit;
  font-weight: 500;
  cursor: pointer;
  min-height: 2.75rem;
  color: var(--ink);
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 0.7rem;
}

.menu-ico {
  width: 1.05rem;
  height: 1.05rem;
  flex: 0 0 auto;
}

.menu-panel button:hover,
.menu-panel a:hover,
.menu-panel button:active,
.menu-panel a:active {
  background: color-mix(in srgb, var(--ink) 8%, transparent);
  color: var(--ink);
}

.menu-panel .is-on,
.menu-panel .is-on:hover,
.menu-panel .is-on:active,
.menu-panel a[aria-current="page"],
.menu-panel a[aria-current="page"]:hover,
.menu-panel a[aria-current="page"]:active {
  background: var(--sea-deep);
  color: #fff;
}

.menu-panel .menu-danger,
.menu-panel .menu-danger:hover,
.menu-panel .menu-danger:active {
  color: #8b2e2e;
}

.hidden {
  display: none !important;
}

/* Primary mobile modes — same pattern as the wine cellar. */
.modebar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 25;
  display: flex;
  padding-bottom: env(safe-area-inset-bottom, 0px);
  background: var(--bar, rgba(238, 242, 244, 0.92));
  border-top: 1px solid var(--line);
  backdrop-filter: blur(8px);
}

.modebar button,
.modebar a {
  flex: 1;
  min-height: 3.5rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.1rem;
  border: 0;
  background: transparent;
  color: var(--ink-soft);
  font: inherit;
  font-size: 0.8125rem;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.modebar button:active,
.modebar a:active {
  background: color-mix(in srgb, var(--sea, #1f5a68) 12%, transparent);
}

.modebar button.is-on,
.modebar a.is-on,
.modebar a[aria-current="page"] {
  color: var(--sea-deep, #0f3540);
  background: color-mix(in srgb, var(--sea, #1f5a68) 18%, transparent);
}

.modebar .menu-ico {
  width: 1.35rem;
  height: 1.35rem;
}

/* Mode-specific actions sit on the line above the mode tabs. */
.mode-dock {
  position: fixed;
  left: 0;
  right: 0;
  bottom: calc(3.5rem + env(safe-area-inset-bottom, 0px));
  z-index: 24;
  padding: 0.45rem 0.9rem;
  background: var(--bar, rgba(238, 242, 244, 0.92));
  border-top: 1px solid var(--line);
  backdrop-filter: blur(8px);
}

.mode-dock .add-wide {
  display: block;
  width: 100%;
  max-width: var(--app-max, 32.5rem);
  margin: 0 auto;
}

@media (min-width: 900px) {
  .modebar,
  .mode-dock {
    left: 50%;
    right: auto;
    width: min(var(--app-max, 40rem), calc(100% - 2rem));
    transform: translateX(-50%);
    border: 1px solid var(--line);
    border-bottom: 0;
  }
}
