:root {
  --bg: #f7f6f3;
  --surface: #ffffff;
  --surface-2: #f1efea;
  --text: #1d1d1b;
  --muted: #6b6a66;
  --line: #e4e1da;
  --accent: #2f6f5e;
  --accent-soft: #e3efeb;
  --accent-text: #ffffff;
  --good: #2e7d4f;
  --good-soft: #e5f3ea;
  --bad: #b3443a;
  --bad-soft: #f8e6e3;
  --warn: #9a6a12;
  --warn-soft: #fbf0d9;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.04), 0 4px 16px rgba(0, 0, 0, 0.04);
  --radius: 14px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141514;
    --surface: #1c1e1d;
    --surface-2: #242725;
    --text: #ecebe7;
    --muted: #9b9a95;
    --line: #2f3331;
    --accent: #6cbca4;
    --accent-soft: #1f3530;
    --accent-text: #0f1a17;
    --good: #74c79a;
    --good-soft: #1b2e23;
    --bad: #e88b80;
    --bad-soft: #3a2220;
    --warn: #e2b55e;
    --warn-soft: #362c17;
    --shadow: none;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Inter, sans-serif;
}
a { color: var(--accent); }
button, input, textarea, select { font: inherit; color: inherit; }

.wrap { max-width: 980px; margin: 0 auto; padding: 0 16px 80px; }

header.top {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 16px; max-width: 980px; margin: 0 auto;
}
.brand { font-weight: 700; letter-spacing: -0.01em; font-size: 18px; text-decoration: none; color: var(--text); }
.brand span { color: var(--accent); }
.spacer { flex: 1; }

.btn {
  border: 1px solid var(--line); background: var(--surface); border-radius: 10px;
  padding: 9px 14px; cursor: pointer; font-weight: 500; white-space: nowrap;
}
.btn:hover { border-color: var(--muted); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.btn.primary:disabled { opacity: 0.55; cursor: progress; }
.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn.small { padding: 5px 10px; font-size: 14px; border-radius: 8px; }

.panel {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 20px; margin-top: 16px;
}
.panel h2 { font-size: 15px; margin: 0 0 4px; letter-spacing: 0.01em; }
.hint { color: var(--muted); font-size: 14px; margin: 0 0 14px; }

.title-input {
  font-size: 28px; font-weight: 700; letter-spacing: -0.02em; border: none; background: transparent;
  width: 100%; padding: 4px 0; margin-top: 12px; outline: none;
}
.title-input:focus { border-bottom: 2px solid var(--accent); }
@media (max-width: 600px) { .title-input { font-size: 22px; } .name { font-size: 23px; } }

label.field { display: block; margin-bottom: 14px; }
label.field b { display: block; font-size: 14px; font-weight: 600; margin-bottom: 4px; }
label.field small { color: var(--muted); font-weight: 400; }
textarea, input[type=text], input[type=number], input[type=password] {
  width: 100%; border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px;
  background: var(--surface-2); outline: none;
}
textarea { min-height: 84px; resize: vertical; }
textarea:focus, input:focus { border-color: var(--accent); background: var(--surface); }

.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
@media (max-width: 700px) { .grid2 { grid-template-columns: 1fr; } }

.rules { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line);
  border-radius: 999px; padding: 6px 12px; background: var(--surface-2); font-size: 14px; cursor: pointer;
  user-select: none;
}
.chip.on { background: var(--accent-soft); border-color: var(--accent); color: var(--text); }
.chip.locked { cursor: default; }
.chip .x { color: var(--muted); }
.why-list { color: var(--muted); font-size: 13px; margin: 10px 0 0; padding-left: 18px; }
.inline { display: inline-flex; gap: 8px; align-items: center; }
.inline input { width: 120px; }
.inline input[type=number] { width: 70px; }

.actions { display: flex; gap: 12px; align-items: center; margin-top: 18px; flex-wrap: wrap; }
.progress { color: var(--muted); font-size: 14px; display: flex; align-items: center; gap: 8px; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); animation: pulse 1s infinite ease-in-out; }
@keyframes pulse { 50% { opacity: 0.25; } }
.error { color: var(--bad); font-size: 14px; }
.notice { background: var(--warn-soft); color: var(--text); border-radius: 10px; padding: 10px 14px; font-size: 14px; margin-top: 16px; }

.tabs { display: flex; gap: 4px; margin: 28px 0 4px; border-bottom: 1px solid var(--line); overflow-x: auto; }
.tab {
  border: none; background: none; padding: 10px 14px; cursor: pointer; color: var(--muted);
  border-bottom: 2px solid transparent; margin-bottom: -1px; font-weight: 600; white-space: nowrap;
}
.tab.on { color: var(--text); border-bottom-color: var(--accent); }

h3.section { font-size: 13px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); margin: 26px 0 10px; }
h3.section em { text-transform: none; letter-spacing: 0; font-style: normal; font-weight: 400; }

