:root {
  --bg: #f3f5f8;
  --ink: #1b2330;
  --muted: #667386;
  --line: #e3e8ef;
  --red: #e10600;
  --red-dark: #b80500;
  color-scheme: light;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

body {
  margin: 0;
  font-family: "Segoe UI", system-ui, sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.45;
}

body.modal-open { overflow: hidden; }

button, input, textarea, select { font: inherit; color: inherit; }

input, textarea, select { font-size: 16px; }

.top {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 56px;
  padding: 8px 16px;
  background: rgba(243, 245, 248, 0.94);
  border-bottom: 1px solid var(--line);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: inherit;
  text-decoration: none;
  font-weight: 700;
  letter-spacing: -0.03em;
}

.mark {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: linear-gradient(#ee1515 0 10px, #1b2330 10px 12px, #fff 12px 22px);
  box-shadow: inset 0 0 0 2px #1b2330;
  position: relative;
  flex: 0 0 auto;
}

.mark::after {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #fff;
  border: 2px solid #1b2330;
  position: absolute;
  left: 5px;
  top: 5px;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 2px;
  min-width: 0;
}

.me {
  color: inherit;
  text-decoration: none;
  font-weight: 700;
  max-width: 46vw;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.wrap {
  width: min(720px, calc(100% - 32px));
  margin: 0 auto;
  padding: 20px 0 48px;
}

.narrow { width: min(440px, calc(100% - 32px)); }

h1 {
  margin: 0 0 12px;
  font-size: 32px;
  line-height: 1.1;
  letter-spacing: -0.04em;
}

h2 { margin: 0 0 12px; font-size: 20px; }

.lead, .hint, .empty, .count { color: var(--muted); }

.lead { margin: 0 0 16px; }

.hint { margin: 8px 0 0; font-size: 14px; }

.panel {
  background: #fff;
  border-radius: 18px;
  padding: 16px;
  margin-bottom: 12px;
}

.banner {
  margin: 0 0 12px;
  padding: 10px 12px;
  border-radius: 12px;
  background: #fff4f2;
  color: #8d1d14;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 14px;
  font-weight: 650;
}

.field span, .kicker { color: var(--muted); font-weight: 650; }

.kicker { display: block; font-size: 12px; }

input[type="text"],
input[type="password"],
input[type="search"],
textarea {
  width: 100%;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid #d5dde6;
  background: #fff;
}

textarea { resize: vertical; min-height: 76px; }

input:focus, textarea:focus, button:focus-visible, a:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 2px;
}

.btn {
  appearance: none;
  border: 0;
  background: var(--red);
  color: #fff;
  font-weight: 700;
  padding: 12px 16px;
  border-radius: 999px;
  cursor: pointer;
  text-decoration: none;
  text-align: center;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.btn .icon { width: 20px; height: 20px; flex: 0 0 auto; }

.stack .btn { width: 100%; }

.btn:hover { background: var(--red-dark); }

.btn.secondary {
  background: #fff;
  color: var(--ink);
  box-shadow: inset 0 0 0 1px #d5dde6;
}

.btn.secondary:hover { background: #f7f9fb; }

.header-btn {
  padding: 8px 12px;
  font-size: 13px;
  line-height: 1.2;
  max-width: 58vw;
}

.icon-btn {
  width: 40px;
  height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  border: 0;
  border-radius: 999px;
  background: #fff;
  color: var(--ink);
  box-shadow: inset 0 0 0 1px #d5dde6;
  text-decoration: none;
  cursor: pointer;
  font-size: 22px;
  line-height: 1;
}

.icon { display: block; }

.icon-btn .icon { width: 20px; height: 20px; }

.plain-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  width: auto;
  height: auto;
  padding: 4px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  box-shadow: none;
  color: var(--muted);
  cursor: pointer;
}

.plain-icon .icon { width: 20px; height: 20px; }

.back-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  margin: 0 0 8px -8px;
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}

.back-link .icon { width: 22px; height: 22px; }

.close-btn { padding: 0; }

.crumbs { margin: 0 0 14px; }

.crumbs ol {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  list-style: none;
  margin: 0;
  padding: 0;
  font-size: 13px;
  font-weight: 650;
}

.crumbs li { display: flex; align-items: center; color: var(--muted); }

.crumbs li + li::before { content: "/"; margin: 0 8px; color: #b7c0cb; }

.crumbs a { color: inherit; text-decoration: none; }

.crumbs [aria-current="page"] { color: var(--ink); }

.profile-card { padding: 14px 12px; }

.profile-title {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.profile-card h1 { margin-bottom: 8px; }

.section-head h1 { margin: 0; }

.user-row a {
  flex: 1;
  min-width: 0;
  color: inherit;
  text-decoration: none;
}

.row-actions { display: flex; align-items: center; gap: 8px; flex: 0 0 auto; }

.id-stack { display: flex; flex-direction: column; gap: 12px; }

.id-block { display: flex; flex-direction: column; gap: 6px; }

.id-label { font-size: 14px; font-weight: 700; }

.id-value {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
  padding: 12px 14px;
  border: 0;
  border-radius: 12px;
  background: #e7ebf0;
  color: var(--muted);
  font: inherit;
  font-weight: 650;
  cursor: pointer;
  text-align: left;
}

.id-value .icon { width: 18px; height: 18px; flex: 0 0 auto; }

.profile-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: nowrap;
}

.copy-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  flex: 0 0 auto;
  padding: 2px 0;
  border: 0;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 12px;
  font-weight: 650;
  line-height: 1.2;
  cursor: pointer;
  text-align: left;
  white-space: nowrap;
}

.copy-chip .icon { width: 16px; height: 16px; flex: 0 0 auto; }

.copy-btn { position: relative; }

.copy-state { display: none; }

.show-copied .copy-state {
  display: block;
  position: absolute;
  z-index: 6;
  left: 50%;
  bottom: calc(100% + 8px);
  transform: translateX(-50%);
  padding: 4px 8px;
  border-radius: 8px;
  background: var(--ink);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  line-height: 1.2;
  white-space: nowrap;
  pointer-events: none;
  animation: tip-in .16s ease;
}

.panel.lists { margin-top: 0; }

.search-box { position: relative; display: block; color: var(--ink); }

.search-box .icon {
  position: absolute;
  left: 12px;
  top: 50%;
  width: 18px;
  height: 18px;
  margin-top: -9px;
  color: var(--muted);
  pointer-events: none;
}

.search-box input { padding-left: 40px; }

#list-string { min-height: 64px; }

.list-row .meta { color: inherit; }

.section-head {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 8px;
}

.section-head h2 { margin: 0; }

.user-row, .list-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 14px 0;
  border-top: 1px solid var(--line);
  color: inherit;
  text-decoration: none;
  font-weight: 700;
}

.list-row .meta { flex: 1; min-width: 0; }

.list-row strong, .list-row .count { display: block; }

.list-row .count { font-weight: 600; font-size: 13px; }

.list-row .icon-btn { flex: 0 0 auto; }

.back { color: var(--muted); text-decoration: none; font-weight: 650; font-size: 14px; }

.list-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.list-title-row h1 { margin: 0; }

.numbers-line {
  display: block;
  width: 100%;
  margin: 0 0 14px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-family: ui-monospace, Consolas, monospace;
  font-size: 16px;
  line-height: 1.4;
  text-align: left;
  word-break: break-all;
  cursor: pointer;
}

.show-grid { overflow: visible; flex: none; }

.poke-card { cursor: default; }

.tabs {
  display: flex;
  gap: 8px;
  margin: 4px 0 16px;
}

.tab {
  flex: 1;
  border: 0;
  background: #f3f5f8;
  color: var(--muted);
  font-weight: 700;
  border-radius: 999px;
  padding: 10px 12px;
  cursor: pointer;
}

.tab.is-on { background: var(--ink); color: #fff; }

.auth-modal { align-items: center; padding: 16px; }

.auth-modal .modal-card {
  width: min(440px, 100%);
  height: auto;
  max-height: calc(100% - 8px);
  margin: auto;
  border-radius: 20px;
  overflow: auto;
}

.auth-modal .btn { margin-top: 16px; margin-bottom: 4px; }

.numbers {
  font-family: ui-monospace, Consolas, monospace;
  font-size: 16px;
  word-break: break-all;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: rgba(27, 35, 48, 0.45);
  display: flex;
  animation: shade-in .2s ease;
}

.modal-card {
  background: #fff;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  padding: 16px;
  min-height: 0;
  animation: card-in .22s ease;
}

.modal-top {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}

.modal-top h2 {
  margin: 0;
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.danger-link {
  flex: 0 0 auto;
  border: 0;
  background: transparent;
  color: var(--red);
  font: inherit;
  font-size: 14px;
  font-weight: 700;
  padding: 8px 2px;
  cursor: pointer;
  white-space: nowrap;
}

.danger-link:hover { color: var(--red-dark); }

.modal-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 0;
  flex: 1;
}

.pick-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  overflow: auto;
  flex: 1;
  min-height: 0;
  align-content: start;
  padding-bottom: 8px;
}

.pick {
  border: 0;
  background: #fff;
  border-radius: 14px;
  box-shadow: inset 0 0 0 1px var(--line);
  padding: 6px 4px 8px;
  text-align: center;
  cursor: pointer;
}

.pick img { width: 64px; height: 64px; display: block; margin: 0 auto; }

.pick .no { display: block; color: var(--muted); font-size: 12px; font-weight: 700; }

.pick .name {
  display: block;
  font-size: 12px;
  font-weight: 700;
  line-height: 1.2;
  min-height: 2.4em;
}

.pick.is-on { box-shadow: inset 0 0 0 2px var(--red); background: #fff4f2; }

.modal-bar { display: flex; gap: 8px; }

.modal-bar .btn { flex: 1; }

.logout-form { margin-top: 16px; }

@keyframes shade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes card-in {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: none; }
}

@keyframes tip-in {
  from { opacity: 0; transform: translateX(-50%) translateY(6px); }
  to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

@media (prefers-reduced-motion: reduce) {
  .modal, .modal-card, .show-copied .copy-state { animation: none; }
}

@media (min-width: 700px) {
  .wrap { width: min(960px, calc(100% - 48px)); padding-top: 28px; }
  h1 { font-size: 40px; }
  .section-head { flex-direction: row; align-items: center; justify-content: space-between; }
  .section-head .btn, .stack .btn { width: auto; }
  .modal { padding: 32px; }
  .modal-card {
    width: min(920px, 100%);
    height: min(860px, 100%);
    margin: auto;
    border-radius: 20px;
  }
  .modal-card-short { height: auto; }
  .pick-grid { grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); }
}
