/* ARKHAIA · Radionics — "tecnología ancestral". See BRAND.md */
@font-face { font-family: 'Cinzel'; src: url('assets/fonts/Cinzel.ttf') format('truetype'); font-weight: 400 900; font-display: swap; }
@font-face { font-family: 'Space Grotesk'; src: url('assets/fonts/SpaceGrotesk.ttf') format('truetype'); font-weight: 300 700; font-display: swap; }

:root {
  --night: #0B0A1F; --indigo: #1A1740; --indigo-2: #241f57;
  --violet: #7C5CFF; --gold: #D9B25F; --gold-hi: #F3D98F; --cyan: #3FE0E8;
  --text: #F2EAD8; --muted: #A8A3C7;
  --line: rgba(217, 178, 95, .28);
  --glass: rgba(26, 23, 64, .72);
  --serif: 'Cinzel', Georgia, serif;
  --sans: 'Space Grotesk', 'Segoe UI', system-ui, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--night); color: var(--text); font: 14px/1.45 var(--sans); display: flex; flex-direction: column; overflow: hidden; }
button, input, select, textarea { font: inherit; }
[hidden] { display: none !important; }

/* Splash */
#splash { position: fixed; inset: 0; background: var(--night); z-index: 1000; display: flex; align-items: center; justify-content: center; }
#splash video { width: 100%; height: 100%; object-fit: contain; }
#skipSplash { position: absolute; right: 16px; bottom: 16px; }
#unmuteSplash { position: absolute; left: 16px; bottom: 16px; }

/* Header / menu */
#appHeader { background: linear-gradient(180deg, rgba(36, 31, 87, .96), rgba(11, 10, 31, .96)); border-bottom: 1px solid var(--line); box-shadow: 0 1px 0 rgba(63, 224, 232, .15); z-index: 20; }
.menubar { display: flex; align-items: center; gap: 4px; padding: 4px 10px; }
.menubar .title { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.menubar .title img { width: 28px; height: 28px; }
.menubar .title span { font-family: var(--serif); font-weight: 600; font-size: 20px; letter-spacing: .28em; color: var(--text); }
.menubar .title small { font-size: 11px; letter-spacing: .3em; text-transform: uppercase; color: var(--gold); }
.menu { position: relative; }
.menu-title { background: none; border: 0; color: var(--muted); padding: 4px 10px; cursor: pointer; border-radius: 6px; letter-spacing: .04em; }
.menu-title:hover, .menu:focus-within .menu-title { color: var(--text); background: rgba(124, 92, 255, .22); }
.menu-items { display: none; position: absolute; top: calc(100% + 4px); left: 0; background: var(--indigo); border: 1px solid var(--line); border-radius: 10px; min-width: 260px; z-index: 50; padding: 6px; box-shadow: 0 12px 30px rgba(0, 0, 0, .5); }
.menu:focus-within .menu-items { display: flex; flex-direction: column; }
.menu-items button { background: none; border: 0; color: var(--text); text-align: left; padding: 8px 12px; cursor: pointer; border-radius: 6px; }
.menu-items button:hover { background: rgba(124, 92, 255, .25); }
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 6px 10px 8px; }

