:root {
  color-scheme: light;
  --ink: #142039;
  --muted: #6f7b91;
  --line: #e4e9f2;
  --surface: #ffffff;
  --canvas: #f4f7fc;
  --brand: #5b65e9;
  --brand-dark: #454ed6;
  --brand-soft: #eff0ff;
  --green: #2fba8b;
  --danger: #d65062;
  --shadow: 0 18px 48px rgba(41, 57, 97, 0.09);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--canvas);
}

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 3% 0%, rgba(115, 113, 255, 0.15), transparent 24rem),
    radial-gradient(circle at 96% 12%, rgba(47, 186, 139, 0.11), transparent 22rem),
    var(--canvas);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  -webkit-font-smoothing: antialiased;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

button:focus-visible,
input:focus-visible,
select:focus-visible {
  outline: 3px solid rgba(91, 101, 233, 0.27);
  outline-offset: 2px;
}

.app-shell {
  width: min(1120px, calc(100% - 40px));
  min-height: 100vh;
  margin: 0 auto;
  padding: max(24px, env(safe-area-inset-top)) 0 max(28px, env(safe-area-inset-bottom));
}

.topbar,
.welcome-grid,
.card-heading,
.goal-meta,
.mini-stats,
.tools-row,
.footer,
.history-item,
.history-main,
.history-side {
  display: flex;
  align-items: center;
}

.topbar {
  justify-content: space-between;
  margin-bottom: 56px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 11px;
  color: inherit;
  text-decoration: none;
}

.brand-mark {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border-radius: 13px;
  color: #fff;
  background: linear-gradient(145deg, #6e76f3, #4b54d5);
  box-shadow: 0 8px 20px rgba(84, 94, 221, 0.28);
  font-size: 21px;
}

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

.brand strong {
  font-size: 16px;
  letter-spacing: 0.02em;
}

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

.storage-badge,
.status-chip,
.record-count {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.76);
  color: #647188;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.storage-badge {
  padding: 8px 11px;
}

.storage-badge i {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--green);
}

.welcome-grid {
  justify-content: space-between;
  gap: 32px;
  margin-bottom: 30px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--brand);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

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

h1 {
  max-width: 680px;
  margin-bottom: 10px;
  font-size: clamp(29px, 4.2vw, 47px);
  line-height: 1.12;
  letter-spacing: -0.045em;
}

h2 {
  margin-bottom: 0;
  font-size: 20px;
  line-height: 1.2;
  letter-spacing: -0.025em;
}

h3 {
  margin-bottom: 5px;
  font-size: 15px;
}

.lead,
.tip-card p,
.empty-state p {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.65;
}

.card {
  border: 1px solid rgba(220, 226, 239, 0.95);
  border-radius: 24px;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: var(--shadow);
}

.today-total {
  min-width: 191px;
  padding: 20px 23px;
  text-align: right;
}

.today-total span,
.today-total small {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.today-total strong {
  display: block;
  margin: 4px 0;
  color: var(--brand-dark);
  font-size: 24px;
  letter-spacing: -0.04em;
}

.main-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(285px, 0.72fr);
  gap: 22px;
  align-items: start;
}

.timer-card,
.goal-card,
.history-card {
  padding: 29px;
}

.card-heading {
  justify-content: space-between;
  gap: 20px;
}

.card-heading.compact {
  align-items: flex-start;
}

.status-chip,
.record-count {
  padding: 7px 11px;
}

.status-chip.running {
  border-color: rgba(47, 186, 139, 0.28);
  background: #ecfbf5;
  color: #198261;
}

.status-chip.paused {
  border-color: rgba(225, 145, 61, 0.25);
  background: #fff8ed;
  color: #ae6a22;
}

.subject-row {
  display: grid;
  grid-template-columns: 82px 1fr;
  gap: 12px;
  align-items: center;
  margin-top: 35px;
}

