:root {
  color-scheme: light;
  --bg: #eef1f3;
  --surface: #fbfcfd;
  --surface-strong: #ffffff;
  --ink: #1e242b;
  --muted: #64707d;
  --line: #d6dde3;
  --green: #2d8068;
  --green-dark: #1d5f4c;
  --blue: #326fa8;
  --amber: #b86f24;
  --red: #bd4a4a;
  --shadow: 0 24px 70px rgba(34, 43, 50, 0.13);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(120deg, rgba(45, 128, 104, 0.08), transparent 36%),
    linear-gradient(300deg, rgba(50, 111, 168, 0.08), transparent 42%),
    var(--bg);
  color: var(--ink);
  font-family: Inter, "Segoe UI", "Microsoft YaHei", "PingFang SC", Arial, sans-serif;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

h1,
h2,
p {
  margin: 0;
}

.app-shell {
  width: min(1240px, 100%);
  margin: 0 auto;
  padding: 22px;
}

.app-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 18px;
}

.eyebrow {
  margin-bottom: 6px;
  color: var(--green-dark);
  font-size: 13px;
  font-weight: 800;
}

h1 {
  font-size: clamp(28px, 4vw, 42px);
  line-height: 1.05;
  letter-spacing: 0;
}

h2 {
  font-size: 16px;
  letter-spacing: 0;
}

.header-stats {
  display: grid;
  grid-template-columns: repeat(3, 92px);
  gap: 10px;
}

.header-stats div,
.blink-grid div,
.summary-list div {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.78);
}

.header-stats div {
  min-height: 66px;
  padding: 10px 12px;
}

.header-stats strong,
.header-stats span,
.blink-grid strong,
.blink-grid span {
  display: block;
}

.header-stats strong,
.blink-grid strong {
  font-size: 26px;
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
}

.header-stats span,
.blink-grid span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 390px;
  gap: 18px;
  align-items: start;
}

.timer-card,
.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: color-mix(in srgb, var(--surface) 94%, transparent);
  box-shadow: var(--shadow);
}

.timer-card {
  min-height: calc(100vh - 120px);
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: clamp(18px, 3vw, 34px);
}

.timer-head,
.panel-title,
.summary-list div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.timer-head {
  margin-bottom: 18px;
}

.timer-head p,
.panel-title p {
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 750;
}

.state-pill,
.alert-tag,
.privacy-badge {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--green) 12%, var(--surface-strong));
  color: var(--green-dark);
  font-size: 13px;
  font-weight: 850;
}

select,
input {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-strong);
  color: var(--ink);
  outline: none;
}

select {
  min-width: 176px;
  padding: 0 12px;
  font-weight: 800;
}

input:focus,
select:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(45, 128, 104, 0.13);
}

.timer-face {
  position: relative;
  width: min(58vh, 390px);
  aspect-ratio: 1;
  margin: 12px auto 20px;
}

.progress-ring {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}

.track,
.progress {
  fill: none;
  stroke-width: 14;
}

.track {
  stroke: color-mix(in srgb, var(--line) 75%, white);
}

.progress {
  stroke: var(--green);
  stroke-linecap: round;
  stroke-dasharray: 703.72;
  stroke-dashoffset: 0;
  transition: stroke-dashoffset 0.35s ease, stroke 0.2s ease;
}

.time-stack {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  gap: 10px;
  text-align: center;
}

#timeValue {
  font-size: clamp(58px, 9vw, 86px);
  font-variant-numeric: tabular-nums;
  line-height: 1;
  letter-spacing: 0;
}

#timeHint {
  color: var(--muted);
  font-size: 15px;
  font-weight: 800;
}

.action-row,
.dialog-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-width: 112px;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-strong);
  color: var(--ink);
  padding: 0 14px;
  font-weight: 850;
  transition: border-color 0.15s ease, background 0.15s ease, transform 0.15s ease;
}

