:root {
  color-scheme: light dark;
  --blue: #0b43ff;
  --black: #101010;
  --ink: #1f1f1f;
  --muted: #6e6e6e;
  --line: #d8d8d8;
  --panel: #f4f4f4;
  --popup-bg: #f7f7f5;
  --white: #ffffff;
  --green: #137333;
  --red: #b3261e;
  --focus: #4d4d4d;
}

@media (prefers-color-scheme: dark) {
  :root {
    --black: #f2f2f2;
    --blue: #5f83ff;
    --ink: #f1f1f1;
    --muted: #ababab;
    --line: #3a3a3a;
    --panel: #202020;
    --popup-bg: #161616;
    --white: #121212;
    --green: #2f9d58;
    --red: #e05249;
    --focus: #d8d8d8;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--popup-bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
button:disabled, input:disabled, select:disabled, textarea:disabled { cursor: not-allowed; opacity: 0.64; }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
h1, h2, p { margin: 0; }
h1 { color: var(--ink); font-size: 22px; line-height: 1.2; font-weight: 800; }
h2 { font-size: 15px; line-height: 1.2; }

label {
  display: grid;
  gap: 7px;
  color: var(--ink);
  font-size: 13px;
  font-weight: 650;
}

label span {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}

label em {
  color: var(--muted);
  font-style: normal;
  font-weight: 500;
}

input, select, textarea {
  width: 100%;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--white);
  color: var(--ink);
  padding: 9px 10px;
}

select.task-ready {
  color: var(--green);
  font-weight: 750;
}

select.project-ready {
  color: var(--green);
  font-weight: 750;
}

input::placeholder,
textarea::placeholder {
  color: var(--muted);
  opacity: 1;
  font-weight: 650;
}

textarea { resize: vertical; }

.popup-shell {
  width: 360px;
  min-height: 0;
  border-radius: 30px 0 30px 30px;
  overflow: hidden;
}

.popup { display: grid; gap: 12px; padding: 18px 18px 12px; }
.topbar, .settings-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; }
.muted, .help-text { color: var(--muted); font-size: 12px; line-height: 1.45; }

.notice, .review-panel, .callout {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.notice { display: grid; gap: 8px; padding: 12px; font-size: 13px; }
.timer-form, .review-panel, .settings-card { display: grid; gap: 10px; }
.timer-form.is-disabled { opacity: 0.86; }
.project-row { display: grid; grid-template-columns: 1fr 38px; gap: 8px; }

.textarea-wrap {
  display: grid;
  gap: 6px;
}

.textarea-wrap em {
  justify-self: end;
  color: var(--muted);
  font-style: normal;
  font-weight: 650;
}

.icon-button {
  width: 38px;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--white);
  color: var(--ink);
  font-size: 20px;
  font-weight: 750;
  line-height: 1;
}

#openOptions {
  font-size: 22px;
}

.timer-button {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 56px;
  border: 0;
  border-radius: 8px;
  color: #fff;
  font-weight: 760;
}

.timer-button.start { background: var(--green); }
.timer-button.stop { background: var(--red); }
.timer-button.submit { background: var(--blue); color: #fff; }

.clock-face {
  position: relative;
  width: 28px;
  height: 28px;
  border: 3px solid currentColor;
  border-radius: 50%;
}

.clock-face::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: currentColor;
  transform: translate(-50%, -50%);
}

.clock-hand {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 2px;
  height: 10px;
  border-radius: 2px;
  background: currentColor;
  transform-origin: 50% 100%;
  transform: translate(-50%, -100%) rotate(0deg);
}

.timer-button.stop .clock-hand { animation: tick 1s steps(60) infinite; }
@keyframes tick { to { transform: translate(-50%, -100%) rotate(360deg); } }

.elapsed-panel {
  display: grid;
  gap: 8px;
  justify-items: center;
  padding: 10px 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.elapsed-input {
  width: 100%;
  min-height: 50px;
  border: 0;
  padding: 0;
  background: transparent;
  color: var(--ink);
  text-align: center;
  font-size: 38px;
  font-weight: 850;
  font-variant-numeric: tabular-nums;
  line-height: 1;
}

.elapsed-input:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 4px;
  border-radius: 6px;
}

.elapsed-panel strong {
  color: var(--ink);
  font-size: 30px;
  font-variant-numeric: tabular-nums;
  line-height: 1;
}

.review-panel { padding: 14px; }
.review-panel dl { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 0; }
.review-panel dt { color: var(--muted); font-size: 12px; font-weight: 650; }
.review-panel dd { margin: 3px 0 0; font-size: 18px; font-weight: 760; }
.button-row { display: flex; flex-wrap: wrap; gap: 10px; }

.primary-button, .secondary-button, .danger-button {
  min-height: 38px;
  border-radius: 6px;
  padding: 8px 12px;
  font-weight: 700;
}

.primary-button { border: 1px solid var(--black); background: var(--black); color: var(--white); }
.secondary-button { border: 1px solid var(--line); background: var(--white); color: var(--ink); }
.danger-button { border: 1px solid var(--red); background: var(--white); color: var(--red); }
.status-line {
  min-height: 14px;
  color: var(--ink);
  font-size: 11px;
  font-weight: 800;
  line-height: 1.4;
  text-align: center;
  text-transform: uppercase;
}
.status-line.is-error { color: var(--red); }

.options-shell { background: #ececec; }
@media (prefers-color-scheme: dark) { .options-shell { background: #0a0a0a; } }

.options {
  display: grid;
  gap: 18px;
  width: min(920px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 32px 0;
}

.settings-header, .settings-card {
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--white);
}

.settings-header p { margin-top: 5px; color: var(--muted); }
.setup-step { display: grid; grid-template-columns: 34px 1fr; gap: 12px; align-items: start; }

.step-marker {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--white);
  color: var(--ink);
  font-size: 13px;
  font-weight: 760;
}

.callout { display: grid; gap: 4px; padding: 12px; font-size: 13px; line-height: 1.45; }
.callout span { color: var(--muted); }
.backup-panel {
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  font-size: 13px;
  line-height: 1.45;
}
.backup-panel div:first-child {
  display: grid;
  gap: 4px;
}
.backup-panel span {
  color: var(--muted);
}
.advanced-card[open] { display: grid; }
.advanced-card summary { cursor: pointer; font-size: 13px; font-weight: 760; }

.floating-status {
  position: sticky;
  bottom: 0;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: color-mix(in srgb, var(--white) 96%, transparent);
}

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

@media (max-width: 680px) {
  .grid, .settings-header, .setup-step { grid-template-columns: 1fr; }
  .settings-header { display: grid; }
}