/* Buttons: gold = sacred action, cyan = live/technology state */
.btn { background: rgba(26, 23, 64, .85); color: var(--text); border: 1px solid var(--line); border-radius: 999px; padding: 6px 16px; cursor: pointer; font-family: var(--sans); font-weight: 500; font-size: 13px; letter-spacing: .06em; text-transform: uppercase; transition: border-color .2s, box-shadow .2s, color .2s; }
.btn:hover { border-color: var(--gold); color: var(--gold-hi); box-shadow: 0 0 14px rgba(217, 178, 95, .25); }
.btn.primary { background: linear-gradient(135deg, var(--gold-hi), var(--gold) 55%, #9c7a34); color: var(--night); border-color: transparent; font-weight: 700; }
.btn.primary:hover { color: var(--night); box-shadow: 0 0 18px rgba(243, 217, 143, .45); }
.btn.danger { background: transparent; border-color: var(--cyan); color: var(--cyan); }
.btn.danger:hover { box-shadow: 0 0 16px rgba(63, 224, 232, .45); color: #fff; }
.btn.small { padding: 4px 12px; font-size: 12px; }
.btn.flag { display: flex; align-items: center; gap: 8px; text-transform: none; }
.btn.flag .lang { font-family: var(--serif); font-weight: 700; color: var(--night); background: var(--gold); border-radius: 50%; width: 28px; height: 28px; display: inline-flex; align-items: center; justify-content: center; font-size: 11px; }
.field { display: flex; flex-direction: column; gap: 3px; margin: 5px 0; }
.toolbar .field { flex-direction: row; align-items: center; gap: 6px; }
.field span, .chk span { color: var(--muted); font-size: 12px; letter-spacing: .05em; text-transform: uppercase; }
input, select, textarea { background: rgba(11, 10, 31, .85); color: var(--text); border: 1px solid rgba(168, 163, 199, .3); border-radius: 8px; padding: 5px 8px; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--cyan); box-shadow: 0 0 0 2px rgba(63, 224, 232, .2); }
input[type=checkbox] { accent-color: var(--cyan); }
.chk { display: inline-flex; align-items: center; gap: 5px; cursor: pointer; }
.muted { color: var(--muted); }
.center { text-align: center; }
.row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 6px 0; }

/* Board */
#board { position: relative; flex: 1; background: var(--night) url('assets/brand/arkhaia-background.jpg') center / cover no-repeat; overflow: hidden; }
#cardLayer, #transferLayer { position: absolute; inset: 0; }
#transferLayer { pointer-events: none; }
.card { position: absolute; width: 140px; user-select: none; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: var(--indigo); cursor: grab; touch-action: none; box-shadow: 0 8px 22px rgba(0, 0, 0, .55), inset 0 0 0 1px rgba(255, 255, 255, .03); transition: box-shadow .2s, border-color .2s; }
.card:hover { border-color: var(--gold); box-shadow: 0 8px 26px rgba(0, 0, 0, .6), 0 0 16px rgba(217, 178, 95, .25); }
.card.dragging { cursor: grabbing; }
.card .cardName { background: rgba(11, 10, 31, .92); color: var(--text); text-align: center; font-family: var(--serif); font-size: 12px; letter-spacing: .12em; padding: 3px 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; height: 22px; border-bottom: 1px solid var(--line); }
.card .cardBody { display: block; width: 100%; height: 110px; object-fit: cover; }
.card .cardBody.empty { display: flex; align-items: center; justify-content: center; font-family: var(--serif); font-weight: 600; font-size: 40px; color: var(--gold-hi);
  background: radial-gradient(circle at 50% 45%, rgba(124, 92, 255, .55), rgba(26, 23, 64, .95) 62%), var(--indigo);
  text-shadow: 0 0 14px rgba(217, 178, 95, .5); }
.card .cardRandomNumber { background: rgba(11, 10, 31, .92); color: var(--cyan); text-align: center; font-family: 'Consolas', monospace; font-size: 13px; letter-spacing: .2em; height: 22px; line-height: 22px; border-top: 1px solid rgba(63, 224, 232, .25); }
.transfer { position: absolute; width: 140px; height: 110px; opacity: .55; border: 1px solid var(--cyan); border-radius: 8px; background-size: cover; background-position: center; box-shadow: 0 0 22px 4px rgba(63, 224, 232, .55), inset 0 0 24px rgba(255, 255, 255, .5); }

#animBar { position: fixed; left: 0; right: 0; bottom: 0; display: flex; gap: 12px; align-items: center; padding: 10px 16px; background: var(--glass); backdrop-filter: blur(8px); border-top: 1px solid var(--line); z-index: 30; }
#footerText { flex: 1; white-space: pre-wrap; color: var(--gold-hi); font-family: var(--serif); font-size: 16px; letter-spacing: .04em; min-height: 22px; }

/* Scheduled timer panel */
#panelTimer { position: fixed; inset: 0; z-index: 25; background: rgba(11, 10, 31, .88) url('assets/brand/arkhaia-background.jpg') center / cover; background-blend-mode: multiply; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 22px; }
#panelTimer::before { content: ''; width: 180px; height: 180px; background: url('assets/brand/arkhaia-emblem.svg') center / contain no-repeat; animation: spin 40s linear infinite, breathe 4s ease-in-out infinite; filter: drop-shadow(0 0 18px rgba(63, 224, 232, .5)); }
#lblTimerMessage { font-family: var(--serif); font-size: 28px; letter-spacing: .06em; color: var(--text); text-align: center; white-space: pre-line; padding: 0 16px; }
@keyframes spin { to { rotate: 360deg; } }
@keyframes breathe { 50% { scale: 1.05; } }

/* Modals */
.modal { background: linear-gradient(180deg, rgba(36, 31, 87, .97), rgba(11, 10, 31, .98)), var(--night); color: var(--text); border: 1px solid var(--line); border-radius: 16px; padding: 20px 24px; max-width: min(680px, calc(100vw - 32px)); width: 100%; max-height: calc(100vh - 32px); overflow: auto; box-shadow: 0 24px 60px rgba(0, 0, 0, .6), 0 0 0 1px rgba(63, 224, 232, .08); }
.modal.wide { max-width: min(900px, calc(100vw - 32px)); }
.modal::backdrop { background: rgba(5, 4, 18, .75); backdrop-filter: blur(3px); }
.modal h2 { margin: 0 0 14px; font-family: var(--serif); font-weight: 600; font-size: 22px; letter-spacing: .18em; text-transform: uppercase; color: var(--gold-hi); }
.bg-card, .bg-tcards, .bg-adv { background-image: linear-gradient(180deg, rgba(36, 31, 87, .93), rgba(11, 10, 31, .97)), url('assets/brand/arkhaia-background.jpg'); background-size: cover; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 560px) { .grid2 { grid-template-columns: 1fr; } }
fieldset { border: 1px solid rgba(168, 163, 199, .25); border-radius: 10px; margin: 10px 0; }
legend { padding: 0 4px; }
.actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 16px; }
.imgpick { border: 1px dashed var(--gold); border-radius: 12px; min-height: 180px; display: flex; flex-direction: column; align-items: center; justify-content: center; cursor: pointer; gap: 6px; padding: 8px; color: var(--muted); background: rgba(11, 10, 31, .5); }
.imgpick:hover { border-color: var(--cyan); }
.imgpick.small { min-height: 120px; }
.imgpick img { max-width: 100%; max-height: 200px; border-radius: 8px; }
.imgpick img:not([src]), .imgpick img[src=""] { display: none; }
.rate { width: 120px; font-family: 'Consolas', monospace; letter-spacing: .15em; color: var(--cyan); }
#tcList { width: 100%; min-height: 160px; }
.tabs { display: flex; flex-wrap: wrap; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 12px; }
.tab { background: none; border: 0; color: var(--muted); padding: 8px 14px; cursor: pointer; font-family: var(--serif); font-size: 14px; letter-spacing: .14em; text-transform: uppercase; border-bottom: 2px solid transparent; }
.tab.active { color: var(--gold-hi); border-bottom-color: var(--cyan); }
.tabpage textarea { width: 100%; }
.rows { display: flex; flex-direction: column; gap: 4px; }
.trow { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding: 5px 8px; border-radius: 8px; background: rgba(11, 10, 31, .55); border: 1px solid transparent; }
.trow.bad { border-color: var(--gold); background: rgba(217, 178, 95, .18); }
.trow .num { width: 22px; color: var(--gold); text-align: right; font-family: var(--serif); }
.trow .fname { flex: 1; min-width: 120px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Stick pad: the emblem becomes the pad and lights up while rubbed */
#stickPad { position: relative; user-select: none; cursor: crosshair; touch-action: none; border-radius: 14px; padding: 24px; background: radial-gradient(circle, rgba(124, 92, 255, .25), rgba(11, 10, 31, .9) 70%); border: 1px solid var(--line); }
#stickImg { width: min(320px, 70vw); aspect-ratio: 1; margin: 0 auto; transition: filter .3s; }
#stickImg img { width: 100%; height: 100%; display: block; pointer-events: none; }
#stickPad.rubbing #stickImg { animation: spin 3s linear infinite; filter: drop-shadow(0 0 22px rgba(63, 224, 232, .9)) brightness(1.25); }
#lblRandomNum { text-align: center; margin-top: 14px; font: 600 30px 'Consolas', monospace; letter-spacing: .3em; color: var(--cyan); text-shadow: 0 0 12px rgba(63, 224, 232, .6); }
.about { text-align: center; }
.about-logo { max-width: 100%; width: 460px; }
.pre { white-space: pre-line; font-family: var(--serif); letter-spacing: .08em; }

/* "El significado de ARKHAIA" — arkhé: beginning, origin */
.meaning { text-align: center; background:
  radial-gradient(ellipse at 50% 0%, rgba(124, 92, 255, .30), transparent 60%),
  linear-gradient(180deg, rgba(36, 31, 87, .97), rgba(11, 10, 31, .98)), var(--night); }
.meaning-hero { display: flex; flex-direction: column; align-items: center; gap: 2px; padding-top: 6px; }
.meaning-emblem { width: 96px; height: 96px; filter: drop-shadow(0 0 18px rgba(63, 224, 232, .45)); animation: breathe 5s ease-in-out infinite; }
.greek { font-family: 'Palatino Linotype', 'Georgia', 'Times New Roman', serif; color: var(--gold-hi); }
.greek.big { font-size: 46px; line-height: 1.1; margin-top: 8px; text-shadow: 0 0 22px rgba(217, 178, 95, .45); }
.translit { font-family: var(--sans); font-style: italic; letter-spacing: .25em; color: var(--cyan); font-size: 13px; }
.meaning-hero h2 { margin: 12px 0 4px; }
.meaning-intro { max-width: 560px; margin: 0 auto; color: var(--muted); }

.etym { list-style: none; margin: 26px 0 8px; padding: 0; display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; position: relative; }
.etym::before { content: ''; position: absolute; top: 9px; left: 16.6%; right: 16.6%; height: 2px;
  background: linear-gradient(90deg, var(--gold), var(--cyan), var(--gold)); opacity: .7; }
.etym li { position: relative; display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 0 6px; }
.etym .node { width: 20px; height: 20px; border-radius: 50%; background: var(--night); border: 3px solid var(--cyan); box-shadow: 0 0 12px rgba(63, 224, 232, .6); margin-bottom: 10px; z-index: 1; }
.etym li:first-child .node { border-color: var(--gold-hi); box-shadow: 0 0 16px rgba(243, 217, 143, .8); }
.etym .greek { font-size: 28px; }
.etym b { font-family: var(--serif); font-weight: 600; letter-spacing: .16em; text-transform: uppercase; font-size: 12px; color: var(--text); margin-top: 6px; }
.etym p { margin: 2px 0 0; color: var(--muted); font-size: 13px; }

.meaning-message { margin: 22px auto 0; max-width: 640px; padding: 18px 22px; border: 1px solid var(--line); border-radius: 14px; background: rgba(11, 10, 31, .55); box-shadow: inset 0 0 30px rgba(124, 92, 255, .12); }
.meaning-message h3 { margin: 0 0 8px; font-family: var(--serif); font-weight: 600; letter-spacing: .2em; text-transform: uppercase; font-size: 16px; color: var(--gold-hi); }
.meaning-message p { margin: 8px 0; line-height: 1.6; }
.motto { margin: 18px 0 0; font-family: var(--serif); letter-spacing: .12em; color: var(--gold); font-size: 14px; }
.meaning .actions { justify-content: center; }

@media (max-width: 620px) {
  .etym { grid-template-columns: 1fr; gap: 22px; }
  .etym::before { top: 10px; bottom: 10px; left: 50%; right: auto; width: 2px; height: auto; background: linear-gradient(180deg, var(--gold), var(--cyan), var(--gold)); }
  .etym li { background: var(--indigo); border-radius: 12px; padding: 10px; }
}

/* ================= Cloud mode ================= */
.grow { flex: 1; min-width: 160px; }
.btn.wide { width: 100%; padding: 10px; font-size: 14px; }
.small { font-size: 12px; }

/* Sign-in / first admin */
#authScreen { position: fixed; inset: 0; z-index: 900; display: flex; align-items: center; justify-content: center; padding: 16px;
  background: radial-gradient(ellipse at 50% 30%, rgba(124, 92, 255, .35), transparent 60%), rgba(11, 10, 31, .82) url('assets/brand/arkhaia-background.jpg') center / cover; background-blend-mode: normal, multiply; }