.button:hover:not(:disabled) {
  border-color: color-mix(in srgb, var(--line) 50%, var(--ink));
  transform: translateY(-1px);
}

.button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.button.primary {
  border-color: var(--green);
  background: var(--green);
  color: #fff;
}

.button.danger {
  color: var(--red);
}

.icon {
  display: inline-grid;
  place-items: center;
  width: 18px;
  height: 18px;
  font-size: 13px;
  line-height: 1;
}

.prompt-strip {
  display: grid;
  grid-template-columns: 48px 1fr;
  gap: 13px;
  align-items: center;
  margin-top: 20px;
  padding: 13px 15px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: color-mix(in srgb, var(--surface-strong) 76%, transparent);
}

.prompt-strip strong {
  display: block;
  margin-bottom: 4px;
}

.prompt-strip p {
  color: var(--muted);
  line-height: 1.55;
}

.mascot {
  position: relative;
  display: block;
  width: 44px;
  height: 44px;
  border-radius: 14px;
  background: linear-gradient(160deg, #82c9ae, #2d8068);
  box-shadow: inset 0 -8px 0 rgba(0, 0, 0, 0.08);
}

.mascot i {
  position: absolute;
  top: 17px;
  width: 7px;
  height: 9px;
  border-radius: 999px;
  background: #14211d;
}

.mascot i:first-child {
  left: 12px;
}

.mascot i:last-child {
  right: 12px;
}

.side-stack {
  display: grid;
  gap: 14px;
}

.panel {
  padding: 16px;
  box-shadow: none;
}

.privacy-badge {
  background: color-mix(in srgb, var(--blue) 12%, var(--surface-strong));
  color: var(--blue);
  white-space: nowrap;
}

.panel-tools {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.text-button {
  min-height: 32px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-strong);
  color: var(--blue);
  padding: 0 10px;
  font-size: 13px;
  font-weight: 850;
}

.text-button:hover {
  border-color: color-mix(in srgb, var(--blue) 55%, var(--line));
}

.camera-box {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 10;
  margin: 14px 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #202833;
}

#cameraVideo,
#overlayCanvas,
.camera-placeholder {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

#cameraVideo {
  object-fit: cover;
  transform: scaleX(-1);
}

#overlayCanvas {
  pointer-events: none;
  transform: scaleX(-1);
}

.camera-placeholder {
  display: grid;
  place-content: center;
  gap: 6px;
  padding: 20px;
  color: #eef3f7;
  text-align: center;
}

.camera-placeholder span {
  color: #b9c5cf;
  font-size: 13px;
  line-height: 1.5;
}

.camera-box.active .camera-placeholder {
  display: none;
}

.blink-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 9px;
}

.blink-grid div {
  min-height: 70px;
  padding: 11px;
}

.compact {
  margin-top: 12px;
}

.settings-grid,
.time-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 14px;
  align-items: stretch;
}

.field {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.settings-grid .field {
  grid-template-rows: 18px 44px minmax(34px, auto);
  align-content: start;
  gap: 6px;
  min-height: 112px;
}

.field > span {
  color: #526171;
  line-height: 18px;
}

.field input,
.field select {
  width: 100%;
  min-height: 44px;
  padding: 0 12px;
  color: var(--ink);
  font-weight: 850;
}

.field .button {
  width: 100%;
  min-height: 44px;
}

.field small {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  line-height: 1.45;
}

.settings-grid .field small {
  min-height: 34px;
}

.full-field {
  margin-top: 12px;
}

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

.toggle-list label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.toggle-list strong,
.toggle-list small {
  display: block;
}

.toggle-list strong {
  margin-bottom: 3px;
  font-size: 14px;
}

.toggle-list small {
  color: var(--muted);
  line-height: 1.4;
}

.toggle-list input {
  width: 42px;
  min-width: 42px;
  height: 24px;
  accent-color: var(--green);
}

.summary-list {
  display: grid;
  gap: 9px;
  margin-top: 14px;
}

.summary-list div {
  min-height: 44px;
  padding: 0 12px;
}

.summary-list span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 750;
}

