:root {
  --accent: #5B4FE8;
  --accent-dark: #4038B0;
  --bg: #F6F5FB;
  --card: #FFFFFF;
  --text: #1E1B2E;
  --muted: #78748F;
  --border: #E6E4F2;
  --success: #1FA971;
  --danger: #E4483B;
  --coach-bubble: #EDEBFB;
  --asker-bubble: #5B4FE8;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  padding-bottom: 76px; /* room for bottom nav */
}

a { color: inherit; text-decoration: none; }

.container { max-width: 640px; margin: 0 auto; padding: 16px; }

.topbar {
  position: sticky; top: 0; z-index: 10;
  background: var(--card);
  border-bottom: 1px solid var(--border);
  padding: 14px 16px;
  display: flex; align-items: center; gap: 10px;
}
.topbar .back { font-size: 20px; }
.topbar h1 { font-size: 17px; margin: 0; flex: 1; }
.topbar .balance {
  font-size: 13px; font-weight: 600; color: var(--accent);
  background: var(--coach-bubble); padding: 4px 10px; border-radius: 999px;
}

.bottom-nav {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 20;
  background: var(--card); border-top: 1px solid var(--border);
  display: flex; justify-content: space-around; padding: 8px 0 max(8px, env(safe-area-inset-bottom));
}
.bottom-nav a {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  font-size: 11px; color: var(--muted); padding: 4px 12px;
}
.bottom-nav a.active { color: var(--accent); font-weight: 600; }
.bottom-nav .icon { font-size: 20px; }

.category-block { margin-bottom: 24px; }
.category-title { font-size: 15px; font-weight: 700; margin: 0 0 10px; display: flex; align-items: center; gap: 8px; }
.room-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.room-card {
  background: var(--card); border: 1px solid var(--border); border-radius: 14px;
  padding: 14px; display: flex; flex-direction: column; gap: 6px;
}
.room-card .icon { font-size: 26px; }
.room-card .name { font-weight: 600; font-size: 14px; }
.room-card .desc { font-size: 12px; color: var(--muted); }