.auth-card { width: min(400px, 100%); background: linear-gradient(180deg, rgba(36, 31, 87, .94), rgba(11, 10, 31, .97)); border: 1px solid var(--line);
  border-radius: 18px; padding: 28px 26px 24px; text-align: center; box-shadow: 0 30px 80px rgba(0, 0, 0, .6), 0 0 0 1px rgba(63, 224, 232, .08); }
.auth-emblem { width: 92px; height: 92px; filter: drop-shadow(0 0 16px rgba(63, 224, 232, .45)); animation: breathe 5s ease-in-out infinite; }
.auth-word { font-family: var(--serif); font-weight: 600; font-size: 30px; letter-spacing: .3em; margin: 8px 0 0 .3em; }
.auth-tag { font-size: 11px; letter-spacing: .28em; text-transform: uppercase; color: var(--gold); margin-bottom: 18px; }
.auth-form { text-align: left; display: flex; flex-direction: column; gap: 4px; }
.auth-form input { padding: 9px 10px; }
.auth-intro { color: var(--muted); text-align: center; margin: 0 0 8px; }
.auth-error { min-height: 18px; color: var(--gold-hi); font-size: 13px; margin: 4px 0; }

/* Account menu */
#menuAccount .menu-title { display: inline-flex; align-items: center; gap: 6px; color: var(--text); }
.user-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--cyan); box-shadow: 0 0 8px var(--cyan); }
.menu-info { display: flex; flex-direction: column; padding: 6px 12px 8px; border-bottom: 1px solid var(--line); margin-bottom: 4px; }
.menu-info span:first-child { color: var(--gold); font-size: 12px; letter-spacing: .1em; text-transform: uppercase; }
.menu-info span:last-child { color: var(--muted); font-size: 12px; }