.summary-list strong {
  max-width: 190px;
  overflow: hidden;
  font-size: 14px;
  text-align: right;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.care-progress {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 9px;
  margin-top: 14px;
}

.care-progress div {
  min-height: 58px;
  padding: 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.72);
}

.care-progress span,
.care-progress strong {
  display: block;
}

.care-progress span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.care-progress strong {
  margin-top: 4px;
  font-size: 22px;
  font-variant-numeric: tabular-nums;
}

.alert-layer {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 22px;
  background: rgba(24, 29, 34, 0.48);
  backdrop-filter: blur(8px);
  z-index: 10;
}

.rule-layer {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 22px;
  background: rgba(24, 29, 34, 0.46);
  backdrop-filter: blur(8px);
  z-index: 11;
}

.rule-layer[hidden] {
  display: none;
}

.rule-dialog {
  width: min(680px, 100%);
  max-height: min(760px, calc(100vh - 44px));
  overflow-y: auto;
  border: 1px solid rgba(255, 255, 255, 0.62);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 30px 90px rgba(0, 0, 0, 0.28);
  padding: 24px;
}

.rule-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.rule-head h2 {
  margin-top: 10px;
  font-size: 28px;
}

.icon-close {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-strong);
  color: var(--ink);
  font-size: 24px;
  line-height: 1;
}

.rule-section {
  padding: 16px 0;
  border-top: 1px solid var(--line);
}

.rule-section h3 {
  margin: 0 0 9px;
  font-size: 16px;
}

.rule-section p,
.rule-section li {
  color: var(--muted);
  line-height: 1.7;
}

.rule-section p {
  margin: 0 0 8px;
}

.rule-section ul {
  margin: 8px 0 0;
  padding-left: 20px;
}

.alert-layer[hidden] {
  display: none;
}

.alert-dialog {
  display: grid;
  grid-template-columns: 70px minmax(0, 1fr);
  gap: 18px;
  width: min(680px, 100%);
  border: 1px solid rgba(255, 255, 255, 0.62);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 30px 90px rgba(0, 0, 0, 0.28);
  padding: 24px;
}

.alert-icon {
  display: grid;
  place-items: center;
  width: 58px;
  height: 58px;
  border-radius: 18px;
  background: color-mix(in srgb, var(--amber) 17%, white);
  color: var(--amber);
  font-size: 28px;
  font-weight: 950;
}

.alert-dialog h2 {
  margin: 10px 0 8px;
  font-size: 27px;
}

.alert-dialog p {
  color: var(--ink);
  font-size: 16px;
  line-height: 1.7;
}

.dialog-actions {
  grid-column: 2;
  justify-content: flex-start;
}

body[data-mode="rest"] .progress {
  stroke: var(--blue);
}

body[data-mode="alert"] .progress {
  stroke: var(--amber);
}

body[data-camera="low-blink"] .camera-panel {
  border-color: color-mix(in srgb, var(--amber) 55%, var(--line));
}

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

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

  .timer-face {
    width: min(82vw, 360px);
  }
}

@media (max-width: 680px) {
  .app-shell {
    padding: 14px;
  }

  .app-header {
    display: grid;
    align-items: start;
  }

  .header-stats,
  .blink-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    width: 100%;
  }

  .timer-head,
  .panel-title {
    align-items: flex-start;
    flex-direction: column;
  }

  select {
    width: 100%;
  }

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

  .settings-grid .field {
    grid-template-rows: auto;
    min-height: auto;
    gap: 7px;
  }

  .settings-grid .field small {
    min-height: auto;
  }

  .alert-dialog {
    grid-template-columns: 1fr;
  }

  .dialog-actions {
    grid-column: auto;
  }

  .button {
    width: 100%;
  }
}