.subject-row label,
.goal-input-label {
  color: #536077;
  font-size: 13px;
  font-weight: 700;
}

select,
.custom-subject,
.goal-input-label input {
  width: 100%;
  min-height: 44px;
  border: 1px solid #dce3f0;
  border-radius: 12px;
  background: #fbfcff;
  color: var(--ink);
  padding: 0 13px;
}

select:disabled,
input:disabled {
  opacity: 0.62;
  cursor: not-allowed;
}

.custom-subject {
  grid-column: 2;
  margin-top: -4px;
}

.timer-display {
  margin: 40px 0 7px;
  color: #17213a;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: clamp(54px, 9.5vw, 91px);
  font-weight: 750;
  letter-spacing: -0.085em;
  line-height: 1;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.timer-hint {
  min-height: 22px;
  margin: 0 0 28px;
  color: var(--muted);
  font-size: 13px;
  text-align: center;
}

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

.timer-actions .button:only-child {
  grid-column: 1 / -1;
}

.button {
  min-height: 42px;
  border: 1px solid transparent;
  border-radius: 12px;
  padding: 0 16px;
  font-size: 14px;
  font-weight: 750;
  transition: transform 160ms ease, box-shadow 160ms ease, background-color 160ms ease;
}

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

.button-primary {
  color: #fff;
  background: linear-gradient(135deg, #656ef0, #4c56d8);
  box-shadow: 0 8px 18px rgba(77, 86, 216, 0.22);
}

.button-primary:hover {
  background: linear-gradient(135deg, #5962e4, #424bc9);
}

.button-secondary {
  border-color: #dce3f0;
  color: #3e4c67;
  background: #fff;
}

.button-ghost {
  border-color: #dce3f0;
  color: #475773;
  background: rgba(255, 255, 255, 0.68);
}

.button-danger-ghost {
  border-color: #f4d8dc;
  color: var(--danger);
  background: #fff9fa;
}

.button-large {
  min-height: 53px;
  font-size: 15px;
}

.text-button {
  display: block;
  margin: 16px auto 0;
  border: 0;
  color: #8791a4;
  background: transparent;
  font-size: 13px;
  text-decoration: underline;
  text-underline-offset: 3px;
}

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

.icon-button {
  display: grid;
  width: 35px;
  height: 35px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--brand);
  background: #fbfcff;
  font-size: 18px;
}

.progress-track {
  height: 10px;
  margin-top: 30px;
  overflow: hidden;
  border-radius: 999px;
  background: #ebeff7;
}

.progress-bar {
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #626bef, #48bb9a);
  transition: width 420ms ease;
}

.goal-meta {
  justify-content: space-between;
  margin-top: 10px;
  color: var(--muted);
  font-size: 12px;
}

.goal-meta span:last-child {
  color: #4e5a72;
  font-weight: 800;
}

.goal-input-label {
  display: grid;
  gap: 7px;
  margin-top: 18px;
}

.mini-stats {
  gap: 10px;
  margin-top: 25px;
}

.mini-stats > div {
  flex: 1;
  padding: 12px 9px;
  border-radius: 13px;
  background: #f7f8fd;
  text-align: center;
}

.mini-stats strong,
.mini-stats span {
  display: block;
}

.mini-stats strong {
  color: #334060;
  font-size: 20px;
  letter-spacing: -0.04em;
}

.mini-stats span {
  margin-top: 3px;
  color: var(--muted);
  font-size: 10px;
}

.tip-card {
  display: flex;
  gap: 12px;
  padding: 18px;
  border-color: #e2e5ff;
  background: linear-gradient(135deg, #f4f3ff, #f9fcff);
  box-shadow: none;
}

.tip-icon {
  flex: 0 0 auto;
  color: #6a70e8;
  font-size: 21px;
}

.history-card {
  margin-top: 22px;
}

.history-list {
  margin-top: 19px;
}

.history-item {
  justify-content: space-between;
  gap: 16px;
  padding: 14px 0;
  border-top: 1px solid #edf0f5;
}

.history-main {
  min-width: 0;
  gap: 12px;
}

.session-bullet {
  display: grid;
  flex: 0 0 auto;
  width: 37px;
  height: 37px;
  place-items: center;
  border-radius: 12px;
  color: var(--brand);
  background: var(--brand-soft);
  font-size: 17px;
}

.session-title,
.session-meta {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.session-title {
  margin-bottom: 3px;
  color: #2f3d58;
  font-size: 14px;
  font-weight: 800;
}

.session-meta {
  color: var(--muted);
  font-size: 12px;
}

.history-side {
  flex: 0 0 auto;
  gap: 9px;
}

.session-duration {
  color: #3b4863;
  font-size: 13px;
  font-weight: 800;
  white-space: nowrap;
}

.delete-button {
  width: 30px;
  height: 30px;
  border: 0;
  border-radius: 9px;
  color: #94a0b2;
  background: transparent;
  font-size: 18px;
  line-height: 1;
}

.delete-button:hover {
  color: var(--danger);
  background: #fff4f5;
}

.empty-state {
  padding: 28px 16px 12px;
  text-align: center;
}

.empty-illustration {
  display: grid;
  width: 48px;
  height: 48px;
  place-items: center;
  margin: 0 auto 11px;
  border-radius: 17px;
  color: #8b93e8;
  background: #f0f1ff;
  font-size: 25px;
}

.empty-state h3 {
  margin-bottom: 3px;
  color: #4c5972;
}

.tools-row {
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 19px;
}

.footer {
  justify-content: space-between;
  margin-top: 48px;
  color: #909bad;
  font-size: 12px;
}

.toast {
  position: fixed;
  z-index: 20;
  bottom: calc(24px + env(safe-area-inset-bottom));
  left: 50%;
  max-width: calc(100vw - 32px);
  padding: 12px 17px;
  border-radius: 999px;
  color: #fff;
  background: rgba(20, 32, 57, 0.92);
  box-shadow: 0 12px 28px rgba(20, 32, 57, 0.24);
  font-size: 13px;
  font-weight: 700;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 16px);
  transition: opacity 180ms ease, transform 180ms ease;
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

.hidden {
  display: none !important;
}

@media (max-width: 760px) {
  .app-shell {
    width: min(100% - 28px, 620px);
    padding-top: max(17px, env(safe-area-inset-top));
  }

  .topbar {
    margin-bottom: 36px;
  }

  .storage-badge {
    padding: 7px 9px;
    font-size: 11px;
  }

  .brand small {
    display: none;
  }

  .welcome-grid {
    display: block;
    margin-bottom: 21px;
  }

  h1 {
    font-size: 31px;
  }

  .today-total {
    min-width: 0;
    margin-top: 20px;
    padding: 16px 18px;
    text-align: left;
  }

  .today-total span,
  .today-total strong,
  .today-total small {
    display: inline;
  }

  .today-total strong {
    margin: 0 8px;
  }

  .main-grid {
    grid-template-columns: 1fr;
    gap: 16px;
  }

  .timer-card,
  .goal-card,
  .history-card {
    padding: 21px;
    border-radius: 20px;
  }

  .timer-display {
    margin-top: 33px;
    font-size: clamp(48px, 16vw, 76px);
  }

  .side-stack {
    gap: 16px;
  }

  .history-card {
    margin-top: 16px;
  }

  .footer {
    display: grid;
    gap: 4px;
    margin-top: 35px;
  }
}

@media (max-width: 420px) {
  .topbar {
    align-items: flex-start;
  }

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

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

  .timer-actions .button {
    grid-column: 1 / -1;
  }

  .history-item {
    align-items: flex-start;
  }

  .history-side {
    flex-direction: column;
    align-items: flex-end;
    gap: 3px;
  }
}
