:root {
  --bg: #f4f3ef;
  --surface: #ffffff;
  --surface-2: #ebe9e3;
  --line: #d8d4cb;
  --ink: #1a1815;
  --ink-soft: #5e574e;
  --ink-muted: #8a8378;
  --accent: #c2541f;
  --accent-soft: #f3d8c7;
  --kakao: #fee500;
  --kakao-ink: #2b1e00;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.04), 0 4px 12px rgba(0, 0, 0, 0.04);
  font-family:
    -apple-system, BlinkMacSystemFont, "Pretendard", "Noto Sans KR",
    "Segoe UI", Roboto, sans-serif;
}

* {
  box-sizing: border-box;
}
html,
body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

button {
  font: inherit;
  cursor: pointer;
}

a {
  color: var(--accent);
  text-decoration: none;
}
a:hover {
  text-decoration: underline;
}

input,
textarea,
select {
  font: inherit;
  color: inherit;
}

/* ---------- 비번 게이트 ---------- */

.gate {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 24px;
}
.gate-card {
  width: 100%;
  max-width: 360px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 28px 24px;
  box-shadow: var(--shadow);
}
.gate-card h1 {
  font-size: 18px;
  font-weight: 600;
  margin: 0 0 4px;
  letter-spacing: -0.01em;
}
.gate-card p {
  font-size: 13px;
  color: var(--ink-muted);
  margin: 0 0 20px;
}
.gate-card form {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.gate-card input[type="password"] {
  height: 44px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--bg);
  outline: none;
  transition: border-color 0.15s;
}
.gate-card input[type="password"]:focus {
  border-color: var(--accent);
}
.gate-card button[type="submit"] {
  height: 44px;
  border: none;
  border-radius: var(--radius-sm);
  background: var(--ink);
  color: white;
  font-weight: 600;
}
.gate-card button[type="submit"]:disabled {
  opacity: 0.6;
}
.gate-card .error {
  color: #b03a1a;
  font-size: 13px;
  margin-top: 8px;
  min-height: 18px;
}

/* ---------- 앱 셸 ---------- */

.shell {
  max-width: 760px;
  margin: 0 auto;
  padding: 24px 20px 80px;
}
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}
.topbar h1 {
  font-size: 16px;
  font-weight: 600;
  margin: 0;
  letter-spacing: -0.01em;
}
.topbar .meta {
  display: flex;
  gap: 12px;
  align-items: center;
  font-size: 13px;
  color: var(--ink-muted);
}
.topbar .meta a,
.topbar .meta button.linklike {
  color: var(--ink-muted);
  background: none;
  border: none;
  padding: 0;
  font-size: 13px;
}
.topbar .meta a:hover,
.topbar .meta button.linklike:hover {
  color: var(--ink);
  text-decoration: underline;
}

.tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 20px;
}
.tab {
  padding: 10px 14px;
  border: none;
  background: none;
  color: var(--ink-muted);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  font-weight: 500;
}
.tab[aria-selected="true"] {
  color: var(--ink);
  border-bottom-color: var(--ink);
}

.panel {
  display: none;
}
.panel[data-active="true"] {
  display: block;
}

/* ---------- 말풍선 (고민/댓글) ---------- */

.bubble-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.bubble {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
  box-shadow: var(--shadow);
}
.bubble-head {
  display: flex;
  gap: 8px;
  align-items: baseline;
  margin-bottom: 6px;
  font-size: 13px;
}
.bubble-head .name {
  font-weight: 600;
  color: var(--ink);
}
.bubble-head .time {
  color: var(--ink-muted);
  font-size: 12px;
}
.bubble-body {
  white-space: pre-wrap;
  word-break: break-word;
}

/* ---------- 케이스 리스트 ---------- */

.case-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.case-item {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 14px 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  cursor: pointer;
  transition: border-color 0.15s, transform 0.05s;
}
.case-item:hover {
  border-color: var(--ink-muted);
}
.case-item:active {
  transform: scale(0.998);
}
.case-item .date {
  font-size: 12px;
  color: var(--ink-muted);
  white-space: nowrap;
}
.case-item .title {
  font-weight: 500;
}

/* ---------- 카톡 스타일 채팅 ---------- */

.chat-bg {
  background: #b2c7d9;
  margin: -24px -20px 0;
  padding: 16px 14px 80px;
  min-height: calc(100dvh - 80px);
}
.chat-head {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.08);
}
.chat-head button.back {
  background: none;
  border: none;
  font-size: 18px;
  color: var(--ink);
}
.chat-head .case-title {
  font-weight: 600;
}
.chat-head .case-date {
  font-size: 12px;
  color: var(--ink-soft);
  margin-left: auto;
}
.chat-stream {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.chat-row {
  display: flex;
  gap: 6px;
  align-items: flex-end;
  max-width: 80%;
}
.chat-row.client {
  align-self: flex-start;
}
.chat-row.me {
  align-self: flex-end;
  flex-direction: row-reverse;
}
.chat-msg {
  padding: 8px 11px;
  border-radius: 12px;
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 14.5px;
  line-height: 1.45;
}
.chat-row.client .chat-msg {
  background: var(--surface);
  color: var(--ink);
  border-top-left-radius: 4px;
}
.chat-row.me .chat-msg {
  background: var(--kakao);
  color: var(--kakao-ink);
  border-top-right-radius: 4px;
}
.chat-time {
  font-size: 10.5px;
  color: rgba(0, 0, 0, 0.45);
  margin-bottom: 2px;
}
.day-divider {
  align-self: center;
  background: rgba(0, 0, 0, 0.08);
  color: rgba(0, 0, 0, 0.55);
  font-size: 11px;
  padding: 3px 10px;
  border-radius: 999px;
  margin: 10px 0;
}

/* ---------- 어드민 폼 ---------- */

.admin-grid {
  display: grid;
  gap: 24px;
}
.admin-section {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
}
.admin-section h2 {
  font-size: 14px;
  font-weight: 600;
  margin: 0 0 12px;
  letter-spacing: -0.01em;
}
.admin-section .helper {
  font-size: 12px;
  color: var(--ink-muted);
  margin: 0 0 14px;
}
.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 10px;
}
.field label {
  font-size: 12px;
  color: var(--ink-soft);
}
.field input,
.field select,
.field textarea {
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--bg);
  outline: none;
  transition: border-color 0.15s;
}
.field input:focus,
.field select:focus,
.field textarea:focus {
  border-color: var(--accent);
}
.field textarea {
  min-height: 90px;
  resize: vertical;
  font-family: inherit;
}
.row {
  display: flex;
  gap: 10px;
}
.row .field {
  flex: 1;
}
.btn {
  appearance: none;
  border: 1px solid var(--ink);
  background: var(--ink);
  color: white;
  border-radius: var(--radius-sm);
  padding: 9px 18px;
  font-weight: 600;
}
.btn.ghost {
  background: transparent;
  color: var(--ink);
}
.btn.danger {
  background: #b03a1a;
  border-color: #b03a1a;
}
.btn:disabled {
  opacity: 0.55;
}
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--ink);
  color: white;
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s, transform 0.18s;
}
.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.empty {
  text-align: center;
  color: var(--ink-muted);
  font-size: 13px;
  padding: 40px 20px;
  border: 1px dashed var(--line);
  border-radius: var(--radius);
}

.delete-btn {
  background: none;
  border: none;
  color: var(--ink-muted);
  font-size: 12px;
  margin-left: auto;
}
.delete-btn:hover {
  color: #b03a1a;
}
.bubble-actions {
  display: flex;
  margin-top: 6px;
}
