:root {
  color-scheme: light;
  --bg: #f5f5f7;
  --surface: rgba(255, 255, 255, 0.92);
  --surface-soft: #ececf0;
  --text: #1d1d1f;
  --muted: #6e6e73;
  --faint: #a1a1a6;
  --line: rgba(60, 60, 67, 0.12);
  --blue: #0071e3;
  --blue-hover: #0077ed;
  --green: #30b05a;
  --red: #d93f3f;
  --dark: #1c1c1e;
  --radius: 24px;
  --shadow: 0 14px 40px rgba(0, 0, 0, 0.06);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; background: var(--bg); color: var(--text); }
button, input, textarea, select { font: inherit; }
button { cursor: pointer; }
.shell { width: min(1240px, calc(100% - 36px)); margin: 0 auto; padding: 52px 0 80px; }
.topbar { display: flex; align-items: flex-end; justify-content: space-between; gap: 28px; }
.topbar h1 { margin: 8px 0 6px; font-size: clamp(48px, 7vw, 74px); line-height: .92; letter-spacing: -.06em; }
.topbar p { margin: 18px 0 0; color: var(--muted); font-size: 18px; }
.eyebrow { color: var(--muted); font-size: 13px; font-weight: 650; letter-spacing: .02em; }
.top-actions { display: flex; align-items: center; gap: 10px; }
.primary, .secondary, .danger, .ghost, .icon-button, .language-button { border: 0; border-radius: 999px; padding: 11px 18px; font-weight: 650; transition: .18s ease; }
.primary { background: var(--blue); color: white; }
.primary:hover { background: var(--blue-hover); transform: translateY(-1px); }
.secondary { background: var(--surface-soft); color: var(--text); }
.secondary:hover, .icon-button:hover, .language-button:hover { background: #e2e2e7; }
.danger { background: #ffe8e8; color: var(--red); }
.ghost { background: transparent; color: var(--blue); padding-inline: 8px; }
.icon-button { width: 42px; height: 42px; padding: 0; background: var(--surface-soft); color: var(--text); font-size: 20px; }
.language-button { min-width: 42px; height: 42px; padding: 0 12px; background: transparent; color: var(--muted); }
.segmented { width: fit-content; margin: 44px auto 30px; padding: 5px; display: grid; grid-template-columns: repeat(6, auto); gap: 3px; background: #e8e8ed; border-radius: 18px; }
.segmented button { border: 0; background: transparent; color: var(--muted); border-radius: 14px; padding: 10px 20px; font-weight: 650; }
.segmented button.active { background: white; color: var(--text); box-shadow: 0 1px 5px rgba(0,0,0,.09); }
.loading, .empty { color: var(--muted); padding: 70px 20px; text-align: center; }
.focus-grid { display: grid; grid-template-columns: minmax(330px, .82fr) minmax(460px, 1.18fr); gap: 24px; align-items: start; }
.card { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); }
.timer-card { min-height: 520px; background: var(--dark); color: white; padding: 36px; display: flex; flex-direction: column; }
.timer-card.idle { background: white; color: var(--text); }
.timer-card .eyebrow { color: #a9a9ae; }
.timer-title { margin: 14px 0 4px; font-size: 28px; letter-spacing: -.03em; }
.timer-goal { color: #a9a9ae; line-height: 1.5; }
.timer-value { margin: auto 0 8px; font-variant-numeric: tabular-nums; font-size: clamp(72px, 9vw, 112px); line-height: .95; letter-spacing: -.07em; }
.timer-state { color: #a9a9ae; }
.timer-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 30px; }
.timer-card:not(.idle) .secondary { background: #363638; color: white; }
.monitor-note { margin-top: 34px; color: #9a9aa0; font-size: 13px; display: flex; align-items: center; gap: 8px; }
.reward-inline { margin-top: 22px; padding: 14px 16px; border-radius: 16px; background: #28282b; }
.empty-inline { color: var(--muted); font-size: 13px; }
.reward-inline.empty-inline { color: #9a9aa0; }
.reward-progress-card.empty-inline { padding: 18px; border-radius: 16px; background: var(--bg); }
.reward-progress-copy { display: grid; grid-template-columns: minmax(0,1fr) auto; align-items: baseline; gap: 4px 12px; }
.reward-progress-copy span { grid-column: 1 / -1; color: var(--muted); font-size: 11px; font-weight: 650; text-transform: uppercase; letter-spacing: .04em; }
.reward-inline .reward-progress-copy span, .reward-inline .reward-progress-copy small { color: #9a9aa0; }
.reward-progress-copy strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.reward-progress-copy small { color: var(--muted); white-space: nowrap; }
.reward-meter { height: 6px; margin-top: 11px; overflow: hidden; border-radius: 999px; background: rgba(142,142,147,.24); }
.reward-meter span { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, #8c6cff, #ff6aa2); transition: width .3s ease; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 4px rgba(48,176,90,.14); }
.task-card { padding: 34px 36px; }
.section-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 20px; margin-bottom: 24px; }
.section-head h2 { margin: 7px 0 0; font-size: 30px; letter-spacing: -.035em; }
.summary-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-bottom: 25px; }
.summary-item { background: var(--bg); border-radius: 18px; padding: 16px; }
.summary-item strong { display: block; font-size: 21px; }
.summary-item span { color: var(--muted); font-size: 12px; }
.progress { height: 6px; background: #e7e7eb; border-radius: 999px; overflow: hidden; }
.progress > span { display: block; height: 100%; background: var(--blue); border-radius: inherit; }
.task-list { margin-top: 12px; }
.task-row { display: grid; grid-template-columns: 26px minmax(0,1fr) auto; gap: 14px; align-items: center; padding: 18px 0; border-bottom: 1px solid var(--line); }
.task-row:last-child { border-bottom: 0; }
.task-check { width: 22px; height: 22px; border-radius: 50%; border: 2px solid #c7c7cc; background: transparent; padding: 0; }
.task-check:hover { border-color: var(--blue); }
.task-copy strong { display: block; font-size: 16px; }
.task-copy span { display: block; color: var(--muted); font-size: 13px; margin-top: 5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.task-tools { display: flex; align-items: center; gap: 5px; }
.task-tools button { border: 0; background: transparent; color: var(--blue); padding: 8px; font-weight: 650; }
.page-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 20px; }
.page-card { padding: 30px; }
.page-card h2, .page-card h3 { margin: 0; letter-spacing: -.025em; }
.rewards-head p { margin: 10px 0 0; color: var(--muted); }
.reward-hero { padding: 30px; display: grid; grid-template-columns: minmax(0,1fr) auto; gap: 20px; margin-bottom: 20px; }
.reward-hero h2 { margin: 7px 0 0; font-size: 32px; letter-spacing: -.04em; }
.reward-hero .reward-progress-card { grid-column: 1 / -1; }
.reward-balance { min-width: 110px; text-align: right; }
.reward-balance strong { display: block; font-size: 36px; letter-spacing: -.05em; }
.reward-balance span { color: var(--muted); font-size: 12px; }
.reward-market { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 16px; margin-bottom: 20px; }
.reward-card { min-height: 265px; padding: 25px; border: 1px solid transparent; display: flex; flex-direction: column; }
.reward-card.selected { border-color: rgba(140,108,255,.45); box-shadow: 0 14px 42px rgba(107,76,210,.12); }
.reward-card-top, .reward-actions { display: flex; align-items: center; gap: 8px; }
.reward-card-top { justify-content: space-between; }
.reward-duration { color: #7355df; font-size: 13px; font-weight: 700; }
.selected-chip { background: #eee9ff; color: #6544d3; }
.reward-card h3 { margin: 22px 0 8px; font-size: 22px; letter-spacing: -.03em; }
.reward-card p { margin: 0; color: var(--muted); line-height: 1.5; }
.reward-meta { display: flex; flex-wrap: wrap; gap: 7px; margin: 18px 0; }
.reward-meta span { padding: 5px 8px; border-radius: 9px; background: var(--bg); color: var(--muted); font-size: 11px; }
.reward-actions { margin-top: auto; flex-wrap: wrap; }
.danger-text { color: var(--red); }
.reward-shelves { margin-top: 0; }
.reward-grant { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 16px 0; border-bottom: 1px solid var(--line); }
.reward-grant:last-child { border-bottom: 0; }
.reward-grant strong, .reward-grant span { display: block; }
.reward-grant span { margin-top: 5px; color: var(--muted); font-size: 12px; }
.reward-grant.redeemed { opacity: .62; }
.check-field { display: flex; align-items: flex-start; gap: 10px; margin: 18px 0; color: var(--muted); font-size: 13px; line-height: 1.45; }
.check-field input { margin-top: 2px; }
.project-card { min-height: 220px; display: flex; flex-direction: column; }
.project-meta { color: var(--muted); margin-top: 10px; line-height: 1.5; }
.project-card .progress { margin-top: auto; }
.project-footer { display: flex; justify-content: space-between; color: var(--muted); font-size: 13px; margin-top: 10px; }
.direction-strip { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 12px; margin-bottom: 20px; }
.direction-item { min-height: 142px; padding: 22px; border-radius: 21px; background: #e9e9ee; display: flex; justify-content: space-between; gap: 16px; }
.direction-item span { color: var(--muted); font-size: 11px; font-weight: 650; text-transform: uppercase; letter-spacing: .04em; }
.direction-item strong { display: block; margin-top: 7px; font-size: 18px; }
.direction-item p { margin: 8px 0 0; color: var(--muted); font-size: 13px; line-height: 1.45; }
.direction-item b { white-space: nowrap; color: var(--muted); font-size: 12px; }
.stat-hero { grid-column: 1 / -1; display: grid; grid-template-columns: 1.4fr 1fr 1fr; gap: 12px; }
.stat-block { background: var(--bg); border-radius: 20px; padding: 24px; }
.stat-block strong { display: block; font-size: 42px; letter-spacing: -.05em; }
.stat-block span { color: var(--muted); }
.settings-list { overflow: hidden; }
.settings-row { display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 20px 0; border-bottom: 1px solid var(--line); }
.settings-row:last-child { border-bottom: 0; }
.settings-row strong { display: block; }
.settings-row span { display: block; color: var(--muted); font-size: 13px; margin-top: 5px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { padding: 7px 11px; border-radius: 999px; background: var(--surface-soft); font-size: 13px; }
dialog { width: min(560px, calc(100% - 28px)); border: 0; border-radius: 26px; padding: 0; box-shadow: 0 30px 90px rgba(0,0,0,.23); }
dialog::backdrop { background: rgba(0,0,0,.25); backdrop-filter: blur(4px); }
dialog form { padding: 30px; }
.dialog-head { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 24px; }
.dialog-head h2 { margin: 6px 0 0; font-size: 30px; letter-spacing: -.04em; }
.close-button { border: 0; width: 34px; height: 34px; border-radius: 50%; background: var(--surface-soft); color: var(--muted); font-size: 22px; }
.field { display: block; margin: 16px 0; }
.field > span { display: block; color: var(--muted); font-size: 13px; font-weight: 600; margin-bottom: 8px; }
.field input, .field textarea, .field select { width: 100%; border: 0; border-radius: 14px; background: var(--bg); color: var(--text); padding: 13px 14px; outline: none; resize: vertical; }
.field input:focus, .field textarea:focus, .field select:focus { box-shadow: 0 0 0 3px rgba(0,113,227,.16); }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 28px; }
.toast { position: fixed; left: 50%; bottom: 28px; transform: translate(-50%, 24px); padding: 11px 16px; border-radius: 999px; background: rgba(28,28,30,.94); color: white; opacity: 0; pointer-events: none; transition: .22s ease; z-index: 20; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.error-card { padding: 40px; text-align: center; }
.error-card p { color: var(--muted); }
.token-form { width: min(460px, 100%); margin: 24px auto 0; display: flex; gap: 10px; }
.token-form input { min-width: 0; flex: 1; border: 0; border-radius: 999px; background: var(--bg); padding: 12px 16px; outline: none; }
.companion-card { width: min(820px, 100%); min-height: 590px; margin: 0 auto; padding: 34px; display: flex; flex-direction: column; }
.chat-thread { flex: 1; min-height: 360px; max-height: 58vh; overflow-y: auto; padding: 6px 2px 20px; }
.chat-message { width: min(78%, 620px); margin: 14px 0; }
.chat-message.user { margin-left: auto; }
.chat-message > span { display: block; margin: 0 10px 6px; color: var(--faint); font-size: 11px; font-weight: 650; text-transform: uppercase; letter-spacing: .04em; }
.chat-message p { margin: 0; padding: 13px 16px; border-radius: 18px; background: var(--bg); line-height: 1.55; }
.chat-message.user p { background: var(--blue); color: white; border-bottom-right-radius: 5px; }
.chat-message.assistant p { border-bottom-left-radius: 5px; }
.companion-empty { margin: auto; padding: 70px 20px; text-align: center; color: var(--muted); }
.companion-empty strong { display: block; color: var(--text); font-size: 22px; margin-bottom: 8px; }
.companion-empty p { max-width: 500px; margin: 0 auto; line-height: 1.6; }
.chat-form { display: grid; grid-template-columns: minmax(0,1fr) auto; align-items: end; gap: 10px; padding-top: 16px; border-top: 1px solid var(--line); }
.chat-form textarea { width: 100%; min-height: 48px; max-height: 150px; resize: vertical; border: 0; border-radius: 17px; background: var(--bg); padding: 13px 15px; outline: none; }
.chat-form textarea:focus { box-shadow: 0 0 0 3px rgba(0,113,227,.16); }

@media (max-width: 850px) {
  .shell { width: min(100% - 24px, 680px); padding-top: 28px; }
  .topbar { align-items: flex-start; }
  .topbar p { display: none; }
  .topbar h1 { font-size: 52px; }
  .focus-grid, .page-grid { grid-template-columns: 1fr; }
  .direction-strip, .reward-market { grid-template-columns: 1fr; }
  .timer-card { min-height: 430px; }
  .stat-hero { grid-column: auto; grid-template-columns: 1fr; }
  .segmented { width: 100%; overflow-x: auto; grid-template-columns: repeat(6, minmax(90px,1fr)); }
}

@media (max-width: 560px) {
  .topbar { display: block; }
  .top-actions { margin-top: 18px; flex-wrap: wrap; }
  .top-actions .icon-button { display: none; }
  .primary { padding-inline: 14px; }
  .segmented button { padding-inline: 8px; font-size: 13px; }
  .task-card, .page-card, .timer-card { padding: 24px; border-radius: 21px; }
  .summary-grid { grid-template-columns: repeat(2, 1fr); }
  .task-row { grid-template-columns: 24px minmax(0,1fr); }
  .task-tools { grid-column: 2; justify-content: flex-start; }
  .form-grid { grid-template-columns: 1fr; }
  .companion-card { min-height: 520px; }
  .reward-hero { grid-template-columns: 1fr; }
  .rewards-head { display: block; }
  .rewards-head .primary { margin-top: 16px; }
  .reward-balance { text-align: left; }
  .reward-hero .reward-progress-card { grid-column: auto; }
  .chat-message { width: 90%; }
}
