:root {
  --bg: #f5f3ef;
  --surface: #fffdf9;
  --surface-2: #f0ede6;
  --line: #ded9cf;
  --text: #25231f;
  --muted: #777166;
  --accent: #1f6b58;
  --accent-2: #e3f1ec;
  --danger: #a83d3d;
  --shadow: 0 14px 40px rgba(51, 43, 28, .08);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background: radial-gradient(circle at top, #fffdf9 0, var(--bg) 42%, #efebe2 100%);
  color: var(--text);
  font: 15px/1.55 ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
button, input { font: inherit; }
button { cursor: pointer; }
button:disabled, input:disabled { opacity: .5; cursor: not-allowed; }
a { color: inherit; text-decoration: none; }

.site-header {
  position: sticky;
  top: 0;
  z-index: 10;
  border-bottom: 1px solid rgba(222, 217, 207, .9);
  background: rgba(255, 253, 249, .9);
  backdrop-filter: blur(16px);
}
.header-inner {
  max-width: 1180px;
  margin: 0 auto;
  min-height: 66px;
  padding: 0 22px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.brand { display: inline-flex; align-items: center; gap: 10px; font-weight: 800; letter-spacing: -.02em; }
.brand-mark {
  width: 34px; height: 34px; border-radius: 10px;
  display: grid; place-items: center;
  background: var(--text); color: white; font-weight: 900;
}
.quiet-link { color: var(--muted); font-size: 13px; }
.quiet-link:hover { color: var(--text); }

.page-shell { max-width: 1180px; margin: 0 auto; padding: 48px 22px 80px; display: grid; gap: 24px; }
.hero { display: flex; justify-content: space-between; align-items: end; gap: 24px; padding: 20px 4px 8px; }
.eyebrow, .section-kicker { margin: 0 0 7px; font-size: 11px; font-weight: 800; letter-spacing: .15em; color: var(--accent); }
.hero h1 { margin: 0; font-size: clamp(38px, 6vw, 70px); line-height: .98; letter-spacing: -.055em; }
.hero-copy { max-width: 640px; margin: 18px 0 0; color: var(--muted); font-size: 16px; }
.hero-note { padding: 11px 14px; border: 1px solid var(--line); border-radius: 999px; background: rgba(255,255,255,.55); color: var(--muted); white-space: nowrap; font-size: 12px; }

.card { background: rgba(255, 253, 249, .9); border: 1px solid var(--line); border-radius: 22px; box-shadow: var(--shadow); }
.identity { padding: 22px; display: grid; grid-template-columns: 1fr minmax(300px, 460px); gap: 20px; align-items: center; }
.identity h2, .section-heading h2, .chat-topline h2 { margin: 0; font-size: 28px; letter-spacing: -.03em; }
.muted { margin: 6px 0 0; color: var(--muted); }
.small { font-size: 12px; }
.identity-form, .room-form, .message-form { display: flex; gap: 9px; }
input {
  width: 100%; min-width: 0;
  padding: 13px 14px;
  color: var(--text);
  background: white;
  border: 1px solid var(--line);
  border-radius: 12px;
  outline: none;
  transition: border-color .15s ease, box-shadow .15s ease;
}
input:focus { border-color: #87ae9f; box-shadow: 0 0 0 4px rgba(31, 107, 88, .09); }
button {
  border: 0; border-radius: 12px; padding: 12px 16px;
  background: var(--accent); color: white; font-weight: 700;
}
.outline-button {
  background: transparent; color: var(--text); border: 1px solid var(--line); font-weight: 650;
}
.danger-button { background: var(--danger); }
.status { min-height: 22px; margin: 8px 0 0; color: var(--danger); font-size: 13px; }

.rooms-section { display: grid; gap: 14px; }
.section-heading { display: flex; align-items: end; justify-content: space-between; gap: 14px; padding: 4px; }
.room-create { padding: 20px; display: grid; gap: 9px; }
.room-create h3 { margin: 0; font-size: 19px; letter-spacing: -.02em; }
.room-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.room-card {
  display: flex; flex-direction: column; gap: 15px; text-align: left;
  padding: 18px; border: 1px solid var(--line); border-radius: 18px;
  background: rgba(255, 253, 249, .78); color: var(--text);
  transition: transform .15s ease, border-color .15s ease, background .15s ease;
}
.room-card:hover { transform: translateY(-2px); border-color: #b7b0a2; background: white; }
.room-card.selected { border-color: #74a595; box-shadow: 0 0 0 3px rgba(31, 107, 88, .08); }
.room-card-top { display: flex; justify-content: space-between; gap: 10px; }
.room-name { font-weight: 800; font-size: 18px; overflow-wrap: anywhere; }
.room-meta { color: var(--muted); font-size: 12px; }
.badge { display: inline-flex; align-items: center; padding: 5px 9px; border-radius: 999px; background: var(--accent-2); color: var(--accent); font-size: 11px; font-weight: 800; }
.badge.locked { background: #f0ece2; color: #6a6052; }
.empty { padding: 28px; text-align: center; color: var(--muted); }
.hidden { display: none !important; }

.chat-section { padding: 22px; }
.chat-topline { display: flex; align-items: start; justify-content: space-between; gap: 16px; }
.chat-actions { display: flex; gap: 8px; align-items: center; }
.messages {
  min-height: 360px; max-height: 58vh; overflow-y: auto;
  margin: 20px 0 12px; padding: 10px 4px;
  display: flex; flex-direction: column; gap: 10px;
}
.message-placeholder { margin: auto; text-align: center; color: var(--muted); }
.message-row { display: flex; gap: 10px; align-items: end; }
.message-row.mine { justify-content: flex-end; }
.message-card { max-width: min(760px, 84%); }
.message-meta { display: flex; align-items: baseline; gap: 8px; margin-bottom: 4px; }
.message-nickname { font-size: 12px; font-weight: 800; color: var(--accent); }
.message-time { font-size: 10px; color: #a39d91; }
.message-body {
  padding: 11px 13px; border: 1px solid var(--line); border-radius: 15px;
  background: white; white-space: pre-wrap; overflow-wrap: anywhere;
}
.mine .message-body { background: var(--accent-2); border-color: #c6e0d7; }
.message-tools { margin-top: 4px; display: flex; justify-content: flex-end; }
.message-tools button { padding: 3px 7px; background: transparent; color: var(--muted); font-size: 11px; }
.message-tools button:hover { color: var(--danger); }
.message-form { border-top: 1px solid var(--line); padding-top: 14px; }
.message-form input { flex: 1; }

.admin-shell { max-width: 1180px; margin: 0 auto; padding: 42px 22px 72px; display: grid; gap: 18px; }
.admin-card { padding: 20px; }
.admin-card h2 { margin: 0 0 12px; }
pre.log-box { margin: 12px 0 0; max-height: 480px; overflow: auto; padding: 14px; background: #201f1c; color: #ebe6db; border-radius: 14px; font-size: 12px; }
.admin-room { border-top: 1px solid var(--line); padding: 16px 0; }
.admin-room:first-child { border-top: 0; }
.admin-room-head { display: flex; justify-content: space-between; gap: 12px; align-items: start; }
.admin-message { display: flex; gap: 10px; justify-content: space-between; align-items: center; padding: 10px 0; border-top: 1px dashed var(--line); }
.admin-message-text { overflow-wrap: anywhere; }

@media (max-width: 900px) {
  .room-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .identity { grid-template-columns: 1fr; }
}

@media (max-width: 640px) {
  .page-shell { padding-top: 28px; }
  .hero { flex-direction: column; align-items: start; }
  .hero h1 { font-size: 43px; }
  .room-grid { grid-template-columns: 1fr; }
  .identity-form, .room-form, .message-form { flex-direction: column; }
  .chat-topline { flex-direction: column; }
  .chat-actions { width: 100%; justify-content: space-between; }
  .message-card { max-width: 94%; }
}
