:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --fg: #1d232b;
  --muted: #5b6573;
  --line: #dde1e7;
  --accent: #0f8a8a;
  --accent-fg: #ffffff;
  --user: #e8f3f3;
  --refer: #fff7e8;
  --error: #b3261e;
  --font: "Hiragino Sans", "Yu Gothic UI", "Meiryo", system-ui, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14181d;
    --surface: #1c2128;
    --fg: #e6e9ee;
    --muted: #9aa4b2;
    --line: #2e353f;
    --accent: #4fc1c1;
    --accent-fg: #0b1a1a;
    --user: #183232;
    --refer: #33291a;
    --error: #ff8a80;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }

/* form などに display を付けても、hidden を付けたものは出さない */
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.75;
}

.top, main {
  max-width: 760px;
  margin: 0 auto;
  padding: 0 16px;
}

.top {
  position: relative;
  padding-top: 24px;
  padding-bottom: 8px;
}

.name { margin: 0; font-size: 1.6rem; letter-spacing: 0.02em; }
.name .ai { color: var(--accent); }
.lead { margin: 4px 0 0; color: var(--muted); font-size: 0.9rem; }

.link {
  background: none;
  border: none;
  color: var(--accent);
  cursor: pointer;
  font: inherit;
  font-size: 0.9rem;
  padding: 4px 0;
  text-decoration: underline;
}

.top .link { position: absolute; top: 24px; right: 16px; }

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 20px 16px;
  margin: 16px 0 40px;
}

.card h2 { margin: 0 0 8px; font-size: 1.15rem; }
.hint { color: var(--muted); font-size: 0.85rem; margin: 4px 0; }
.status { color: var(--muted); padding: 24px 0; }

form { display: grid; gap: 8px; margin-top: 12px; }
label { font-weight: 600; font-size: 0.95rem; }

input, textarea {
  width: 100%;
  font: inherit;
  color: var(--fg);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px 12px;
}

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

.primary {
  justify-self: start;
  background: var(--accent);
  color: var(--accent-fg);
  border: none;
  border-radius: 6px;
  font: inherit;
  font-weight: 600;
  padding: 10px 20px;
  cursor: pointer;
}

button:disabled, input:disabled, textarea:disabled { opacity: 0.6; cursor: wait; }

.message { min-height: 1.5em; margin: 12px 0 0; }
.message.error { color: var(--error); }

.notice {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px 16px;
  font-size: 0.85rem;
  color: var(--muted);
  margin: 16px 0;
}

.log { list-style: none; padding: 0; margin: 0 0 16px; display: grid; gap: 12px; }

.entry {
  border-radius: 8px;
  padding: 12px 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  overflow-wrap: anywhere;
}

.entry .text { margin: 0; white-space: pre-wrap; }
.entry.user { background: var(--user); margin-left: 15%; }
.entry.refer { background: var(--refer); }
.entry.pending { color: var(--muted); }
.entry.error { color: var(--error); }
.topics { margin: 8px 0 0; font-size: 0.8rem; color: var(--muted); }

.ask {
  position: sticky;
  bottom: 0;
  background: var(--bg);
  padding: 8px 0 16px;
}

.ask-row { display: flex; justify-content: space-between; align-items: center; gap: 8px; }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

@media (max-width: 480px) {
  .name { font-size: 1.35rem; }
  .entry.user { margin-left: 8%; }
  .top .link { top: 20px; }
  .lead { padding-right: 72px; }
}
