/* HarmReduce — dark utility theme */

* { box-sizing: border-box; }

:root {
  --bg: #16161c;
  --bg-elev: #1f1f28;
  --bg-elev-2: #262633;
  --border: #2e2e3c;
  --text: #e4e4ec;
  --muted: #8d8da0;
  --accent: #a78bfa;        /* violet */
  --accent-dim: #6d5cb5;
  --good: #6dd3a3;
  --warn: #f0b956;
  --bad: #f08585;
  --danger: #ef4d4d;
  --radius: 10px;
  --radius-sm: 6px;
}

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  font-family: -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
}

#app {
  display: grid;
  grid-template-columns: 220px 1fr;
  height: 100vh;
  overflow: hidden;
}

/* --- sidebar --- */
#sidebar {
  background: var(--bg-elev);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 18px 12px 12px;
}

.brand {
  font-size: 18px;
  margin: 0 6px 18px;
  letter-spacing: 0.5px;
  color: var(--accent);
  font-weight: 600;
}

#nav { display: flex; flex-direction: column; gap: 2px; flex: 1; overflow-y: auto; }

#nav button {
  text-align: left;
  background: transparent;
  border: 0;
  color: var(--text);
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 13.5px;
  display: flex;
  align-items: center;
  gap: 9px;
  transition: background-color 0.12s;
}

#nav button:hover { background: var(--bg-elev-2); }
#nav button.active {
  background: rgba(167, 139, 250, 0.16);
  color: var(--accent);
}
#nav .icon {
  font-size: 14px;
  width: 18px;
  display: inline-block;
  text-align: center;
  color: var(--muted);
}
#nav button.active .icon { color: var(--accent); }

.sidebar-footer {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
  font-size: 11.5px;
  color: var(--muted);
}

/* --- main --- */
#main { display: flex; flex-direction: column; overflow: hidden; }

.topbar {
  padding: 18px 26px 14px;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
}

#view-title { margin: 0; font-size: 20px; font-weight: 600; }
#view-subtitle { margin: 3px 0 0; font-size: 13px; }

.disclaimer {
  margin: 0;
  font-size: 11.5px;
  color: var(--muted);
  text-align: right;
  max-width: 280px;
  line-height: 1.4;
}

#view {
  padding: 22px 26px;
  overflow-y: auto;
  flex: 1;
}

.muted { color: var(--muted); }

/* --- card / form primitives --- */
.card {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 16px;
}

.card h3 { margin: 0 0 12px; font-size: 15px; font-weight: 600; }
.card p.help { margin: 0 0 14px; font-size: 12.5px; color: var(--muted); }

.row { display: flex; gap: 12px; flex-wrap: wrap; }
.row > * { flex: 1; min-width: 140px; }

