/* Attune Admin — warm paper + ink, serif, quiet chrome. */
* { box-sizing: border-box; }
[hidden] { display: none !important; }

:root {
  --paper: #f7f5f0;
  --panel: #fffdf9;
  --ink: #211d16;
  --muted: #7a7263;
  --line: #e6e1d5;
  --accent: #6b4f2a;
  --accent-soft: #f0e9dd;
  --help: #2f6b4f;
  --danger: #a83a2e;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(60, 50, 30, .07);
}

html, body { height: 100%; }
body {
  margin: 0; background: var(--paper); color: var(--ink);
  font-family: Georgia, "Times New Roman", serif; font-size: 16px;
  line-height: 1.45;
}

/* ---------- shell: fixed sidebar + scrolling main */
.shell { display: flex; min-height: 100vh; }
.sidebar {
  width: 216px; flex: 0 0 216px; position: sticky; top: 0;
  height: 100vh; display: flex; flex-direction: column;
  background: var(--panel); border-right: 1px solid var(--line);
  padding: 22px 0 16px;
}
.brand {
  font-size: 20px; font-weight: bold; letter-spacing: .3px;
  padding: 0 22px 18px;
}
.brand span { color: var(--accent); font-weight: normal; margin-left: 6px; }
.sidebar nav { display: flex; flex-direction: column; gap: 2px; }
.sidebar nav a {
  color: var(--ink); text-decoration: none; padding: 9px 22px;
  border-left: 3px solid transparent; font-size: 15.5px;
}
.sidebar nav a:hover { background: var(--accent-soft); }
.sidebar nav a.on {
  border-left-color: var(--accent); background: var(--accent-soft);
  color: var(--accent); font-weight: bold;
}
.sidebar-foot {
  margin-top: auto; padding: 14px 22px 0; border-top: 1px solid var(--line);
  font-size: 13px; color: var(--muted);
}
.sidebar-foot .who { margin-bottom: 6px; word-break: break-all; }

main {
  flex: 1; min-width: 0; padding: 28px 36px 120px;
  max-width: 980px;
}
main.main-chat { padding: 0; max-width: none; display: flex; }

h1 { margin: 0 0 18px; font-size: 26px; }
h2 { margin: 0 0 10px; font-size: 18px; }

/* ---------- panels & fields */
.panel {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 20px 24px; margin-bottom: 22px;
}
.note { color: var(--muted); font-size: 14px; margin: 4px 0 14px; }
.meta { color: var(--muted); font-size: 13px; font-weight: normal; }
.field { margin: 16px 0; }
.field > label {
  display: block; font-size: 13.5px; color: var(--muted);
  text-transform: uppercase; letter-spacing: .4px; margin-bottom: 6px;
}
input[type=text], input[type=number], input[type=email],
input[type=password], input[type=search], select {
  font: inherit; padding: 8px 12px; border: 1px solid var(--line);
  border-radius: 7px; background: #fff; min-width: 240px; color: var(--ink);
}
input[type=number] { min-width: 130px; }
input:focus, select:focus {
  outline: 2px solid var(--accent); outline-offset: 1px; border-color: var(--accent);
}
.radio, .check {
  display: inline-flex; align-items: center; gap: 7px; margin-right: 18px;
  font-size: 15px; text-transform: none; letter-spacing: 0;
}
.voice-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 5px 14px;
}
.help-line {
  min-height: 18px; margin: 8px 0 0; font-size: 13.5px;
  color: var(--help); font-style: italic;
}
.help-line:empty { margin: 0; min-height: 0; }

/* ---------- buttons */
button {
  font: inherit; padding: 8px 20px; border-radius: 7px; cursor: pointer;
  border: 1px solid var(--accent); background: var(--accent); color: #fff;
  transition: filter .12s;
}
button:hover { filter: brightness(1.08); }
button.secondary { background: transparent; color: var(--accent); }
button.danger { background: transparent; color: var(--danger); border-color: var(--danger); }
button.link {
  background: none; border: none; color: var(--accent);
  text-decoration: underline; padding: 0;
}
button:disabled { opacity: .45; cursor: default; }
.save { margin-top: 10px; }

