:root {
  color-scheme: light;
  --page: #f7f6fb;
  --surface: #fff;
  --ink: #211a32;
  --secondary: #635a73;
  --line: #e6e0ee;
  --accent: #5236a5;
  --accent-ink: #fff;
  --accent-soft: #eee8fc;
  --success: #176b55;
  --success-soft: #e4f5ec;
  --danger: #a32e46;
  --danger-soft: #fcecf0;
  --shadow: 0 18px 60px rgb(33 26 50 / 16%);
  font: 16px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #16131e;
  --surface: #231e31;
  --ink: #f5f0fb;
  --secondary: #c0b4d2;
  --line: #3d334c;
  --accent: #c9b5ff;
  --accent-ink: #2e1a65;
  --accent-soft: #3b2c58;
  --success: #a1e2c2;
  --success-soft: #253d35;
  --danger: #ffabbb;
  --danger-soft: #4a2837;
  --shadow: 0 18px 60px rgb(0 0 0 / 38%);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--page); color: var(--ink); }
button, input, select { font: inherit; }
button { cursor: pointer; }
button:disabled { opacity: .55; cursor: wait; }
button:focus-visible, input:focus-visible, select:focus-visible, summary:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}
h1, h2, p { margin: 0; }
h1 { font-size: 1.28rem; font-weight: 780; letter-spacing: -.025em; }
h2 { font-size: 1.16rem; line-height: 1.25; }
p { overflow-wrap: anywhere; }

.shell {
  width: min(100%, 37rem);
  margin-inline: auto;
  padding: calc(8px + env(safe-area-inset-top)) 14px calc(14px + env(safe-area-inset-bottom));
}

.header {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 48px;
  margin-bottom: 8px;
}

.brand {
  display: grid;
  place-items: center;
  flex: 0 0 34px;
  height: 34px;
  border-radius: 11px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 1.5rem;
  font-weight: 720;
  line-height: 1;
}

.primary, .quiet, .danger, .tabs button, .points-button {
  min-height: 42px;
  padding: 7px 12px;
  border: 1px solid transparent;
  border-radius: 11px;
  font-weight: 660;
}

.primary { background: var(--accent); color: var(--accent-ink); }
.danger { background: var(--danger-soft); color: var(--danger); }
.quiet { background: var(--surface); color: var(--ink); border-color: var(--line); }
.refresh { margin-inline-start: auto; font-size: 1.22rem; line-height: 1; }

.tabs {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 3px;
  padding: 3px;
  border-radius: 13px;
  background: var(--accent-soft);
}

.tabs button { background: transparent; color: var(--secondary); padding-inline: 4px; }
.tabs button[aria-current="page"] { background: var(--surface); color: var(--accent); }
.panel { padding-top: 10px; }
.tools { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 8px; }
.rows { list-style: none; padding: 0; margin: 0; }

.rows > li {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 53px;
  padding: 5px 8px 5px 11px;
  background: var(--surface);
  border: 1px solid var(--line);
}

.rows > li + li { border-top: 0; }
.rows > li:first-child { border-radius: 13px 13px 0 0; }
.rows > li:last-child { border-radius: 0 0 13px 13px; }
.rows > li:only-child { border-radius: 13px; }
.rows .my-rank { background: var(--accent-soft); }
.row-copy { flex: 1; min-width: 0; }
.row-title { font-weight: 650; overflow-wrap: anywhere; }
.meta { color: var(--secondary); font-size: .875rem; margin-top: 2px; }
.ranking-place { flex: 0 0 24px; text-align: center; color: var(--accent); font-weight: 780; }
.points, .points-button { white-space: nowrap; font-variant-numeric: tabular-nums; }
.points { color: var(--success); font-weight: 740; text-align: right; }
.points-button { background: var(--success-soft); color: var(--success); min-width: 50px; }
.icon-button { padding: 6px; width: 39px; height: 42px; color: var(--secondary); }
.icon-button .pencil { font-size: 1.08rem; }
.cancel-award { flex: none; font-size: .875rem; padding-inline: 7px; }
.canceled .points { color: var(--secondary); text-decoration: line-through; }
.more { margin-top: 8px; }

.period { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; color: var(--secondary); }
.period select {
  appearance: none;
  max-width: 100%;
  min-height: 42px;
  padding: 6px 24px 6px 8px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  color: var(--ink);
  font-weight: 620;
}
.period { position: relative; }
.period::after {
  content: "";
  position: absolute;
  right: 9px;
  top: calc(50% - 5px);
  width: 6px;
  height: 6px;
  pointer-events: none;
  border: solid var(--secondary);
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

.archived { margin-top: 10px; }
.archived summary { cursor: pointer; color: var(--secondary); padding: 7px 4px; }
.empty, .status { border-radius: 12px; padding: 10px 12px; }
.empty { background: var(--surface); border: 1px solid var(--line); }
.empty p { color: var(--secondary); }
.empty h2 + p { margin-top: 5px; }
.empty .primary { margin-top: 10px; }
.status { margin-bottom: 8px; background: var(--accent-soft); color: var(--ink); }
.status[data-kind="error"], .form-error { background: var(--danger-soft); color: var(--danger); }

dialog {
  width: min(calc(100% - 24px), 29rem);
  max-height: calc(100% - 20px);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 13px;
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow);
}
dialog::backdrop { background: rgb(23 15 40 / 51%); }
.dialog-header { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 7px; }
.dialog-header .dismiss { flex: none; width: 42px; padding-inline: 0; font-size: 1.12rem; }
.field { display: grid; gap: 3px; margin-bottom: 8px; color: var(--secondary); }
.field input {
  width: 100%;
  min-height: 42px;
  padding: 6px 9px;
  border-radius: 9px;
  border: 1px solid var(--line);
  color: var(--ink);
  background: var(--page);
}
.points-field { width: min(100%, 9rem); }
.dialog-actions { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 9px; }
.form-error { margin-top: 8px; border-radius: 9px; padding: 7px 9px; }

@media (max-width: 350px) {
  .shell { padding-inline: 9px; }
  .rows > li { gap: 5px; padding-inline: 7px; }
}
