:root {
  --bg: #f4f3f1;
  --surface: #ffffff;
  --ink: #161513;
  --text: #1c1b19;
  --muted: #6f6a64;
  --line: #e4e0da;
  --line-strong: #cfc9c1;
  --accent: #9c3d2e;
  --danger: #9b332c;
  --shadow: 0 1px 2px rgba(22, 21, 19, 0.04);
}

* { box-sizing: border-box; }

html { color-scheme: light; }

html:not([data-i18n-ready]) body { visibility: hidden; }

body {
  margin: 0;
  min-height: 100vh;
  padding-left: env(safe-area-inset-left);
  padding-right: env(safe-area-inset-right);
  background: var(--bg);
  color: var(--text);
  font: 16px/1.6 "Segoe UI", ui-sans-serif, system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}

::selection { background: #f3ddd6; color: var(--ink); }

a { color: inherit; }

.wrap {
  width: min(760px, calc(100% - 40px));
  margin: 0 auto;
  padding: 8px 0 80px;
}

.top {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px 20px;
  margin: 0 0 28px;
  padding: 12px 0;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
}

.brand {
  color: var(--ink);
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: -0.03em;
  text-decoration: none;
}

nav {
  display: flex;
  gap: 4px;
}

nav a {
  display: inline-flex;
  align-items: center;
  min-height: 40px;
  padding: 0 12px;
  border-radius: 8px;
  color: var(--muted);
  text-decoration: none;
}

nav a:hover { color: var(--ink); }

nav a[aria-current="page"] {
  color: var(--ink);
  background: var(--surface);
  box-shadow: inset 0 0 0 1px var(--line);
}

.page-head { margin: 4px 0 24px; }

h1, h2 {
  color: var(--ink);
  font-weight: 600;
  letter-spacing: -0.03em;
}

h1 {
  margin: 0;
  font-size: clamp(1.6rem, 2.6vw, 1.9rem);
  line-height: 1.15;
}

h2 {
  margin: 0 0 8px;
  font-size: 1rem;
  line-height: 1.3;
}

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

.tagline {
  max-width: 36rem;
  margin: 6px 0 0;
  font-size: 0.95rem;
}

.tagline:empty { display: none; }

.toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
}

.toolbar input {
  flex: 1;
  min-width: 0;
  margin-top: 0;
  padding-left: 40px;
  background-color: var(--surface);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='none' stroke='%236f6a64' stroke-width='1.8' stroke-linecap='round'%3E%3Ccircle cx='7' cy='7' r='4.5'/%3E%3Cpath d='M10.5 10.5 14 14'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: 14px center;
}

.count {
  color: var(--muted);
  font-size: 0.875rem;
  white-space: nowrap;
}

.count:empty { display: none; }

.top10 { margin-bottom: 28px; }

.top10 h2 {
  margin-bottom: 10px;
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.top10 ol {
  margin: 0;
  padding: 0;
  list-style: none;
  counter-reset: rank;
}

.top10 li {
  display: flex;
  align-items: baseline;
  gap: 12px;
  margin: 0;
  padding: 10px 0;
  border-top: 1px solid var(--line);
  counter-increment: rank;
}

.top10 li:last-child { border-bottom: 1px solid var(--line); }

.top10 li::before {
  content: counter(rank, decimal-leading-zero);
  min-width: 1.6rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  font-size: 0.8rem;
}

.top10 a {
  color: var(--ink);
  text-decoration: none;
}

.top10 a:hover { color: var(--accent); }

.votes {
  margin-left: auto;
  color: var(--muted);
  font-size: 0.85rem;
  font-variant-numeric: tabular-nums;
}

.card {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  margin: 0 0 10px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.card-body { min-width: 0; flex: 1; }

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

.card h2 {
  margin: 0;
  font-size: 1.02rem;
  line-height: 1.3;
  overflow-wrap: anywhere;
}

.why {
  margin: 8px 0 0;
  color: var(--text);
}

.meta {
  margin-top: 8px;
  color: var(--muted);
  font-size: 0.85rem;
}

.avatar {
  display: grid;
  place-items: center;
  width: 56px;
  height: 80px;
  flex-shrink: 0;
  border-radius: 10px;
  background: #eceae6;
  color: var(--accent);
  font-weight: 600;
}

.poster {
  width: 56px;
  height: 80px;
  flex-shrink: 0;
  object-fit: cover;
  border-radius: 10px;
  background: #eceae6;
}

.actions {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}

label {
  display: block;
  margin-bottom: 20px;
  color: var(--ink);
  font-size: 0.875rem;
  font-weight: 600;
}

input, textarea, button { font: inherit; }

input, textarea {
  display: block;
  width: 100%;
  margin-top: 8px;
  padding: 12px 14px;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
}

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

input::placeholder, textarea::placeholder { color: #9c968e; }

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

button {
  min-height: 44px;
  padding: 0 18px;
  border: 0;
  border-radius: 10px;
  background: var(--ink);
  color: #fff;
  font-weight: 600;
  cursor: pointer;
}

button:hover { background: #2c2a27; }

button:disabled {
  opacity: 0.45;
  cursor: default;
}

#search {
  background: transparent;
  color: var(--ink);
  box-shadow: inset 0 0 0 1px var(--line-strong);
}

#search:hover { background: var(--surface); }

.ghost {
  min-height: 36px;
  padding: 0 10px;
  background: transparent;
  color: var(--muted);
  font-weight: 500;
  font-size: 0.85rem;
}

.ghost:hover {
  background: transparent;
  color: var(--ink);
}

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

.panel {
  padding: 0;
  border: 0;
  background: transparent;
}

.panel button[type="submit"] {
  min-width: 180px;
  margin-top: 4px;
}

.title-row {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  margin-bottom: 8px;
}

.title-row label {
  flex: 1;
  margin-bottom: 0;
}

.title-row button { flex-shrink: 0; }

.hint { margin: 0 0 20px; }

.picked {
  display: flex;
  align-items: center;
  gap: 14px;
  margin: 0 0 22px;
}

.picked[hidden] { display: none; }

.picked img {
  width: 72px;
  height: 108px;
  object-fit: cover;
  border-radius: 10px;
  background: #eceae6;
}

.picked-label {
  margin: 0;
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 600;
}

.picked strong {
  display: block;
  margin: 2px 0 4px;
  color: var(--ink);
}

dialog#picker {
  width: min(760px, calc(100vw - 32px));
  max-height: min(88vh, 860px);
  margin: auto;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--text);
}

dialog#picker::backdrop {
  background: rgba(22, 21, 19, 0.48);
}