/* ---------- denominations, tables */
details.denom { border-top: 1px solid var(--line); padding: 12px 0; }
details.denom > summary { cursor: pointer; font-size: 16px; }
details.denom > summary::marker { color: var(--accent); }
table { border-collapse: collapse; width: 100%; margin-top: 12px; font-size: 14.5px; }
th {
  text-align: left; font-size: 12.5px; text-transform: uppercase;
  letter-spacing: .4px; color: var(--muted); font-weight: normal;
}
th, td { padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
tbody tr:hover { background: var(--accent-soft); }
td.num { text-align: right; font-variant-numeric: tabular-nums; }
#books-table tr[hidden] { display: none; }

/* ---------- save bar & dialogs */
#savebar {
  position: fixed; bottom: 0; left: 216px; right: 0; display: flex; gap: 14px;
  align-items: center; justify-content: center; padding: 12px;
  background: #362d1f; color: #fff; z-index: 40;
}
#confirm-overlay {
  position: fixed; inset: 0; background: rgba(30, 25, 15, .45); z-index: 50;
  display: flex; align-items: center; justify-content: center;
}
#confirm-overlay .dialog {
  background: var(--panel); color: var(--ink); padding: 26px 30px;
  border-radius: var(--radius); max-width: 420px; text-align: center;
  box-shadow: 0 8px 30px rgba(0,0,0,.2);
}
#confirm-overlay .dialog button { margin: 6px; }

/* ---------- login */
.login-body {
  display: flex; align-items: center; justify-content: center;
  min-height: 100vh; background: var(--paper);
  font-family: Georgia, serif;
}
.login-box {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 12px; padding: 36px 42px; width: 370px; box-shadow: var(--shadow);
}
.login-box h1 { margin-top: 0; font-size: 22px; }
.login-box label { display: block; margin: 14px 0; font-size: 14px; color: var(--muted); }
.login-box input { width: 100%; margin-top: 5px; min-width: 0; }
.login-box button { width: 100%; margin-top: 16px; }
.error { color: var(--danger); }

/* ---------- chat screen */
.chat-screen {
  display: flex; flex-direction: column; height: 100vh; flex: 1; min-width: 0;
}
.chat-head {
  display: grid; grid-template-columns: auto auto 1fr; align-items: center;
  gap: 16px; padding: 14px 26px 10px; background: var(--panel);
  border-bottom: 1px solid var(--line);
}
.chat-head .help-line { grid-column: 1 / -1; margin: 2px 0 0; }
.tabs { display: inline-flex; border: 1px solid var(--accent); border-radius: 8px; overflow: hidden; }
.tabs .tab {
  border: none; border-radius: 0; background: transparent; color: var(--accent);
  padding: 8px 22px; font-size: 15px;
}
.tabs .tab.on { background: var(--accent); color: #fff; }
.chat-log {
  flex: 1; overflow-y: auto; padding: 22px 26px; display: flex;
  flex-direction: column; gap: 14px;
}
.chat-empty {
  margin: auto; max-width: 460px; text-align: center; color: var(--muted);
  font-style: italic;
}
.msg { max-width: 720px; }
.msg.user {
  align-self: flex-end; background: var(--accent); color: #fff;
  padding: 10px 16px; border-radius: 14px 14px 3px 14px; font-size: 15.5px;
}
.msg.assistant { align-self: flex-start; width: 100%; max-width: 760px; }
.msg .cstat { color: var(--muted); font-size: 12.5px; margin: 4px 0 6px 2px; }
.msg .card {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 12px 12px 12px 3px; box-shadow: var(--shadow);
  padding: 14px 18px; margin-bottom: 10px; font-size: 15px;
}
.msg .card .ref { font-weight: bold; }
.msg .card .verse {
  font-style: italic; margin: 8px 0; padding-left: 12px;
  border-left: 3px solid var(--accent-soft);
}
.msg .card .cvoice { color: var(--accent); font-weight: bold; }
.msg .card details { margin-top: 8px; }
.msg .card summary { cursor: pointer; color: var(--muted); font-size: 13.5px; }
.msg .card .long { margin-top: 8px; color: var(--ink); }
.msg.pending .card { color: var(--muted); font-style: italic; }
.chat-composer {
  display: flex; gap: 10px; padding: 14px 26px 18px; background: var(--panel);
  border-top: 1px solid var(--line);
}
.chat-composer select { min-width: 180px; max-width: 260px; }
.chat-composer input { flex: 1; min-width: 0; }