label {
  display: block;
  font-size: 12px;
  color: var(--muted);
  margin: 0 0 4px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

input, select, textarea {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  font: inherit;
  font-size: 13.5px;
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
}

textarea { resize: vertical; min-height: 90px; }

.field { margin-bottom: 12px; }

button.primary, button.secondary, button.danger {
  border: 0;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-weight: 500;
  font-size: 13px;
}

button.primary {
  background: var(--accent);
  color: #16161c;
}
button.primary:hover { background: #b8a0ff; }

button.secondary {
  background: var(--bg-elev-2);
  color: var(--text);
}
button.secondary:hover { background: #313143; }

button.danger {
  background: transparent;
  color: var(--bad);
  border: 1px solid transparent;
}
button.danger:hover { background: rgba(240, 133, 133, 0.1); }

.actions { display: flex; gap: 8px; margin-top: 6px; }

/* --- list / table --- */
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
th, td {
  padding: 9px 10px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: top;
}
th { color: var(--muted); font-weight: 500; font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.4px; }
tr:last-child td { border-bottom: 0; }

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

/* --- badges / pills --- */
.pill {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 500;
  background: var(--bg-elev-2);
  color: var(--muted);
}
.pill.good { background: rgba(109, 211, 163, 0.15); color: var(--good); }
.pill.warn { background: rgba(240, 185, 86, 0.15); color: var(--warn); }
.pill.bad { background: rgba(240, 133, 133, 0.15); color: var(--bad); }
.pill.danger { background: rgba(239, 77, 77, 0.18); color: #ff7a7a; }
.pill.todo { background: rgba(167, 139, 250, 0.12); color: var(--accent); }

/* --- result panes --- */
.result {
  background: var(--bg-elev-2);
  border-left: 3px solid var(--accent);
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  margin-top: 10px;
  font-size: 13px;
}

.placeholder-banner {
  border: 1px dashed var(--accent-dim);
  background: rgba(167, 139, 250, 0.06);
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 14px;
}

.placeholder-banner h3 { margin: 0 0 6px; color: var(--accent); font-size: 14px; }
.placeholder-banner ul { margin: 8px 0 0 18px; padding: 0; }
.placeholder-banner li { margin: 2px 0; }

/* --- library view --- */
.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.chip {
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--muted);
  padding: 4px 10px;
  border-radius: 999px;
  cursor: pointer;
  font-size: 11.5px;
  letter-spacing: 0.2px;
  text-transform: lowercase;
}
.chip:hover { color: var(--text); border-color: var(--accent-dim); }
.chip.active {
  background: rgba(167, 139, 250, 0.16);
  border-color: var(--accent);
  color: var(--accent);
}

.library-item {
  border: 1px solid var(--border);
  background: var(--bg-elev);
  border-radius: var(--radius);
  margin-bottom: 6px;
  overflow: hidden;
}

.library-item.open { border-color: var(--accent-dim); }

.library-row {
  display: grid;
  grid-template-columns: 220px 1fr auto;
  gap: 14px;
  width: 100%;
  background: transparent;
  border: 0;
  color: var(--text);
  text-align: left;
  padding: 10px 14px;
  cursor: pointer;
  font: inherit;
  font-size: 13.5px;
  align-items: center;
}
.library-row:hover { background: var(--bg-elev-2); }
.library-row.open { background: var(--bg-elev-2); }

.library-name { font-weight: 500; }
.library-cats { font-size: 11.5px; }
.library-toggle { color: var(--accent); font-size: 12px; }

.library-detail {
  padding: 4px 16px 16px;
  border-top: 1px solid var(--border);
  background: var(--bg);
}

.lib-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin: 12px 0 10px;
}

.sub-card {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  margin: 10px 0;
}

.sub-card h4 {
  margin: 0 0 8px;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--muted);
  font-weight: 600;
}

.prop {
  display: grid;
  grid-template-columns: 140px 1fr;
  gap: 12px;
  padding: 5px 0;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.prop:last-child { border-bottom: 0; }
.prop-key { text-transform: uppercase; letter-spacing: 0.4px; font-size: 11px; padding-top: 1px; }

.dose-table th, .dose-table td { font-size: 12.5px; padding: 6px 8px; }
.dose-table td.route { font-weight: 500; }

.combo-table { font-size: 12.5px; }
.combo-note { color: var(--muted); }

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

/* --- chat / friends --- */
.chat-log {
  max-height: 420px;
  overflow-y: auto;
  padding: 4px 0;
  margin-bottom: 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.chat-msg {
  background: var(--bg-elev-2);
  border-radius: var(--radius-sm);
  padding: 6px 10px;
  max-width: 70%;
  word-wrap: break-word;
}
.chat-msg.mine {
  background: rgba(167, 139, 250, 0.18);
  align-self: flex-end;
}

.chat-meta {
  font-size: 10.5px;
  color: var(--muted);
  margin-bottom: 2px;
}
.chat-body {
  white-space: pre-wrap;
  font-size: 13px;
}

.chat-input {
  display: flex;
  gap: 8px;
  align-items: stretch;
}
.chat-input input { flex: 1; }
.chat-input button { flex: 0 0 auto; }

.friend-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
}
.friend-row:last-child { border-bottom: 0; }
.friend-row .actions { margin: 0; }

/* --- recovery phrase display --- */
.recovery-banner {
  margin-top: 16px;
  border: 2px solid var(--accent);
  background: rgba(167, 139, 250, 0.06);
  border-radius: var(--radius);
  padding: 16px;
}
.recovery-banner h3 { margin: 0 0 10px; color: var(--accent); font-size: 13px; letter-spacing: 0.6px; }
.recovery-phrase {
  font-family: ui-monospace, "Cascadia Code", Consolas, "Courier New", monospace;
  font-size: 16px;
  font-weight: 600;
  background: var(--bg);
  color: var(--text);
  padding: 14px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  user-select: all;
  word-break: break-all;
  line-height: 1.5;
  margin-bottom: 8px;
}

/* small touch */
::selection { background: rgba(167, 139, 250, 0.4); }
