:root {
  --brand: #c62f45;
  --brand-2: #d23f3f;
  --ink: #16131a;
  --muted: #5d5866;
  --line: #ebe7ee;
  --soft: #fff5f3;
  --bg: #faf8f9;
  --card: #fff;
  --ok: #1d7a43;
  --ok-bg: #eefaf2;
  --danger: #b42318;
  --danger-bg: #fef3f2;
  --radius: 16px;
  --side: 232px;
  --top: 60px;
  --tab: 64px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--ink);
  background: var(--bg);
  line-height: 1.5;
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--brand); }
img { max-width: 100%; }
h1 { font-size: 24px; letter-spacing: -0.02em; margin: 0; line-height: 1.2; }
h2 { font-size: 17px; letter-spacing: -0.01em; margin: 0 0 14px; }
p { margin: 0; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.stack { display: grid; gap: 16px; }
:focus-visible { outline: 3px solid var(--brand-2); outline-offset: 2px; }
button, summary, select, [role="switch"], label[for], a { cursor: pointer; }

.brand { display: inline-flex; align-items: center; gap: 10px; font-weight: 700; font-size: 19px; color: var(--ink); text-decoration: none; }
.ico { width: 20px; height: 20px; flex: none; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px 20px;
  border-radius: 999px;
  font: inherit;
  font-weight: 600;
  font-size: 15px;
  text-decoration: none;
  cursor: pointer;
  border: 1px solid transparent;
  transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
  list-style: none;
}
.btn::-webkit-details-marker { display: none; }
.btn:hover { transform: translateY(-1px); }
.btn:disabled { opacity: 0.6; cursor: default; transform: none; }
.btn-primary { color: #fff; background: linear-gradient(135deg, var(--brand-2), var(--brand)); box-shadow: 0 8px 24px rgba(235, 72, 92, 0.25); }
.btn-ghost { background: #fff; border-color: var(--line); color: var(--ink); }
.btn-ghost:hover { border-color: #d6d0db; }
.btn-danger { background: #fff; color: var(--danger); border-color: #f1c4bf; }
.btn-danger:hover { background: var(--danger-bg); }
.btn-danger.armed { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-sm { padding: 8px 14px; font-size: 14px; }
.btn-block { width: 100%; }

.shell { min-height: 100vh; }
.side { display: none; }
.main { min-width: 0; padding-bottom: var(--tab); }

.top {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 12px;
  height: var(--top);
  padding: 0 16px;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.brand-sm { font-size: 17px; }
.brand-sm img { width: 30px; height: 22px; }
.ws { margin-left: auto; text-align: right; line-height: 1.25; min-width: 0; }
.ws-label { display: none; font-size: 12px; color: var(--muted); }
.ws b { display: block; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 34vw; }

.content { padding: 20px 16px 32px; max-width: 980px; margin: 0 auto; display: grid; gap: 18px; align-content: start; }
.page-head { display: grid; gap: 4px; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; }
.card > h2:last-child { margin-bottom: 0; }
.section-title { margin: 6px 0 10px; }

.notice { padding: 12px 16px; border-radius: 12px; font-size: 14px; font-weight: 500; }
.notice-ok { background: var(--ok-bg); color: var(--ok); border: 1px solid #c9ecd6; }
.notice-err { background: var(--danger-bg); color: var(--danger); border: 1px solid #f9d0cb; }

.tabbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 30;
  height: var(--tab);
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  background: #fff;
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.tabbar a { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; text-decoration: none; color: var(--muted); font-size: 11px; font-weight: 600; }
.tabbar a.active { color: var(--brand); }

.field { display: grid; gap: 6px; font-size: 14px; font-weight: 600; }
.field small { font-weight: 400; font-size: 13px; }
input[type="text"], input[type="email"], input[type="password"], select, textarea {
  width: 100%;
  font: inherit;
  font-weight: 400;
  color: var(--ink);
  background: #fff;
  border: 1px solid #d6d0db;
  border-radius: 12px;
  padding: 11px 14px;
}
input[readonly] { background: #f6f3f7; color: var(--muted); }
textarea { resize: vertical; min-height: 44px; }
.composer-row textarea { resize: none; }
.card .field + .field { margin-top: 14px; }
.form-grid { grid-template-columns: 1fr; }
.form-grid .wide { grid-column: 1 / -1; }

.auth { min-height: 100vh; display: grid; align-content: center; justify-items: center; gap: 24px; padding: 24px 16px; background: radial-gradient(900px 420px at 80% -10%, #ffe6e1 0%, rgba(255, 230, 225, 0) 70%), var(--bg); }
.auth-card { width: 100%; max-width: 400px; background: #fff; border: 1px solid var(--line); border-radius: 22px; padding: 32px 28px; box-shadow: 0 24px 70px rgba(22, 19, 26, 0.08); display: grid; gap: 14px; }
.auth-brand { justify-self: center; font-size: 22px; margin-bottom: 8px; }
.auth-card h1 { text-align: center; font-size: 26px; }
.auth-card > .muted { text-align: center; margin-top: -8px; }
.legal { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px 22px; font-size: 14px; padding-top: 8px; }
.legal a { color: var(--muted); }
.legal a:hover { color: var(--ink); }

.channel { display: grid; gap: 18px; }
.channel-main { display: flex; align-items: center; gap: 16px; }
.channel-logo { width: 44px; height: 44px; flex: none; }
.channel-text h2 { margin: 0 0 2px; }
.channel-user { font-weight: 600; display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.channel-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 14px 22px; }
.pill { font-size: 12px; padding: 3px 10px; border-radius: 999px; background: var(--ok-bg); color: var(--ok); font-weight: 600; }
.pill-off { background: #f1eff3; color: var(--muted); }

.switch-row { display: inline-flex; align-items: center; gap: 10px; font-weight: 600; font-size: 14px; }
.switch { position: relative; width: 44px; height: 26px; border-radius: 999px; border: 0; padding: 0; background: #8a8491; transition: background 0.15s; flex: none; }
.switch i { position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; transition: transform 0.15s; }
.switch[aria-checked="true"] { background: var(--ok); }
.switch[aria-checked="true"] i { transform: translateX(18px); }

.badge { display: inline-block; font-size: 12px; font-weight: 600; padding: 2px 9px; border-radius: 999px; background: var(--ok-bg); color: var(--ok); white-space: nowrap; }
.badge-human { background: #eef0ff; color: #3b3fa8; }
.badge-muted { background: #f1eff3; color: var(--muted); }

.avatar { width: 40px; height: 40px; border-radius: 50%; flex: none; display: grid; place-items: center; background: linear-gradient(135deg, #feda75, #d62976 60%, #4f5bd5); color: #fff; font-weight: 700; overflow: hidden; }
.avatar img { width: 100%; height: 100%; object-fit: cover; }

.content-fill { max-width: none; padding: 0; gap: 0; }
.content-fill > .notice { margin: 12px 16px 0; }
.inbox { position: relative; height: calc(100dvh - var(--top) - var(--tab)); display: grid; grid-template-columns: 1fr; min-height: 0; }
.inbox .card { border-radius: 0; border-width: 0; padding: 0; display: flex; flex-direction: column; min-height: 0; overflow: hidden; }
.inbox[data-view="list"] .conv { display: none; }
.inbox[data-view="conv"] .inbox-list { display: none; }
.pane-head { display: flex; align-items: center; gap: 12px; padding: 14px 16px; border-bottom: 1px solid var(--line); min-height: 64px; }
.thread-list { overflow-y: auto; flex: 1; }
.thread { display: flex; gap: 12px; width: 100%; text-align: left; padding: 12px 16px; border: 0; border-bottom: 1px solid var(--line); background: #fff; font: inherit; color: inherit; cursor: pointer; }
.thread:hover { background: #faf8f9; }
.thread.active { background: var(--soft); }
.thread-body { min-width: 0; flex: 1; }
.thread-top { display: flex; align-items: baseline; gap: 8px; }
.thread-top b { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.thread-time { font-size: 12px; color: var(--muted); flex: none; }
.thread-last { display: flex; align-items: center; gap: 8px; margin-top: 2px; }
.thread-last span:first-child { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); font-size: 14px; }
.empty { padding: 36px 20px; text-align: center; display: grid; gap: 6px; align-content: center; justify-items: center; }
.conv-placeholder { flex: 1; }
.conv-open { display: flex; flex-direction: column; min-height: 0; flex: 1; }
.conv-head .btn { margin-left: auto; }
.conv-title { display: grid; gap: 2px; min-width: 0; justify-items: start; }
.conv-title b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }
.icon-btn { border: 0; background: transparent; padding: 6px; margin-left: -8px; border-radius: 50%; color: var(--ink); display: grid; place-items: center; cursor: pointer; }
.icon-btn:hover { background: #f1eff3; }
.messages { flex: 1; overflow-y: auto; padding: 18px 16px; display: flex; flex-direction: column; gap: 10px; background: #fcfbfc; }
.bubble { max-width: 82%; padding: 9px 14px; border-radius: 18px; font-size: 15px; line-height: 1.45; overflow-wrap: anywhere; white-space: pre-wrap; }
.bubble.in { align-self: flex-start; background: #f1eff3; border-bottom-left-radius: 6px; }
.bubble.out { align-self: flex-end; color: #fff; background: linear-gradient(135deg, var(--brand-2), var(--brand)); border-bottom-right-radius: 6px; }
.bubble img { border-radius: 12px; max-height: 260px; width: auto; }
.bubble img + span { display: block; margin-top: 6px; }
.bubble time { display: block; font-size: 11px; opacity: 0.75; margin-top: 3px; }
.composer { border-top: 1px solid var(--line); padding: 10px 16px 12px; display: grid; gap: 8px; background: #fff; }
.quick { display: flex; gap: 8px; flex-wrap: wrap; }
.chip { font: inherit; font-size: 13px; font-weight: 600; padding: 5px 12px; border-radius: 999px; border: 1px solid var(--line); background: #fff; color: var(--ink); cursor: pointer; }
.chip:hover { border-color: #d6d0db; background: var(--soft); }
.chip-static { cursor: default; font-weight: 500; background: var(--soft); border-color: transparent; color: var(--ink); }
.composer-row { display: flex; gap: 10px; align-items: flex-end; }
.composer-row textarea { max-height: 120px; border-radius: 18px; }
.hint { font-size: 12px; color: var(--muted); }
.toast { position: absolute; left: 16px; right: 16px; top: 72px; max-width: 520px; margin: 0 auto; z-index: 5; padding: 12px 16px; border-radius: 12px; background: var(--danger); color: #fff; font-size: 14px; font-weight: 500; }

.post { display: grid; gap: 14px; }
.post-head { display: flex; gap: 14px; align-items: center; }
.thumb { width: 64px; height: 64px; border-radius: 12px; object-fit: cover; flex: none; background: #f1eff3; }
.caption { font-weight: 600; overflow-wrap: anywhere; }
.comment-list { list-style: none; margin: 0; padding: 0; }
.comment { padding: 14px 0; border-top: 1px solid var(--line); display: grid; gap: 6px; }
.comment.is-hidden .comment-text { color: var(--muted); }
.comment-top { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.comment-text { overflow-wrap: anywhere; }
.reply { margin-left: 14px; padding: 6px 0 6px 14px; border-left: 3px solid var(--line); font-size: 14px; }
.comment-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: flex-start; margin-top: 4px; }
.comment-actions form { margin: 0; }
.reply-box[open] { flex-basis: 100%; order: 5; }
.reply-box[open] summary { margin-bottom: 8px; }
.reply-form { display: grid; gap: 8px; justify-items: start; max-width: 520px; }
.post-none { padding-top: 4px; }

.rules { list-style: none; margin: 0; padding: 0 20px; }
.rule { display: grid; gap: 12px; padding: 16px 0; border-top: 1px solid var(--line); }
.rule:first-child { border-top: 0; }
.rule-off .rule-main { opacity: 0.6; }
.rule-main { display: grid; gap: 8px; min-width: 0; }
.kw { display: flex; flex-wrap: wrap; gap: 6px; }
.rule-reply { color: var(--ink); overflow-wrap: anywhere; }
.rule-reply .small { display: block; }
.rule-actions { display: flex; align-items: center; gap: 18px; }

.privacy { list-style: none; margin: 0; padding: 0; counter-reset: p; }
.privacy li { display: grid; gap: 12px; padding: 16px 0; border-top: 1px solid var(--line); counter-increment: p; }
.privacy li:first-child { border-top: 0; padding-top: 0; }
.privacy li form, .privacy li > a { justify-self: start; }
.privacy b { display: block; }

@media (min-width: 900px) {
  .shell { display: grid; grid-template-columns: var(--side) 1fr; }
  .side { display: flex; flex-direction: column; gap: 22px; position: sticky; top: 0; height: 100vh; padding: 20px 14px; background: #fff; border-right: 1px solid var(--line); }
  .side .brand { padding: 4px 10px; }
  .side-nav { display: grid; gap: 4px; }
  .side-nav a { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 12px; text-decoration: none; color: var(--muted); font-weight: 600; }
  .side-nav a:hover { background: #f6f3f7; color: var(--ink); }
  .side-nav a.active { background: var(--soft); color: var(--brand); }
  .tabbar, .brand-sm { display: none; }
  .main { padding-bottom: 0; }
  .top { padding: 0 28px; background: #fff; }
  .ws { margin-left: 0; margin-right: auto; text-align: left; }
  .ws-label { display: block; }
  .ws b { max-width: 40vw; font-size: 15px; }
  .content { padding: 28px 28px 48px; }
  .content-fill { padding: 0; }
  .content-fill > .notice { margin: 16px 28px 0; }
  .form-grid { grid-template-columns: 1fr 1fr; }
  .rule { grid-template-columns: 1fr auto; align-items: center; gap: 24px; }
  .privacy li { grid-template-columns: 1fr auto; align-items: center; gap: 24px; }
  .privacy li form, .privacy li > a { justify-self: end; }
  .channel { grid-template-columns: 1fr auto; align-items: center; }
  .inbox { height: calc(100vh - var(--top)); grid-template-columns: 340px 1fr; }
  .inbox .card { border-width: 0 1px 0 0; }
  .inbox .conv { border-right: 0; }
  .inbox[data-view] .conv, .inbox[data-view] .inbox-list { display: flex; }
  #conv-back { display: none; }
}

@media (max-width: 899px) {
  .content-fill { max-width: none; }
  .conv-head { padding-left: 8px; }
  .composer-row textarea { font-size: 16px; }
  input, select, textarea { font-size: 16px; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
.auth-card > .auth-alt { margin-top: 4px; }