.picker {
  max-height: min(88vh, 860px);
  overflow: auto;
  padding: 18px 18px 8px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--bg);
  box-shadow: 0 20px 50px rgba(22, 21, 19, 0.22);
}

.picker-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 4px;
}

.picker-head h2 { margin: 0; }

.covers {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 12px;
  margin: 0 0 16px;
}

.cover-pick {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 100%;
  min-height: 0;
  padding: 8px;
  border-radius: 12px;
  background: var(--surface);
  color: var(--text);
  font-weight: 500;
  font-size: 0.8rem;
  line-height: 1.35;
  text-align: left;
  box-shadow: inset 0 0 0 1px var(--line);
}

.cover-pick:hover {
  background: var(--surface);
  box-shadow: inset 0 0 0 1px var(--line-strong);
}

.cover-pick.selected {
  background: var(--surface);
  box-shadow: inset 0 0 0 2px var(--ink);
}

.cover-pick img,
.cover-missing {
  display: block;
  width: 100%;
  aspect-ratio: 2 / 3;
  object-fit: cover;
  border-radius: 8px;
  background: #eceae6;
}

.cover-title {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.cover-meta {
  color: var(--muted);
  font-size: 0.72rem;
}

.empty {
  margin: 12px 0 0;
  padding: 48px 12px;
  color: var(--muted);
  text-align: center;
}

.empty a { color: var(--accent); }

.notify {
  margin: 0 0 24px;
  padding: 18px 18px 14px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface);
}

.notify.open { border-color: #e7cfc8; }

.notify h2 { margin: 0 0 8px; }

.notify .lead { margin: 0 0 16px; color: var(--text); }

.only-two {
  margin: 0 0 16px;
  padding: 0;
  list-style: none;
}

.only-two li {
  margin: 0;
  padding: 8px 0;
  border-top: 1px solid var(--line);
  color: var(--text);
}

.only-two li:last-child { border-bottom: 1px solid var(--line); }

.notify .when {
  margin: 0 0 16px;
  color: var(--muted);
}

.notify .ghost { padding-left: 0; }

.notify-row {
  display: flex;
  align-items: flex-end;
  gap: 10px;
}

.notify-row label {
  flex: 1;
  margin: 0;
}

.notify-row button { flex-shrink: 0; }

.notify .status:empty { display: none; }

.status { min-height: 1.5em; margin: 12px 0 0; }

.status.error { color: var(--danger); }

@media (max-width: 640px) {
  .wrap {
    width: min(760px, calc(100% - 32px));
    padding-bottom: 72px;
  }

  .top {
    align-items: flex-start;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 28px;
  }

  .page-head { margin-bottom: 20px; }

  .toolbar { align-items: stretch; flex-direction: column; gap: 6px; }

  .card { gap: 12px; padding: 12px 14px; }

  .card-top { flex-wrap: wrap; }

  .actions { width: 100%; }

  .poster, .avatar { width: 48px; height: 70px; }

  .title-row, .notify-row { flex-wrap: wrap; }

  .title-row button,
  .notify-row button,
  .panel button[type="submit"] { width: 100%; }

  .notify { padding: 18px 16px 14px; }

  .covers { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