/* Toast */
#toast { position: fixed; left: 50%; bottom: 70px; translate: -50% 20px; opacity: 0; pointer-events: none; z-index: 1100;
  background: var(--indigo); border: 1px solid var(--cyan); color: var(--text); padding: 9px 18px; border-radius: 999px;
  box-shadow: 0 0 20px rgba(63, 224, 232, .35); transition: opacity .25s, translate .25s; }
#toast.show { opacity: 1; translate: -50% 0; }

/* Template lists */
.tpl-list { display: flex; flex-direction: column; gap: 6px; max-height: 52vh; overflow: auto; padding-right: 2px; }
.tpl-row { display: flex; gap: 12px; align-items: center; justify-content: space-between; flex-wrap: wrap; padding: 10px 12px;
  border-radius: 12px; background: rgba(11, 10, 31, .55); border: 1px solid rgba(168, 163, 199, .15); }
.tpl-row:hover { border-color: var(--line); }
.tpl-info { flex: 1; min-width: 200px; }
.tpl-name { font-family: var(--serif); font-weight: 600; letter-spacing: .06em; color: var(--gold-hi); }
.tpl-desc { color: var(--muted); font-size: 13px; margin-top: 2px; }
.tpl-meta { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-top: 6px; font-size: 12px; }
.tpl-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 999px; font-size: 11px;
  border: 1px solid rgba(168, 163, 199, .3); color: var(--muted); }