.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 420px), 1fr)); gap: 14px; }
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 18px; display: flex; flex-direction: column; gap: 10px; min-width: 0;
}
.card.liked { border-color: var(--accent); }
.card.disliked { opacity: 0.5; }
.card-head { display: flex; align-items: baseline; gap: 10px; }
.name { font-size: 26px; font-weight: 700; letter-spacing: -0.02em; line-height: 1.15; overflow-wrap: anywhere; }
.score { margin-left: auto; font-weight: 700; color: var(--accent); font-size: 15px; white-space: nowrap; }
.reason { color: var(--muted); font-size: 14px; margin: 0; }
.domains { display: flex; flex-wrap: wrap; gap: 6px; }
.dom {
  font-size: 13px; border-radius: 8px; padding: 4px 9px; border: 1px solid transparent;
  display: inline-flex; gap: 6px; align-items: baseline; text-decoration: none; color: var(--text);
}
.dom.free { background: var(--good-soft); }
.dom.free b { color: var(--good); }
.dom.taken { background: var(--surface-2); color: var(--muted); text-decoration: line-through; }
.dom.premium { background: var(--warn-soft); }
.dom.premium b { color: var(--warn); }
.dom.unknown { background: var(--surface-2); color: var(--muted); }
.dom .price { color: var(--muted); }
.flags { display: flex; flex-direction: column; gap: 6px; }
.flag { font-size: 13px; border-radius: 8px; padding: 6px 10px; }
.flag.red { background: var(--bad-soft); }
.flag.amber { background: var(--warn-soft); }
.flag.ok { color: var(--good); padding: 0; }
.flag a { color: inherit; }
.links { display: flex; flex-wrap: wrap; gap: 14px; font-size: 14px; }
.links a { text-decoration: none; }
.card-foot { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; border-top: 1px solid var(--line); padding-top: 10px; }
.checked { color: var(--muted); font-size: 13px; }
.checked button { border: none; background: none; color: var(--accent); cursor: pointer; padding: 0; font-size: 13px; }
.vote { border: 1px solid var(--line); background: var(--surface); border-radius: 999px; width: 36px; height: 36px; cursor: pointer; font-size: 16px; }
.vote.on.like { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.vote.on.dislike { background: var(--bad-soft); border-color: var(--bad); }
.foot-right { margin-left: auto; display: flex; gap: 8px; align-items: center; }

.project-list { display: grid; gap: 10px; margin-top: 16px; }
.project-row {
  display: flex; align-items: center; gap: 12px; padding: 16px 18px; background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--radius); text-decoration: none; color: var(--text);
}
.project-row:hover { border-color: var(--accent); }
.project-row small { color: var(--muted); }
.empty { color: var(--muted); text-align: center; padding: 40px 0; }

.history-row { padding: 12px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.history-row .names { color: var(--muted); }

details summary { cursor: pointer; font-weight: 600; list-style: none; }
details summary::-webkit-details-marker { display: none; }
details summary::before { content: "▸ "; color: var(--muted); }
details[open] summary::before { content: "▾ "; }

.login { max-width: 360px; margin: 12vh auto 0; }

/* ---- product page layout: names + chat ---- */
.layout { display: grid; grid-template-columns: minmax(0, 1fr); grid-template-areas: "top" "chat" "bottom"; }
.top-col { grid-area: top; min-width: 0; }
.bottom-col { grid-area: bottom; min-width: 0; }
.chat-col { grid-area: chat; }
@media (min-width: 1180px) {
  body:has(.layout) .wrap, body:has(.layout) header.top { max-width: 1340px; }
  .layout { grid-template-columns: minmax(0, 1fr) 380px; grid-template-areas: "top chat" "bottom chat"; column-gap: 24px; align-items: start; }
  .chat-col { position: sticky; top: 16px; max-height: calc(100vh - 32px); }
}

/* ---- chat ---- */
.chat-col { display: flex; flex-direction: column; gap: 12px; }
.chat-col h2 { margin: 0; }
.msgs { overflow-y: auto; display: flex; flex-direction: column; gap: 10px; min-height: 80px; max-height: 420px; padding-right: 2px; }
@media (min-width: 1180px) { .msgs { max-height: none; flex: 1; } }
.msg { display: flex; }
.msg.user { justify-content: flex-end; }
.bubble { max-width: 88%; padding: 9px 13px; border-radius: 14px; font-size: 14px; line-height: 1.45; white-space: pre-wrap; overflow-wrap: anywhere; }
.msg.user .bubble { background: var(--accent); color: var(--accent-text); border-bottom-right-radius: 4px; }
.msg.assistant .bubble { background: var(--surface-2); border-bottom-left-radius: 4px; }
.bubble.typing { color: var(--muted); display: inline-flex; gap: 8px; align-items: center; }
button.link { border: none; background: none; padding: 0; margin-top: 6px; color: var(--accent); cursor: pointer; font-weight: 600; font-size: 14px; }
.chat-empty p { color: var(--muted); font-size: 14px; margin: 0 0 10px; }
.chat-empty .chip { margin: 0 6px 8px 0; text-align: left; border-radius: 12px; }
.chat-form { display: flex; gap: 8px; align-items: flex-end; }
.chat-form textarea { min-height: 44px; max-height: 160px; resize: vertical; }
.chat-form textarea:disabled { opacity: 0.6; }
