﻿:root {
  color-scheme: light;
  --bg: #edf5ff;
  --ink: #10345f;
  --muted: #5c718f;
  --panel: #ffffff;
  --line: #c7dbf7;
  --accent: #1f5fbf;
  --accent-strong: #174a97;
  --warning: #d54d41;
  --warning-bg: #ffe7e1;
  --blue: #2e7be7;
  --yellow: #f4c94a;
  --shadow: 0 18px 55px rgba(24, 64, 122, 0.16);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  background:
    radial-gradient(circle at top left, rgba(31, 95, 191, 0.22), transparent 32rem),
    radial-gradient(circle at right top, rgba(46, 123, 231, 0.16), transparent 24rem),
    linear-gradient(135deg, #edf5ff 0%, #e7f0ff 48%, #f8fbff 100%);
  color: var(--ink);
}

button,
input {
  font: inherit;
}

button {
  min-height: 48px;
  border: 0;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font-weight: 750;
  cursor: pointer;
  transition:
    transform 150ms ease,
    background 150ms ease,
    opacity 150ms ease;
}

button:hover {
  transform: translateY(-1px);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.5;
  transform: none;
}

input {
  width: 100%;
  min-height: 48px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 14px;
  background: #fff;
  color: var(--ink);
}

label {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 0.92rem;
  font-weight: 700;
}

.hidden {
  display: none !important;
}

.app-shell {
  width: min(100%, 480px);
  min-height: 100vh;
  margin: 0 auto;
  padding: max(12px, env(safe-area-inset-top)) 10px calc(92px + env(safe-area-inset-bottom));
  display: grid;
  align-items: center;
}

.login-view,
.dashboard {
  width: 100%;
}

.login-view {
  display: grid;
  gap: 18px;
  padding: 26px;
  border: 1px solid rgba(199, 219, 247, 0.95);
  border-radius: 8px;
  background: linear-gradient(180deg, rgba(255,255,255,0.94), rgba(241,248,255,0.96));
  box-shadow: var(--shadow);
}

.brand-mark {
  width: 62px;
  height: 62px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: linear-gradient(135deg, #d8ebff, #edf6ff);
  font-size: 2rem;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: clamp(2rem, 8vw, 4.2rem);
  line-height: 0.96;
  letter-spacing: 0;
}

h2 {
  font-size: 1.25rem;
}

.muted,
.first-start,
.status-line {
  color: var(--muted);
}

.code-form,
.dialog-form {
  display: grid;
  gap: 12px;
}

.error {
  min-height: 1.3em;
  color: var(--warning);
  font-weight: 700;
}

.first-start {
  border-top: 1px solid var(--line);
  padding-top: 14px;
}

.first-start summary {
  cursor: pointer;
  font-weight: 750;
  color: var(--ink);
}

.dashboard {
  align-self: start;
  display: grid;
  gap: 12px;
  padding-bottom: 78px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
  padding-top: 4px;
}

.topbar h1 {
  font-size: clamp(2rem, 12vw, 3.2rem);
}

.header-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.app-version {
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
}

.eyebrow {
  margin-bottom: 4px;
  color: var(--accent-strong);
  font-weight: 850;
  text-transform: uppercase;
  font-size: 0.78rem;
  letter-spacing: 0.08em;
}

.ghost,
.secondary {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
}

.danger {
  background: var(--warning);
}

.timer-panel,
.settings-panel,
.alarm-panel,
.logs-panel {
  display: grid;
  gap: 12px;
  padding: 12px;
  border: 1px solid rgba(199, 219, 247, 0.95);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 10px 34px rgba(20, 48, 42, 0.08);
}

.action-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.mode-button {
  min-height: 86px;
  display: grid;
  gap: 4px;
  align-content: center;
  padding: 12px;
  background: linear-gradient(180deg, #2f7ef0, #1f5fbf);
  text-align: left;
}

.mode-button span {
  font-size: 1.55rem;
  line-height: 1;
}

.mode-button small {
  color: rgba(255, 255, 255, 0.82);
  font-weight: 650;
}

.timer-face {
  min-height: 230px;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 10px;
  border-radius: 8px;
  background: #10231f;
  color: #fff;
  text-align: center;
}

.timer-face.expired {
  background: #681d14;
  animation: pulse 1.2s ease-in-out infinite;
}

.timer-face p,
.timer-face span {
  color: rgba(255, 255, 255, 0.72);
  font-weight: 700;
}

.timer-face strong {
  font-variant-numeric: tabular-nums;
  font-size: clamp(4.8rem, 24vw, 9rem);
  line-height: 0.9;
  letter-spacing: 0;
}

.timer-face .stop-inline {
  width: min(100%, 280px);
  margin-top: 8px;
  background: #e45542;
}

.prelimit-panel {
  display: grid;
  gap: 4px;
  padding: 12px;
  border: 1px solid #ecd183;
  border-radius: 8px;
  background: #fff6d8;
}

.prelimit-panel strong {
  color: #8a5b00;
  font-size: 1.1rem;
}

.prelimit-panel span {
  color: #6d5b28;
  font-weight: 700;
}

.limit-visual {
  display: grid;
  gap: 8px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.limit-visual-head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
}

.limit-visual-head strong,
.limit-visual-head span {
  font-weight: 850;
}

.limit-visual-head span {
  color: var(--accent-strong);
  font-variant-numeric: tabular-nums;
}

.limit-track {
  height: 18px;
  overflow: hidden;
  border-radius: 999px;
  background: #dfe8e3;
}

.limit-fill {
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent), var(--yellow));
  transition: width 240ms ease;
}

.limit-visual p {
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 700;
}

.limit-visual.over-limit {
  border-color: #ffc0b5;
  background: var(--warning-bg);
}

.limit-visual.over-limit .limit-fill {
  background: var(--warning);
}

.limit-visual.over-limit .limit-visual-head span {
  color: var(--warning);
}

.quick-actions {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.bottom-tabs {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 30;
  display: flex;
  gap: 6px;
  padding: 8px max(10px, env(safe-area-inset-right)) calc(10px + env(safe-area-inset-bottom)) max(10px, env(safe-area-inset-left));
  background: rgba(237, 245, 255, 0.96);
  backdrop-filter: blur(14px);
  border-top: 1px solid var(--line);
}

.tab-button {
  flex: 1;
  min-height: 44px;
  padding: 0 8px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
}

.tab-button.active {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}

.tab-button,
.ghost {
  position: relative;
}

.app-view {
  display: grid;
  gap: 16px;
}

.stats-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}

.stats-grid--weekly {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.logs-chart {
  display: grid;
  gap: 10px;
}

.day-bar {
  display: grid;
  gap: 6px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.day-bar__head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  font-weight: 800;
}

.day-bar__track {
  height: 10px;
  overflow: hidden;
  border-radius: 999px;
  background: #dbe9fb;
}

.day-bar__fill {
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #2f7ef0, #7bb8ff);
}


.stats-grid--weekly {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.logs-chart {
  display: grid;
  gap: 10px;
}

.day-bar {
  display: grid;
  gap: 6px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.day-bar__head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  font-weight: 800;
}

.day-bar__track {
  height: 10px;
  overflow: hidden;
  border-radius: 999px;
  background: #dbe9fb;
}

.day-bar__fill {
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #2f7ef0, #7bb8ff);
}


.stat-card {
  min-height: 88px;
  display: grid;
  gap: 6px;
  align-content: center;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8faf7;
}

.stat-card span {
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 700;
}

.stat-card strong {
  font-size: clamp(1.4rem, 6vw, 2rem);
  font-variant-numeric: tabular-nums;
  line-height: 1;
}

.status-line {
  min-height: 1.4em;
  font-weight: 650;
}

.alarm-panel {
  background: var(--warning-bg);
  border-color: #ffc0b5;
}

.alarm-panel strong {
  color: var(--warning);
  font-size: 1.2rem;
}

.section-title {
  display: grid;
  gap: 4px;
}

.section-title p {
  color: var(--muted);
}

.settings-form {
  display: grid;
  gap: 16px;
}

.bulk-limit-actions {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}

.compact-note {
  margin-top: -2px;
  color: var(--muted);
  font-size: 0.86rem;
  line-height: 1.35;
}

.family-panel {
  display: grid;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f7fbff;
}

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

.family-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.family-panel {
  display: grid;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f7fbff;
}

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

.family-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

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

.settings-grid button {
  align-self: end;
}

.weekly-limits {
  display: grid;
  gap: 8px;
}

.day-row {
  display: grid;
  grid-template-columns: 42px repeat(2, minmax(0, 1fr));
  gap: 10px;
  align-items: center;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.limit-stepper {
  display: grid;
  gap: 6px;
}

.limit-stepper > span {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
}

.limit-stepper > div {
  display: grid;
  grid-template-columns: 42px minmax(54px, 1fr) 42px;
  gap: 6px;
  align-items: center;
}

.limit-stepper button {
  min-height: 42px;
  padding: 0;
  font-size: 1.35rem;
}

.limit-stepper output {
  min-height: 42px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8faf7;
  font-weight: 850;
  font-variant-numeric: tabular-nums;
}

.day-row strong {
  align-self: center;
  font-size: 1.05rem;
}

.logs-list {
  display: grid;
  gap: 14px;
}

.log-day {
  display: grid;
  gap: 8px;
}

.log-day h3 {
  margin: 0;
  color: var(--accent-strong);
  font-size: 0.95rem;
  text-transform: capitalize;
}

.log-item {
  display: grid;
  gap: 8px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.log-row {
  display: grid;
  grid-template-columns: minmax(86px, 1fr) auto auto;
  gap: 8px;
  align-items: baseline;
}

.log-row span,
.log-row small {
  color: var(--muted);
  font-weight: 750;
}

.log-edit {
  display: grid;
  gap: 7px;
}

.log-note,
.empty-state {
  color: var(--muted);
}

.log-note {
  font-size: 0.84rem;
  font-weight: 750;
}

.log-edit {
  grid-template-columns: 1fr auto;
  align-items: end;
  margin-top: 8px;
}

.log-edit button {
  min-width: 0;
  padding: 0 12px;
}

.log-edit-wrap summary {
  color: var(--accent-strong);
  cursor: pointer;
  font-weight: 800;
  font-size: 0.9rem;
}

.audit-list {
  display: grid;
  gap: 8px;
}

.audit-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  overflow: hidden;
}

.audit-item summary {
  list-style: none;
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 12px;
  cursor: pointer;
  font-weight: 800;
}

.audit-item summary::-webkit-details-marker {
  display: none;
}

.audit-item span {
  color: var(--muted);
  font-weight: 700;
}

.audit-item__body {
  padding: 0 12px 12px;
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.4;
}

@media (max-width: 420px) {
  .header-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .header-actions .ghost {
    min-height: 40px;
    padding-inline: 10px;
  }
}

dialog {
  width: min(calc(100% - 28px), 420px);
  border: 0;
  border-radius: 8px;
  padding: 20px;
  color: var(--ink);
  box-shadow: var(--shadow);
}

dialog::backdrop {
  background: rgba(16, 35, 31, 0.55);
}

.dialog-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

@keyframes pulse {
  0%,
  100% {
    filter: brightness(1);
  }
  50% {
    filter: brightness(1.22);
  }
}

@media (max-width: 560px) {
  .app-shell {
    padding-inline: 12px;
  }

  .login-view,
  .timer-panel,
  .settings-panel,
  .alarm-panel {
    padding: 14px;
  }

  .topbar {
    align-items: center;
  }

  .ghost {
    min-width: 82px;
  }

  .settings-grid,
  .quick-actions,
  .mode-row,
  .stats-grid,
  .day-row,
  .log-item,
  .log-edit {
    grid-template-columns: 1fr;
  }
}