.badge.cat { border-color: var(--line); color: var(--gold); }
.badge.users { border-color: rgba(124, 92, 255, .6); color: #c8bbff; }
.badge.all { border-color: rgba(63, 224, 232, .6); color: var(--cyan); }
.empty { padding: 24px 8px; }

/* Visibility / sharing */
fieldset.vis { display: flex; flex-direction: column; gap: 6px; }
.vis-opt { display: flex; gap: 10px; align-items: flex-start; padding: 8px 10px; border-radius: 10px; cursor: pointer; border: 1px solid transparent; }
.vis-opt:has(input:checked) { border-color: var(--line); background: rgba(124, 92, 255, .12); }
.vis-opt input { margin-top: 3px; accent-color: var(--cyan); }
.vis-opt span { display: flex; flex-direction: column; }
.vis-opt small { color: var(--muted); }
.share-pick { margin: 4px 0 0 28px; display: flex; flex-direction: column; gap: 6px; }
.share-users { max-height: 180px; overflow: auto; display: flex; flex-direction: column; gap: 2px; padding: 4px; border-radius: 8px; background: rgba(11, 10, 31, .5); }
.share-user { padding: 4px 6px; border-radius: 6px; }
.share-user:hover { background: rgba(124, 92, 255, .15); }
.share-user span { text-transform: none; letter-spacing: 0; font-size: 13px; color: var(--text); }

/* Admin */
details.new-user { margin-bottom: 12px; }
details.new-user summary { display: inline-block; list-style: none; margin-bottom: 8px; }
details.new-user summary::-webkit-details-marker { display: none; }
.user-list { display: flex; flex-direction: column; gap: 8px; max-height: 50vh; overflow: auto; }
.user-row { display: grid; grid-template-columns: minmax(180px, 1.3fr) minmax(220px, 1.4fr) auto; gap: 12px; align-items: center;
  padding: 10px 12px; border-radius: 12px; background: rgba(11, 10, 31, .55); border: 1px solid rgba(168, 163, 199, .15); }
.user-row.inactive { opacity: .55; }
.user-name { font-weight: 600; }
.user-ctrl { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; }
.user-ctrl .field { margin: 0; }
.user-ctrl .quota { width: 80px; }
.user-actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.usage { display: flex; flex-direction: column; gap: 3px; min-width: 110px; }
.usage .bar { height: 6px; border-radius: 3px; background: rgba(168, 163, 199, .2); overflow: hidden; }
.usage .bar i { display: block; height: 100%; background: linear-gradient(90deg, var(--cyan), var(--violet)); }
.cat-list { display: flex; flex-direction: column; gap: 4px; max-height: 50vh; overflow: auto; }
.cat-row { margin: 0; }
@media (max-width: 720px) { .user-row { grid-template-columns: 1fr; } .user-actions { justify-content: flex-start; } }

/* ================= Therapists ================= */
.patient-chip { display: inline-flex; align-items: center; gap: 6px; margin-left: auto; padding: 4px 6px 4px 12px; border-radius: 999px;
  border: 1px solid var(--cyan); background: rgba(63, 224, 232, .1); box-shadow: 0 0 14px rgba(63, 224, 232, .25); font-size: 13px; }
.chip-btn { background: none; border: 1px solid rgba(168, 163, 199, .35); color: var(--muted); border-radius: 999px; padding: 2px 9px; cursor: pointer; font-size: 12px; }
.chip-btn:hover { color: var(--text); border-color: var(--gold); }
.patient-note { margin: 6px 0; padding: 8px 12px; border-radius: 10px; border: 1px solid rgba(63, 224, 232, .4); background: rgba(63, 224, 232, .08); color: var(--text); }
.ethics { margin: -6px 0 8px; }
.pat-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; flex-wrap: wrap; }
.pat-head h2 { margin-bottom: 2px; }
.grid2.tight { gap: 8px; }
.consent { margin: 6px 0; }
.row.space { justify-content: space-between; margin-top: 12px; }
.row.end { justify-content: flex-end; margin: 4px 0 0; }
.tab:disabled { opacity: .35; cursor: not-allowed; }
.record-new { display: flex; flex-direction: column; gap: 6px; align-items: flex-end; margin-bottom: 10px; }
.record-new textarea { width: 100%; }
.record-list { display: flex; flex-direction: column; gap: 6px; max-height: 46vh; overflow: auto; }
.record { padding: 10px 12px; border-radius: 12px; background: rgba(11, 10, 31, .55); border: 1px solid rgba(168, 163, 199, .15); }
.record textarea { width: 100%; margin-top: 6px; }
.record-head { display: flex; gap: 10px; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.record-date { color: var(--gold); font-size: 12px; letter-spacing: .06em; }
.record-text { white-space: pre-wrap; margin-top: 4px; line-height: 1.55; }
.session-summary { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 10px; }
.session-summary div { display: flex; flex-direction: column; align-items: center; padding: 10px; border-radius: 12px; border: 1px solid var(--line); background: rgba(124, 92, 255, .1); }
.session-summary b { font-family: var(--serif); font-size: 18px; color: var(--gold-hi); }
.session-summary span { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .1em; }

/* Patient history export: printed from the page itself */
#printArea { display: none; }
@media print {
  body { background: #fff !important; color: #1a1740; display: block; overflow: visible; }
  body > *:not(#printArea) { display: none !important; }
  #printArea { display: block; font: 12.5px/1.5 Georgia, serif; color: #1a1740; padding: 8mm 10mm; }
  #printArea h1 { font-size: 22px; letter-spacing: .12em; margin: 0; }
  #printArea h2 { font-size: 14px; letter-spacing: .14em; text-transform: uppercase; color: #5b3fd6; border-bottom: 1px solid #d9b25f; padding-bottom: 3px; margin: 22px 0 8px; }
  #printArea .m { color: #777; } #printArea .e { margin: 8px 0; break-inside: avoid; } #printArea .e p { margin: 2px 0 0; white-space: pre-wrap; }
  #printArea table { width: 100%; border-collapse: collapse; } #printArea td, #printArea th { border-bottom: 1px solid #ddd; padding: 5px; text-align: left; vertical-align: top; }
  #printArea th { font-size: 10.5px; text-transform: uppercase; color: #666; } #printArea tr { break-inside: avoid; }
  #printArea .brand { color: #9c7a34; letter-spacing: .3em; font-size: 10.5px; }
  #printArea .grid { display: grid; grid-template-columns: 150px 1fr; gap: 3px 10px; }
  #printArea .conf { margin-top: 28px; font-size: 10.5px; color: #777; }
  @page { margin: 12mm; }
}

/* ================= Requests (tickets) ================= */
.count-badge { display: inline-flex; align-items: center; justify-content: center; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px;
  background: var(--cyan); color: var(--night); font: 700 11px var(--sans); box-shadow: 0 0 10px rgba(63, 224, 232, .6); margin-left: 6px; }
.menu-items .with-badge { display: flex; align-items: center; justify-content: space-between; }
details.new-ticket { margin-bottom: 12px; padding: 0; }
details.new-ticket summary { display: inline-block; list-style: none; margin-bottom: 8px; }
details.new-ticket summary::-webkit-details-marker { display: none; }
details.new-ticket[open] { padding: 12px; border: 1px solid var(--line); border-radius: 12px; background: rgba(11, 10, 31, .45); }
.ticket-row { cursor: pointer; }
.ticket-row.unread { border-color: rgba(63, 224, 232, .55); box-shadow: 0 0 12px rgba(63, 224, 232, .15); }
.dot-new { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--cyan); box-shadow: 0 0 8px var(--cyan); margin-right: 8px; vertical-align: middle; }
.badge.st-open { border-color: rgba(120, 220, 150, .6); color: #9fe8b6; }
.badge.st-answered { border-color: rgba(124, 92, 255, .6); color: #c8bbff; }
.badge.st-closed { color: var(--muted); }
.thread { display: flex; flex-direction: column; gap: 8px; max-height: 46vh; overflow: auto; padding: 6px 2px; margin: 10px 0; }
.msg { max-width: 82%; padding: 9px 12px; border-radius: 14px; background: rgba(11, 10, 31, .6); border: 1px solid rgba(168, 163, 199, .18); }
.msg.me { align-self: flex-end; border-bottom-right-radius: 4px; background: rgba(124, 92, 255, .18); border-color: rgba(124, 92, 255, .4); }
.msg.them { align-self: flex-start; border-bottom-left-radius: 4px; }
.msg.admin .msg-head { color: var(--gold); }
.msg-head { font-size: 11px; color: var(--muted); margin-bottom: 3px; letter-spacing: .03em; }
.msg-body { white-space: pre-wrap; line-height: 1.5; }
.msg.system { align-self: center; max-width: 100%; background: none; border: 0; font-size: 12px; color: var(--muted); font-style: italic; padding: 2px; }
.reply textarea { width: 100%; }
.cat-shortcut { display: flex; flex-direction: column; gap: 6px; }
.closed-box { padding: 8px 0; }

/* ================= AI ================= */
.btn.ai-btn { border-color: rgba(63, 224, 232, .6); color: var(--cyan); box-shadow: 0 0 12px rgba(63, 224, 232, .2); }
.btn.ai-btn:hover { color: #fff; box-shadow: 0 0 18px rgba(63, 224, 232, .45); }
.assistant-top { align-items: end; }
.assistant-top textarea { width: 100%; }
.ai-working { display: flex; align-items: center; gap: 10px; color: var(--cyan); margin: 12px 0; }
.ai-spinner { width: 18px; height: 18px; border-radius: 50%; border: 2px solid rgba(63, 224, 232, .25); border-top-color: var(--cyan); animation: spin 1s linear infinite; }
.as-results { display: flex; flex-direction: column; gap: 6px; max-height: 48vh; overflow: auto; margin-top: 10px; }
.as-row { display: flex; gap: 10px; align-items: flex-start; padding: 8px 10px; border-radius: 12px; background: rgba(11, 10, 31, .55); border: 1px solid rgba(168, 163, 199, .15); }
.as-row.main { border-color: var(--gold); box-shadow: 0 0 14px rgba(217, 178, 95, .18); }
.as-num { width: 28px; height: 28px; flex: none; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-family: var(--serif); font-weight: 700;
  color: var(--night); background: var(--gold); }
.as-row:not(.main) .as-num { background: var(--violet); color: #fff; }
.as-fields { flex: 1; display: flex; flex-direction: column; gap: 4px; }
.as-fields textarea { width: 100%; }
.as-title { font-family: var(--serif); letter-spacing: .06em; }
.reading .rd-sec { margin-top: 8px; }
.reading h4 { margin: 0 0 3px; font-family: var(--serif); font-weight: 600; letter-spacing: .14em; text-transform: uppercase; font-size: 12px; color: var(--gold-hi); }
.reading p, .reading li { margin: 2px 0; line-height: 1.55; }
.reading ul, .reading ol { margin: 2px 0; padding-left: 20px; }
.rd-sym { padding: 6px 0; border-bottom: 1px dashed rgba(168, 163, 199, .2); }
.rd-warn { margin-top: 6px; padding: 6px 10px; border-radius: 8px; border: 1px solid var(--gold); background: rgba(217, 178, 95, .12); color: var(--gold-hi); }
.rd-template { padding: 8px 10px; border-radius: 10px; background: rgba(124, 92, 255, .12); border: 1px solid rgba(124, 92, 255, .35); }
.usage-row { display: flex; justify-content: space-between; padding: 4px 2px; border-bottom: 1px solid rgba(168, 163, 199, .12); }
.ai-row .user-ctrl input:not(.quota), .ai-row .user-ctrl select { width: 150px; }
.kb-text { width: 100%; font-family: var(--sans); line-height: 1.5; }

/* In-app message windows (replace native alert/confirm/prompt) */
.modal.ui-dialog { max-width: min(440px, calc(100vw - 32px)); text-align: center; padding: 22px 24px 18px; z-index: 2000; }
.ui-emblem { width: 46px; height: 46px; filter: drop-shadow(0 0 10px rgba(63, 224, 232, .4)); }
.ui-msg { margin: 10px 0 4px; white-space: pre-line; line-height: 1.55; font-size: 15px; }
.ui-input { width: 100%; margin-top: 8px; padding: 8px 10px; }
.ui-dialog .actions { justify-content: center; }

/* ================= My library ================= */
.lib-usage { flex: 1; max-width: 320px; }
.lib-search { width: 100%; margin: 8px 0; }
.lib-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; max-height: 50vh; overflow: auto; padding: 2px; }
.lib-item { display: flex; flex-direction: column; gap: 4px; padding: 8px; border-radius: 12px; background: rgba(11, 10, 31, .55); border: 1px solid rgba(168, 163, 199, .15); }
.lib-item.pickable { cursor: pointer; }
.lib-item.pickable:hover { border-color: var(--cyan); box-shadow: 0 0 14px rgba(63, 224, 232, .25); }
.lib-thumb { height: 100px; border-radius: 8px; overflow: hidden; display: flex; align-items: center; justify-content: center;
  background: radial-gradient(circle, rgba(124, 92, 255, .35), rgba(11, 10, 31, .9)); }
.lib-thumb img { width: 100%; height: 100%; object-fit: cover; }
.lib-play { width: 48px; height: 48px; border-radius: 50%; border: 1px solid var(--cyan); background: rgba(63, 224, 232, .12); color: var(--cyan); font-size: 18px; cursor: pointer; }
.lib-play:hover { box-shadow: 0 0 14px rgba(63, 224, 232, .5); }
.lib-name { font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lib-meta { font-size: 11px; }
.lib-actions { display: flex; gap: 4px; flex-wrap: wrap; }
.lib-item .btn.small { align-self: flex-start; }
