:root {
  color-scheme: light dark;
  --bg: #f5f5f4;
  --panel: #ffffff;
  --panel-2: #fafaf9;
  --border: #e2e2df;
  --text: #1c1c1a;
  --muted: #6b6b68;
  --faint: #9c9c98;
  --accent: #3a6ff0;
  --accent-ink: #ffffff;
  --err: #d13c3c;
  --twitch: #9146ff;
  --youtube: #ff0000;
  --guest: #4b8f8c;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

  --sp-1: 0.25rem;
  --sp-2: 0.5rem;
  --sp-3: 0.75rem;
  --sp-4: 1rem;
  --sp-5: 1.5rem;
  --sp-6: 2rem;
  --sp-7: 3rem;

  --text-xs: 0.75rem;
  --text-sm: 0.8125rem;
  --text-base: 0.9375rem;
  --text-md: 1.0625rem;
  --text-lg: 1.3125rem;

  --radius: 10px;
  --radius-sm: 7px;
  --ease: 180ms cubic-bezier(0.4, 0, 0.2, 1);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #17181a;
    --panel: #212226;
    --panel-2: #1b1c1e;
    --border: #34363b;
    --text: #ececea;
    --muted: #9a9a9c;
    --faint: #6c6c70;
    --accent: #6f9bff;
    --accent-ink: #0d1220;
    --err: #ff6b6b;
    --twitch: #a970ff;
    --youtube: #ff4d4d;
    --guest: #6fb8b4;
  }
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: var(--text-base);
  line-height: 1.5;
  background: var(--bg);
  color: var(--text);
}

.wrap,
.chat-wrap {
  max-width: 720px;
  margin: 0 auto;
  padding: var(--sp-6) var(--sp-4) var(--sp-7);
}

header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--sp-6);
}

h1 {
  font-size: var(--text-lg);
  font-weight: 700;
  letter-spacing: -0.01em;
  margin: 0;
}

#whoami {
  font-size: var(--text-sm);
  color: var(--muted);
}

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--sp-5);
  margin-bottom: var(--sp-5);
}

.card h2 {
  font-size: var(--text-xs);
  font-weight: 700;
  margin: 0 0 var(--sp-4);
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.field {
  margin-bottom: var(--sp-4);
}

.field label {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  font-size: var(--text-sm);
  color: var(--muted);
  margin-bottom: var(--sp-2);
}

.dest-icon,
.platform-icon {
  width: 1.05rem;
  height: 1.05rem;
  flex-shrink: 0;
  display: block;
}

.setting-hint {
  color: var(--muted);
  font-size: var(--text-xs);
  margin-top: var(--sp-1);
  line-height: 1.55;
}

.link-row {
  display: flex;
  gap: var(--sp-2);
}

.link-row input {
  flex: 1;
}

input[type="text"],
input[type="password"] {
  width: 100%;
  padding: 0.55rem 0.7rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-family: var(--mono);
  font-size: var(--text-sm);
}

input[type="text"]:focus-visible,
input[type="password"]:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

button {
  font: inherit;
  font-size: var(--text-sm);
  cursor: pointer;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text);
  padding: 0.55rem 0.9rem;
  transition: border-color var(--ease), background var(--ease);
}

button:hover {
  border-color: var(--accent);
}

button.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
  font-weight: 600;
}

button.primary:hover {
  opacity: 0.9;
}

.actions {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  margin-top: var(--sp-5);
}

.save-msg {
  font-size: var(--text-sm);
  color: var(--muted);
}

.login-wrap {
  max-width: 320px;
  margin: 4rem auto;
  padding: 0 var(--sp-4);
}

.login-wrap .card {
  margin-bottom: 0;
}

.error {
  color: var(--err);
  font-size: var(--text-sm);
  margin-bottom: var(--sp-4);
}

.logout-form {
  display: inline;
}

/* Chat page */

#claim-form,
#send-form {
  display: flex;
  gap: var(--sp-2);
}

#claim-form .field {
  flex: 1;
  margin-bottom: 0;
}

.feed {
  height: 360px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--panel-2);
  padding: var(--sp-3);
  margin-bottom: var(--sp-4);
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
}

.chat-line {
  display: flex;
  align-items: flex-start;
  gap: var(--sp-2);
  font-size: var(--text-sm);
  line-height: 1.45;
}

.chat-line .platform-icon {
  margin-top: 0.15rem;
}

.chat-line .username {
  font-weight: 600;
  flex-shrink: 0;
}

.chat-line .text {
  overflow-wrap: anywhere;
}

#send-form input {
  flex: 1;
}