.thread-list { display: flex; flex-direction: column; gap: 10px; margin-top: 12px; }
.thread-card {
  background: var(--card); border: 1px solid var(--border); border-radius: 12px;
  padding: 12px 14px; display: flex; flex-direction: column; gap: 6px;
}
.thread-card .title { font-weight: 600; font-size: 14px; }
.thread-card .meta { font-size: 12px; color: var(--muted); display: flex; gap: 8px; align-items: center; }
.pill { font-size: 11px; font-weight: 700; padding: 2px 9px; border-radius: 999px; }
.pill.open { background: #FFF1D6; color: #9A6B00; }
.pill.resolved { background: #DFF6EA; color: var(--success); }

.fab {
  position: fixed; bottom: 88px; right: 20px; z-index: 15;
  background: var(--accent); color: white; border: none; border-radius: 999px;
  padding: 14px 22px; font-weight: 700; font-size: 14px; box-shadow: 0 6px 18px rgba(91,79,232,.4);
}

.card { background: var(--card); border: 1px solid var(--border); border-radius: 14px; padding: 18px; }

label { display: block; font-size: 13px; font-weight: 600; margin: 14px 0 6px; }
input[type=text], input[type=tel], input[type=password], input[type=number], textarea, select {
  width: 100%; padding: 13px 14px; border-radius: 10px; border: 1px solid var(--border);
  font-size: 15px; background: #fff; color: var(--text);
}
textarea { min-height: 90px; resize: vertical; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  width: 100%; padding: 14px; border-radius: 12px; border: none;
  font-size: 15px; font-weight: 700; cursor: pointer; margin-top: 14px;
}
.btn-primary { background: var(--accent); color: white; }
.btn-primary:active { background: var(--accent-dark); }
.btn-secondary { background: var(--coach-bubble); color: var(--accent-dark); }
.btn-danger { background: #FBE4E1; color: var(--danger); }
.btn-sm { width: auto; padding: 8px 16px; font-size: 13px; margin-top: 0; }

.error-box { background: #FBE4E1; color: var(--danger); padding: 12px 14px; border-radius: 10px; font-size: 13px; margin-bottom: 12px; }
.info-box { background: var(--coach-bubble); color: var(--accent-dark); padding: 12px 14px; border-radius: 10px; font-size: 13px; margin-bottom: 12px; }
.success-box { background: #DFF6EA; color: var(--success); padding: 12px 14px; border-radius: 10px; font-size: 13px; margin-bottom: 12px; }

.type-tabs { display: flex; gap: 8px; margin-top: 10px; }
.type-tab {
  flex: 1; text-align: center; padding: 10px; border-radius: 10px; border: 1px solid var(--border);
  font-size: 13px; font-weight: 600; color: var(--muted); background: #fff; cursor: pointer;
}
.type-tab.active { border-color: var(--accent); color: var(--accent); background: var(--coach-bubble); }
.type-tab .cost { display: block; font-size: 11px; font-weight: 400; margin-top: 2px; }

.coach-list { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; }
.coach-check {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px;
  border: 1px solid var(--border); border-radius: 10px; background: #fff;
}
.coach-check input { width: auto; }

.recorder-box { text-align: center; padding: 20px 10px; }
.record-btn {
  width: 84px; height: 84px; border-radius: 50%; border: none;
  background: var(--danger); color: white; font-size: 30px;
  display: inline-flex; align-items: center; justify-content: center;
  box-shadow: 0 4px 14px rgba(228,72,59,.4);
}
.record-btn.recording { animation: pulse 1.2s infinite; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(228,72,59,.5); } 70% { box-shadow: 0 0 0 18px rgba(228,72,59,0); } 100% { box-shadow: 0 0 0 0 rgba(228,72,59,0); } }
.record-timer { margin-top: 10px; font-size: 14px; font-weight: 700; color: var(--muted); }
.record-hint { font-size: 12px; color: var(--muted); margin-top: 6px; }
video.preview, audio.preview { width: 100%; margin-top: 12px; border-radius: 10px; }

.messages { display: flex; flex-direction: column; gap: 12px; margin: 16px 0; }
.msg { max-width: 82%; padding: 10px 14px; border-radius: 14px; font-size: 14px; }
.msg .sender { font-size: 11px; font-weight: 700; margin-bottom: 3px; opacity: .75; }
.msg.from-asker { align-self: flex-end; background: var(--asker-bubble); color: white; border-bottom-right-radius: 4px; }
.msg.from-coach { align-self: flex-start; background: var(--coach-bubble); color: var(--text); border-bottom-left-radius: 4px; }
.msg audio, .msg video { width: 100%; margin-top: 6px; border-radius: 8px; }
.msg .cost-tag { font-size: 10px; opacity: .7; margin-top: 4px; }

.composer { margin-top: 18px; }
.resolve-box { margin-top: 24px; padding: 16px; background: var(--coach-bubble); border-radius: 14px; }
.resolve-box h3 { margin: 0 0 8px; font-size: 14px; }

.preset-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-top: 8px; }
.preset-btn {
  padding: 12px 4px; text-align: center; border-radius: 10px; border: 1px solid var(--border);
  background: #fff; font-weight: 700; font-size: 13px; cursor: pointer;
}
.preset-btn.selected { border-color: var(--accent); background: var(--coach-bubble); color: var(--accent-dark); }

.wallet-balance { text-align: center; padding: 22px 0; }
.wallet-balance .num { font-size: 40px; font-weight: 800; color: var(--accent); }
.wallet-balance .label { font-size: 13px; color: var(--muted); }

.history-row { display: flex; justify-content: space-between; padding: 10px 0; border-bottom: 1px solid var(--border); font-size: 13px; }
.history-row .note { color: var(--muted); }
.history-row .amt.pos { color: var(--success); font-weight: 700; }
.history-row .amt.neg { color: var(--danger); font-weight: 700; }

table.admin-table { width: 100%; border-collapse: collapse; font-size: 13px; margin-top: 10px; }
table.admin-table th, table.admin-table td { text-align: left; padding: 8px; border-bottom: 1px solid var(--border); }
