:root {
  --bg: #f4f7fb;
  --bg-elevated: #ffffff;
  --bg-card: #ffffff;
  --border: #d7e0ec;
  --text: #1a2433;
  --text-muted: #66778c;
  --accent: #3b82f6;
  --accent-2: #6366f1;
  --accent-soft: rgba(59, 130, 246, 0.1);
  --danger: #e11d48;
  --success: #059669;
  --warn: #d97706;
  --radius: 14px;
  --shadow: 0 8px 28px rgba(26, 36, 51, 0.08);
  --font: "Hiragino Sans", "Noto Sans JP", "Segoe UI", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
}
body {
  background:
    radial-gradient(1100px 520px at 8% -12%, rgba(59, 130, 246, 0.14), transparent 55%),
    radial-gradient(900px 480px at 100% 0%, rgba(99, 102, 241, 0.1), transparent 50%),
    var(--bg);
}

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

.app-shell {
  max-width: 720px;
  margin: 0 auto;
  padding: 16px 14px 96px;
}

.header {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 16px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
}
.logo-mark {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: 13px;
  letter-spacing: -0.02em;
  color: white;
  flex-shrink: 0;
}
.brand h1 {
  margin: 0;
  font-size: 1.05rem;
  line-height: 1.35;
  font-weight: 700;
}
.brand .sub {
  margin: 2px 0 0;
  color: var(--text-muted);
  font-size: 0.78rem;
}

.notice {
  background: #fff7e8;
  border: 1px solid #f2d39a;
  color: #8a5a00;
  border-radius: 12px;
  padding: 10px 12px;
  font-size: 0.85rem;
  line-height: 1.45;
}

.tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin: 14px 0 12px;
  background: #eef3f9;
  padding: 6px;
  border-radius: 999px;
  border: 1px solid var(--border);
}
.tab-btn {
  border: none;
  background: transparent;
  color: var(--text-muted);
  padding: 10px 8px;
  border-radius: 999px;
  font-size: 0.92rem;
  font-weight: 600;
  cursor: pointer;
}
.tab-btn.active {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: white;
  box-shadow: var(--shadow);
}

.panel {
  display: none;
}
.panel.active { display: block; }

.feed {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 40vh;
}
.msg {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  box-shadow: 0 2px 10px rgba(26, 36, 51, 0.04);
  animation: fadeIn 0.25s ease;
}
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: none; }
}
.msg-meta {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
  font-size: 0.75rem;
  color: var(--text-muted);
}
.msg-name { font-weight: 700; color: #334155; }
.msg-text {
  white-space: pre-wrap;
  word-break: break-word;
  line-height: 1.5;
  font-size: 0.95rem;
}
.msg.tweet .msg-text {
  font-size: 1.02rem;
}
.reply-box {
  margin-top: 10px;
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--accent-soft);
  border: 1px solid rgba(59, 130, 246, 0.22);
}
.reply-box .label {
  font-size: 0.72rem;
  color: var(--accent);
  font-weight: 700;
  margin-bottom: 4px;
}
.empty {
  text-align: center;
  color: var(--text-muted);
  padding: 40px 12px;
  font-size: 0.9rem;
}

.composer {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 10px 14px calc(12px + env(safe-area-inset-bottom));
  background: rgba(244, 247, 251, 0.92);
  backdrop-filter: blur(12px);
  border-top: 1px solid var(--border);
}
.composer-inner {
  max-width: 720px;
  margin: 0 auto;
  display: flex;
  gap: 8px;
  align-items: flex-end;
}
.composer textarea {
  flex: 1;
  resize: none;
  min-height: 44px;
  max-height: 120px;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text);
  font: inherit;
  font-size: 0.95rem;
  line-height: 1.4;
}
.composer textarea:focus {
  outline: 2px solid rgba(59, 130, 246, 0.35);
  border-color: var(--accent);
}
.composer .send {
  border: none;
  border-radius: 12px;
  padding: 0 16px;
  min-height: 44px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: white;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
}
.composer .send:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}
.char-count {
  max-width: 720px;
  margin: 4px auto 0;
  font-size: 0.72rem;
  color: var(--text-muted);
  text-align: right;
}
.char-count.warn { color: var(--warn); }
.char-count.over { color: var(--danger); }

/* Gate overlay */
.gate {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(232, 238, 247, 0.82);
  backdrop-filter: blur(10px);
  display: grid;
  place-items: center;
  padding: 20px;
}
.gate.hidden { display: none; }
.gate-card {
  width: 100%;
  max-width: 420px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 22px 18px;
  box-shadow: var(--shadow);
}
.gate-card h2 {
  margin: 0 0 8px;
  font-size: 1.15rem;
}
.gate-card p {
  margin: 0 0 16px;
  color: var(--text-muted);
  font-size: 0.88rem;
  line-height: 1.5;
}
label {
  display: block;
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 6px;
  font-weight: 600;
}
input[type="text"],
input[type="password"],
textarea.field {
  width: 100%;
  padding: 11px 12px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: #f8fafc;
  color: var(--text);
  font: inherit;
  margin-bottom: 12px;
}
input:focus, textarea.field:focus {
  outline: 2px solid rgba(59, 130, 246, 0.35);
  border-color: var(--accent);
}
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  border: none;
  border-radius: 12px;
  padding: 12px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: white;
  font-weight: 700;
  font-size: 0.95rem;
  cursor: pointer;
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn.secondary {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
}
.error {
  color: var(--danger);
  font-size: 0.85rem;
  margin: 0 0 10px;
  min-height: 1.2em;
}
.hint {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 10px;
  line-height: 1.4;
}
.user-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.78rem;
  color: var(--text-muted);
}
.user-chip strong { color: var(--text); }

/* Staff */
.staff-shell { max-width: 800px; margin: 0 auto; padding: 16px 14px 40px; }
.staff-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 16px;
}
.staff-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.staff-actions .btn {
  width: auto;
  padding: 8px 14px;
  font-size: 0.85rem;
}
.q-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 12px;
  box-shadow: 0 2px 10px rgba(26, 36, 51, 0.04);
}
.q-card .reply-form {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 10px;
}
.q-card textarea {
  width: 100%;
  min-height: 72px;
  resize: vertical;
  padding: 10px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: #f8fafc;
  color: var(--text);
  font: inherit;
}
.badge {
  display: inline-block;
  font-size: 0.7rem;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(5, 150, 105, 0.12);
  color: var(--success);
  font-weight: 700;
}
.badge.pending {
  background: rgba(217, 119, 6, 0.12);
  color: var(--warn);
}

@media (min-width: 640px) {
  .app-shell { padding-top: 24px; }
  .brand h1 { font-size: 1.2rem; }
}
