:root {
  color-scheme: light;
  --bg: #ffffff;
  --ink: #000000;
  --muted: #6b6b6b;
  --card: #ffffff;
  --field: #ffffff;
  --line: #e5e5e5;
  --accent: #000000;
  --on-accent: #ffffff;
  --hi: #ff4d00;
  --shadow: none;
  --sans: Inter, "Helvetica Neue", Helvetica, Arial, sans-serif;
  --serif: var(--sans);
}

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --bg: #000000;
    --ink: #ffffff;
    --muted: #9a9a9a;
    --card: #0d0d0d;
    --field: #0d0d0d;
    --line: #262626;
    --accent: #ffffff;
    --on-accent: #000000;
    --hi: #ff5a1f;
  }
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--sans);
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  font-feature-settings: "cv11", "ss01";
  padding-left: env(safe-area-inset-left);
  padding-right: env(safe-area-inset-right);
}

body::before {
  content: "";
  display: block;
  height: 4px;
  background: var(--hi);
}

main {
  width: min(40rem, calc(100% - 2rem));
  margin: 0 auto;
  padding: 1.25rem 0 3rem;
}

h1,
h2,
.entry h3 {
  font-family: var(--sans);
  font-weight: 700;
  letter-spacing: -0.035em;
}

h1 {
  margin: 0;
  font-size: clamp(1.85rem, 4.5vw, 2.6rem);
  line-height: 0.95;
}

h1 a {
  color: inherit;
  text-decoration: none;
}

h2 {
  margin: 0 0 0.65rem;
  font-size: 1.15rem;
}

.lede,
.hint,
.footnote,
.empty,
.since {
  color: var(--muted);
  line-height: 1.5;
}

.lede {
  max-width: 34rem;
  margin: 0;
  font-size: 1.05rem;
}

.bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.85rem;
}

.bar-actions {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.add {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: 3rem;
  height: 3rem;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: var(--accent);
  color: var(--on-accent);
  font-size: 2rem;
  line-height: 1;
}

.add-icon::before {
  content: "+";
}

.add.is-open {
  background: var(--field);
  color: var(--ink);
  border: 1px solid var(--line);
  font-size: 1.75rem;
}

.add.is-open .add-icon::before {
  content: "×";
}

.add:disabled {
  opacity: 0.45;
  cursor: default;
}

form,
.entry {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow);
}

form {
  display: flex;
  flex-direction: column;
  gap: 0.95rem;
  padding: 1.1rem;
}

label {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

label span,
.unit span {
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

input,
button {
  font: inherit;
}

input {
  width: 100%;
  min-width: 0;
  appearance: none;
  background: var(--field);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.8rem 0.85rem;
  font-size: 1rem;
}

button {
  cursor: pointer;
}

.actions {
  display: flex;
  gap: 0.65rem;
}

.primary,
.ghost,
.text-btn {
  border-radius: 10px;
}

.primary {
  flex: 1;
  border: 0;
  background: var(--accent);
  color: var(--on-accent);
  padding: 0.85rem 1rem;
  font-weight: 600;
}

.ghost {
  border: 1px solid var(--line);
  background: transparent;
  color: var(--ink);
  padding: 0.85rem 0.9rem;
}

.primary:hover,
.ghost:hover,
.text-btn:hover {
  filter: brightness(1.06);
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

.note {
  margin: 0.4rem 0 0;
  color: var(--accent);
  font-size: 0.95rem;
}

.note:empty {
  display: none;
}

.hint,
.footnote,
.empty {
  margin: 0;
  font-size: 0.92rem;
}

.saved {
  margin-top: 0.85rem;
}

#list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.65rem;
}

.entry {
  min-width: 0;
  padding: 1rem 1rem 1.05rem;
}

.entry.is-fresh {
  border-color: var(--accent);
}

.entry-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.75rem 1rem;
}

.entry h3 {
  margin: 0;
  font-size: 1.7rem;
  line-height: 1.05;
  overflow-wrap: anywhere;
}

.entry-title {
  color: inherit;
  text-decoration: none;
}

.entry-title:hover {
  text-decoration: underline;
  text-underline-offset: 0.15em;
}

.entry-share {
  margin-top: 0.35rem;
}

.entry-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 0.15rem;
}

.text-btn {
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: 0.35rem 0.45rem;
  font-size: 0.92rem;
}

.text-btn.primary {
  color: var(--accent);
  font-weight: 600;
}

.counter {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.5rem;
  margin-top: 1rem;
  padding-top: 0.95rem;
  border-top: 1px solid var(--line);
}

.unit b {
  display: block;
  font-family: var(--sans);
  font-size: clamp(1.8rem, 6vw, 2.75rem);
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.05em;
  line-height: 1;
  color: var(--hi);
}

.counter.is-future b {
  opacity: 0.55;
}

.since {
  margin: 0.85rem 0 0;
  font-size: 0.95rem;
}

.footnote {
  margin-top: 1.5rem;
}

::selection {
  background: var(--hi);
  color: #000000;
}

@media (max-width: 420px) {
  .entry-top {
    flex-direction: column;
  }

  .entry-actions {
    justify-content: flex-start;
  }
}

@media (min-width: 720px) {
  form.starter {
    display: grid;
    grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr) auto;
    align-items: end;
    gap: 0.75rem;
  }

  form.starter .hint {
    grid-column: 1 / -1;
  }
}

@media (min-width: 960px) {
  main {
    width: min(68rem, calc(100% - 3rem));
  }

  .empty,
  .footnote {
    max-width: 40rem;
  }

  #list {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .entry-top {
    flex-direction: column;
  }

  .entry-actions {
    justify-content: flex-start;
  }

  .entry h3 {
    font-size: 1.45rem;
  }

  .unit b {
    font-size: 1.85rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    scroll-behavior: auto !important;
  }
}

body.is-share main {
  width: min(40rem, calc(100% - 2rem));
}

body.is-share #list {
  grid-template-columns: 1fr;
}

body.is-share .entry h3 {
  font-size: clamp(2rem, 6vw, 2.8rem);
}

body.is-share .unit b {
  font-size: clamp(2.2rem, 8vw, 3.4rem);
}
