:root {
  --bg: #0c0c10;
  --panel: #15151b;
  --panel-2: #1c1c24;
  --line: #2a2a35;
  --text: #f2f1f5;
  --muted: #9a98a8;
  --accent: #ff3d7f;
  --accent-2: #ff7a59;
  --grad: linear-gradient(135deg, var(--accent), var(--accent-2));
  --radius: 16px;
  --narr: #a9a6b8;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Inter", "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; }
svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

.shell { display: grid; grid-template-columns: 220px 1fr; height: 100vh; }

/* ---- rail ---- */
.rail { background: var(--panel); border-right: 1px solid var(--line); padding: 18px 12px; display: flex; flex-direction: column; gap: 4px; }
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 10px 18px; font-weight: 700; font-size: 20px; letter-spacing: -0.02em; }
.brand svg { width: 28px; height: 28px; fill: var(--accent); stroke: none; }
.brand span { background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.nav { display: flex; align-items: center; gap: 12px; padding: 11px 12px; border-radius: 12px; color: var(--muted); text-align: left; transition: background .15s, color .15s; }
.nav:hover { background: var(--panel-2); color: var(--text); }
.nav.active { background: rgba(255, 61, 127, .13); color: var(--text); }
.nav.active svg { color: var(--accent); }
.rail-foot { margin-top: auto; padding: 10px 12px; font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 8px; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: #666; flex: none; }
.dot.ok { background: #3ddc84; box-shadow: 0 0 8px rgba(61, 220, 132, .6); }
.dot.bad { background: #ff5a5a; }

main { min-width: 0; min-height: 0; overflow: hidden; }
.view { display: none; height: 100%; overflow-y: auto; }
.view.active { display: block; }
.view.narrow { padding: 0 32px 40px; }
.view.narrow > * { max-width: 760px; }

.page-head { padding: 34px 32px 8px; }
.view.narrow .page-head { padding-left: 0; padding-right: 0; }
.page-head h1 { margin: 0 0 6px; font-size: 30px; letter-spacing: -0.03em; font-weight: 700; }
.page-head h1 em { font-style: normal; background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.page-head p { margin: 0; color: var(--muted); }

.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 20px; }
.chip { padding: 7px 14px; border-radius: 999px; background: var(--panel-2); border: 1px solid var(--line); color: var(--muted); font-size: 13px; }
.chip:hover { color: var(--text); }
.chip.active { background: var(--grad); border-color: transparent; color: #fff; font-weight: 600; }

/* ---- grid ---- */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 18px; padding: 22px 32px 48px; }
.card { position: relative; aspect-ratio: 3 / 4.200; border-radius: var(--radius); overflow: hidden; text-align: left; background: var(--panel-2); border: 1px solid var(--line); transition: transform .18s ease, border-color .18s, box-shadow .18s; }
.card:hover { transform: translateY(-4px); border-color: var(--accent); box-shadow: 0 14px 34px rgba(255, 61, 127, .18); }
.card .art { position: absolute; inset: 0; background-size: cover; background-position: center top; }
.card .art.ph { display: grid; place-items: center; }
.card .art.ph span { font-size: 120px; font-weight: 800; letter-spacing: -0.06em; color: rgba(255, 255, 255, .16); transform: translateY(-12%); }
.clip { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; object-position: center top; opacity: 0; transition: opacity .25s; pointer-events: none; }
.clip.on { opacity: 1; }
.card .shade { position: absolute; inset: 0; background: linear-gradient(to top, rgba(8, 8, 12, .96) 0%, rgba(8, 8, 12, .55) 38%, transparent 62%); }
.card .meta { position: absolute; left: 0; right: 0; bottom: 0; padding: 16px; }
.card .meta h3 { margin: 0; font-size: 19px; font-weight: 700; display: flex; align-items: baseline; gap: 8px; }
.card .meta h3 small { font-size: 14px; font-weight: 500; color: var(--muted); }
.card .meta p { margin: 6px 0 10px; font-size: 13px; color: #cfcdd8; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.tags { display: flex; flex-wrap: wrap; gap: 6px; }
.tag { font-size: 11px; padding: 3px 9px; border-radius: 999px; background: rgba(255, 255, 255, .1); color: #e7e5ee; }
.card .cta { position: absolute; top: 12px; right: 12px; padding: 6px 12px; border-radius: 999px; background: var(--grad); color: #fff; font-size: 12px; font-weight: 600; opacity: 0; transform: translateY(-4px); transition: .18s; }
.card:hover .cta { opacity: 1; transform: none; }

/* ---- chat layout ---- */
#view-chat.active { display: grid; grid-template-columns: 270px minmax(0, 1fr) 320px; overflow: hidden; position: relative; }
.threads { border-right: 1px solid var(--line); overflow-y: auto; padding: 20px 10px; }
.threads h2 { margin: 0 10px 12px; font-size: 13px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); font-weight: 600; }
.thread { display: flex; gap: 12px; align-items: center; width: 100%; padding: 10px; border-radius: 12px; text-align: left; }
.thread:hover { background: var(--panel); }
.thread.active { background: var(--panel-2); }
.thread .t-name { font-weight: 600; }
.thread .t-prev { font-size: 12.500px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 170px; }

.avatar { width: 46px; height: 46px; border-radius: 50%; flex: none; background-size: cover; background-position: center top; display: grid; place-items: center; font-weight: 700; color: rgba(255, 255, 255, .85); }
.avatar.sm { width: 40px; height: 40px; }

.convo { display: flex; flex-direction: column; min-height: 0; min-width: 0; }
.convo-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 12px 22px; border-bottom: 1px solid var(--line); }
.who { display: flex; align-items: center; gap: 12px; min-width: 0; }
.who .name { font-weight: 700; }
.who .sub { font-size: 12.500px; color: var(--muted); }
.tools { display: flex; align-items: center; gap: 14px; flex: none; }
.ghost { padding: 8px 14px; border-radius: 999px; border: 1px solid var(--line); color: var(--muted); font-size: 13px; }
.ghost:hover { color: var(--text); border-color: var(--muted); }
.primary { padding: 10px 20px; border-radius: 999px; background: var(--grad); color: #fff; font-weight: 600; }
.primary:hover { filter: brightness(1.080); }

.switch { display: flex; align-items: center; gap: 9px; cursor: pointer; font-size: 13px; color: var(--muted); user-select: none; }
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.switch .track { width: 38px; height: 22px; border-radius: 999px; background: var(--line); position: relative; transition: background .15s; }
.switch .track::after { content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: transform .15s; }
.switch input:checked + .track { background: var(--accent); }
.switch input:checked + .track::after { transform: translateX(16px); }
.switch input:checked ~ .lbl { color: var(--text); }
.switch input:focus-visible + .track { outline: 2px solid var(--accent-2); outline-offset: 2px; }

.messages { flex: 1; overflow-y: auto; padding: 24px 22px 8px; display: flex; flex-direction: column; gap: 6px; }
.msg { display: flex; max-width: min(78%, 640px); flex-direction: column; }
.msg.user { align-self: flex-end; align-items: flex-end; }
.msg.assistant { align-self: flex-start; align-items: flex-start; }
.bubble { padding: 10px 14px; border-radius: 18px; white-space: pre-wrap; word-wrap: break-word; overflow-wrap: anywhere; }
.msg.assistant .bubble { background: var(--panel-2); border-bottom-left-radius: 6px; }
.msg .bubble + .bubble { margin-top: 5px; }
.msg.user .bubble { background: var(--grad); color: #fff; border-bottom-right-radius: 6px; }
.bubble em.narr { color: var(--narr); font-style: italic; }
.msg.user .bubble em.narr { color: rgba(255, 255, 255, .8); }
.msg + .msg.user, .msg.user + .msg.assistant { margin-top: 10px; }
.msg-actions { display: flex; gap: 12px; margin: 4px 6px 0; font-size: 12px; color: var(--muted); }
.msg-actions button { color: var(--muted); padding: 2px 0; }
.msg-actions button:hover { color: var(--accent); }
.typing { display: inline-flex; gap: 4px; padding: 4px 2px; }
.typing i { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); animation: blink 1.2s infinite both; }
.typing i:nth-child(2) { animation-delay: .2s; }
.typing i:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%, 80%, 100% { opacity: .25; } 40% { opacity: 1; } }
.note { align-self: center; font-size: 12.500px; color: #ff9a9a; background: rgba(255, 90, 90, .1); border: 1px solid rgba(255, 90, 90, .3); padding: 8px 14px; border-radius: 12px; margin: 8px 0; max-width: 90%; }

.composer { display: flex; gap: 10px; align-items: flex-end; padding: 12px 22px 18px; }
.composer textarea { flex: 1; resize: none; max-height: 160px; padding: 12px 16px; border-radius: 22px; background: var(--panel-2); border: 1px solid var(--line); outline: none; }
.composer textarea:focus { border-color: var(--accent); }
.composer button { width: 46px; height: 46px; border-radius: 50%; background: var(--grad); color: #fff; display: grid; place-items: center; flex: none; }
.composer button svg { fill: #fff; stroke: none; }
.composer button:disabled { opacity: .45; cursor: default; }

.profile-panel { border-left: 1px solid var(--line); overflow-y: auto; }
.profile-panel .hero { aspect-ratio: 3 / 3.700; background-size: cover; background-position: center top; position: relative; display: grid; place-items: center; }
.profile-panel .hero span { font-size: 150px; font-weight: 800; color: rgba(255, 255, 255, .16); }
.profile-panel .hero::after { content: ""; position: absolute; inset: 0; z-index: 1; background: linear-gradient(to top, var(--bg) 0%, transparent 45%); }
.profile-panel .body { padding: 0 20px 28px; margin-top: -46px; position: relative; z-index: 2; }
.profile-panel h3 { margin: 0; font-size: 24px; letter-spacing: -0.02em; }
.profile-panel h3 small { font-size: 16px; color: var(--muted); font-weight: 500; margin-left: 6px; }
.profile-panel .occ { color: var(--accent); font-size: 13px; margin: 2px 0 12px; font-weight: 600; }
.profile-panel p { color: #cfcdd8; font-size: 14px; margin: 0 0 16px; }
.profile-panel h4 { margin: 18px 0 8px; font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); font-weight: 600; }
.profile-panel ul { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 6px; font-size: 14px; color: #dddbe6; }
.profile-panel li::before { content: "♥"; color: var(--accent); margin-right: 8px; font-size: 11px; }
.profile-panel .greet { display: flex; flex-direction: column; gap: 8px; }
.profile-panel .greet button { text-align: left; padding: 10px 12px; border-radius: 12px; border: 1px solid var(--line); font-size: 13px; color: #dddbe6; }
.profile-panel .greet button:hover { border-color: var(--accent); }
.profile-panel .greet small { display: block; color: var(--muted); font-size: 12px; margin-top: 2px; }

.empty { display: none; position: absolute; inset: 0; background: var(--bg); place-items: center; align-content: center; gap: 14px; text-align: center; color: var(--muted); }
.empty.show { display: grid; }

.stage { display: flex; border: 1px solid var(--line); border-radius: 999px; overflow: hidden; font-size: 12px; }
.stage button { padding: 6px 10px; color: var(--muted); white-space: nowrap; }
.stage button + button { border-left: 1px solid var(--line); }
.stage button:hover { color: var(--text); }
.stage button.now { color: var(--text); background: rgba(255, 61, 127, .16); }
.stage button.set { color: #fff; background: var(--grad); font-weight: 600; }
.cmp-head .stage { margin-bottom: 4px; }
@media (max-width: 1500px) { .stage button { font-size: 0; padding: 6px 9px; } .stage button::before { content: attr(data-stage); font-size: 12px; text-transform: capitalize; } }

/* ---- usporedba ---- */
#view-compare.active { display: flex; flex-direction: column; overflow: hidden; }
.cmp-head { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 14px; padding: 14px 22px; border-bottom: 1px solid var(--line); }
.cmp-head > label:not(.switch) { display: flex; flex-direction: column; gap: 5px; font-size: 12px; color: var(--muted); font-weight: 600; min-width: 150px; flex: 1; max-width: 300px; }
.cmp-head select { padding: 9px 11px; border-radius: 10px; background: var(--panel-2); border: 1px solid var(--line); color: var(--text); outline: none; width: 100%; }
.cmp-head select:focus { border-color: var(--accent); }
.cmp-head .switch { padding-bottom: 9px; }
.cmp-head .ghost { margin-left: auto; margin-bottom: 2px; }
.cmp-cols { flex: 1; min-height: 0; display: grid; grid-template-columns: 1fr 1fr; }
.cmp-col { display: flex; flex-direction: column; min-height: 0; min-width: 0; }
.cmp-col + .cmp-col { border-left: 1px solid var(--line); }
.cmp-title { display: flex; align-items: center; gap: 10px; padding: 10px 22px; font-size: 13px; color: var(--muted); border-bottom: 1px solid var(--line); background: var(--panel); }
.cmp-title b { width: 22px; height: 22px; border-radius: 7px; display: grid; place-items: center; background: var(--grad); color: #fff; font-size: 12px; flex: none; }
.cmp-title span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cmp-col .msg { max-width: 92%; }
.composer.side { padding: 8px 14px; border-top: 1px solid var(--line); }
.composer.side textarea { padding: 9px 14px; border-radius: 18px; font-size: 14px; }
.composer.side button { width: 38px; height: 38px; }
.composer.side button svg { width: 18px; height: 18px; }
#cComposer { border-top: 1px solid var(--line); padding-top: 10px; }

/* izvjestaj ocjena */
.ev { padding: 26px 32px 60px; max-width: 1180px; }
.ev h1 { margin: 0 0 6px; font-size: 26px; }
.ev h2 { margin: 34px 0 10px; font-size: 17px; }
.ev p.lead { color: var(--muted); margin: 0 0 6px; max-width: 820px; line-height: 1.5; }
.ev-empty { color: var(--muted); padding: 40px 0; }
.ev table { border-collapse: collapse; width: 100%; font-size: 13.5px; font-variant-numeric: tabular-nums; }
.ev th, .ev td { padding: 8px 10px; border-bottom: 1px solid var(--line); text-align: right; white-space: nowrap; }
.ev th:first-child, .ev td:first-child { text-align: left; }
.ev th { color: var(--muted); font-weight: 600; font-size: 12px; }
.ev td.best { color: #fff; font-weight: 700; }
.ev td.low { color: #ff9a9a; }
.ev .bar { display: inline-block; height: 8px; border-radius: 4px; background: var(--grad); vertical-align: middle; margin-right: 8px; }
.ev .scroll { overflow-x: auto; }
.ev details { border: 1px solid var(--line); border-radius: 12px; margin: 8px 0; background: var(--panel); }
.ev summary { cursor: pointer; padding: 11px 14px; display: flex; gap: 12px; align-items: center; font-size: 14px; }
.ev summary b { flex: none; min-width: 250px; }
.ev summary span { color: var(--muted); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ev details > div { padding: 4px 14px 14px; }
.ev .q { color: var(--muted); font-size: 12.5px; white-space: normal; text-align: left; max-width: 420px; line-height: 1.4; }
.ev .q i { color: var(--text); font-style: normal; }
.ev .tags { white-space: normal; text-align: left; color: var(--muted); font-size: 12px; }
.ev .crit { display: grid; grid-template-columns: repeat(auto-fill, minmax(330px, 1fr)); gap: 10px; }
.ev .crit div { border: 1px solid var(--line); border-radius: 12px; padding: 11px 13px; font-size: 13px; line-height: 1.45; }
.ev .crit b { display: block; margin-bottom: 3px; }
.ev .crit em { display: block; color: var(--muted); font-size: 12px; margin-top: 6px; font-style: normal; }
.ev a { color: var(--accent); }

/* ponavljanje razgovora na drugim modelima */
.ghost.mini { margin-left: auto; padding: 4px 10px; font-size: 12px; flex: none; }
dialog#rpDialog { background: var(--panel); color: var(--text); border: 1px solid var(--line); border-radius: 16px; padding: 22px 24px; width: min(440px, 92vw); }
dialog#rpDialog::backdrop { background: rgba(0, 0, 0, .6); }
#rpDialog h3 { margin: 0 0 8px; font-size: 17px; }
#rpDialog p { margin: 0 0 14px; color: var(--muted); font-size: 13.5px; line-height: 1.45; }
dialog#scDialog { background: var(--panel); color: var(--text); border: 1px solid var(--line); border-radius: 16px; padding: 22px 24px; width: min(460px, 92vw); }
dialog#scDialog::backdrop { background: rgba(0, 0, 0, .6); }
#scDialog h3 { margin: 0 0 8px; font-size: 17px; }
#scDialog p { margin: 0 0 14px; color: var(--muted); font-size: 13.5px; line-height: 1.45; }
#scDialog .rp-err { color: #ff9a9a; margin: 0 0 10px; }
.sc-field { display: flex; flex-direction: column; gap: 5px; font-size: 12px; color: var(--muted); font-weight: 600; margin-bottom: 12px; }
.sc-field select { padding: 9px 11px; border-radius: 10px; background: var(--panel-2); border: 1px solid var(--line); color: var(--text); }
#scModels { display: flex; flex-direction: column; gap: 8px; margin-bottom: 14px; }
#scModels label { display: flex; align-items: center; gap: 10px; font-size: 14px; }
#scModels small, .rp-cell .sim { color: var(--muted); font-size: 11.5px; }
.rp-cell .bubble.mine { background: var(--grad); color: #fff; border-bottom-left-radius: 18px; border-bottom-right-radius: 6px; align-self: flex-end; max-width: 92%; font-size: 13.5px; }
.rp-user .goal { color: var(--muted); font-size: 12.5px; }
#rpModels { display: flex; flex-direction: column; gap: 8px; margin-bottom: 14px; }
#rpModels label { display: flex; align-items: center; gap: 10px; font-size: 14px; }
#rpModels small { color: var(--muted); }
#rpDialog .rp-err { color: #ff9a9a; min-height: 0; margin: 0 0 10px; }
.rp-actions { display: flex; justify-content: flex-end; gap: 10px; }
.rp-actions .primary { padding: 9px 18px; border-radius: 999px; background: var(--grad); color: #fff; font-weight: 600; }
#view-replay.active { display: flex; flex-direction: column; overflow: hidden; }
.rp-head { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 14px; padding: 14px 22px; border-bottom: 1px solid var(--line); }
.rp-head label { display: flex; flex-direction: column; gap: 5px; font-size: 12px; color: var(--muted); font-weight: 600; flex: 1; max-width: 520px; }
.rp-head select { padding: 9px 11px; border-radius: 10px; background: var(--panel-2); border: 1px solid var(--line); color: var(--text); outline: none; width: 100%; }
#rpStatus { color: var(--muted); font-size: 13px; padding-bottom: 9px; margin-right: auto; }
.rp-empty { padding: 60px 22px; color: var(--muted); text-align: center; }
.rp-scroll { flex: 1; min-height: 0; overflow: auto; }
.rp-grid { display: grid; width: 100%; }
.rp-model { position: sticky; top: 0; z-index: 3; background: var(--panel); border-bottom: 1px solid var(--line); padding: 10px 14px; font-size: 13px; font-weight: 600; display: flex; flex-direction: column; gap: 2px; }
.rp-model small { font-weight: 400; color: var(--muted); }
.rp-model small.bad { color: #ff9a9a; }
.rp-model + .rp-model, .rp-cell + .rp-cell { border-left: 1px solid var(--line); }
.rp-user { grid-column: 1 / -1; background: rgba(255, 255, 255, .025); border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.rp-user.shift { border-top: 2px solid var(--accent); }
.rp-user > div { position: sticky; left: 0; width: min(100%, calc(100vw - 240px)); padding: 10px 14px; display: flex; align-items: center; gap: 12px; }
.rp-user .tag { font-size: 11.5px; color: var(--muted); white-space: nowrap; flex: none; }
.rp-user.shift .tag { color: var(--accent); font-weight: 600; }
.rp-user .bubble { background: var(--grad); color: #fff; border-bottom-right-radius: 6px; margin-left: auto; max-width: 70%; }
.rp-cell { padding: 12px 14px 16px; min-width: 0; display: flex; flex-direction: column; align-items: flex-start; gap: 5px; }
.rp-cell .bubble { background: var(--panel-2); border-bottom-left-radius: 6px; font-size: 14.5px; }
.rp-cell .meta-line { font-size: 11.5px; color: var(--muted); margin: 2px 4px 0; }
.rp-cell .wait { color: var(--muted); font-size: 13px; }
.rp-cell .note { align-self: flex-start; margin: 0; }
.msg .meta-line { margin: 4px 6px 0; font-size: 11.500px; color: var(--muted); }

/* ---- ocjene ---- */
.msg-actions { align-items: center; opacity: 0; transition: opacity .12s; }
.msg:hover .msg-actions, .msg-actions.rated, .msg-actions.last { opacity: 1; }
.msg-actions [data-act="up"], .msg-actions [data-act="down"] { filter: grayscale(1); opacity: .5; font-size: 14px; }
.msg-actions [data-act="up"]:hover, .msg-actions [data-act="down"]:hover, .msg-actions button.on { filter: none; opacity: 1; }

/* ---- pamćenje ---- */
.mem-sum { font-size: 13px; color: #cfcdd8; margin: 0 0 6px; }
.profile-panel p.mem-meta { font-size: 12px; color: var(--muted); margin: 0 0 6px; }
.profile-panel ul.facts { gap: 5px; font-size: 13px; }
.profile-panel ul.facts li { display: flex; gap: 8px; align-items: flex-start; justify-content: space-between; }
.profile-panel ul.facts li::before { content: none; }
.facts li button { color: var(--muted); font-size: 16px; line-height: 1; padding: 0 2px; flex: none; }
.facts li button:hover { color: var(--accent); }
.facts li.none { color: var(--muted); }
.fact-add { display: flex; gap: 6px; margin-top: 8px; }
.fact-add input { flex: 1; min-width: 0; padding: 7px 10px; border-radius: 10px; background: var(--panel-2); border: 1px solid var(--line); outline: none; font-size: 13px; }
.fact-add input:focus { border-color: var(--accent); }
.fact-add button { width: 32px; border-radius: 10px; border: 1px solid var(--line); color: var(--muted); flex: none; }
.fact-add button:hover { color: var(--text); border-color: var(--muted); }
.mem-foot { display: flex; align-items: center; gap: 10px; margin-top: 12px; }
.mem-foot .ghost { padding: 6px 12px; font-size: 12px; flex: none; }
.mem-note { font-size: 12px; color: var(--muted); }
button.link { color: var(--accent); font-size: inherit; padding: 0; }

/* ---- samopodešavanje ---- */
.card-form label.switch { flex-direction: row; flex: none; align-items: center; font-weight: 400; }
.card-form .switch input { width: auto; padding: 0; }
.tune-head { display: flex; justify-content: space-between; gap: 18px; align-items: flex-start; }
.tune-head b { font-size: 16px; }
.tune-head p { margin: 4px 0 0; color: var(--muted); font-size: 13px; }
#tuneStats { font-size: 13px; color: var(--muted); }
.tune-row { display: grid; grid-template-columns: 18px 1fr auto 16px; gap: 12px; align-items: center; padding: 10px 0; border-top: 1px solid var(--line); font-size: 14px; }
.tune-row.off { opacity: .5; }
.card-form .tune-row input { width: 16px; height: 16px; padding: 0; accent-color: var(--accent); }
.tune-note small { display: block; color: var(--muted); font-size: 11.500px; margin-top: 2px; }
.tune-score { font-size: 12.500px; color: var(--muted); white-space: nowrap; }
#tuneAdd { display: flex; gap: 10px; }
#tuneAdd input { flex: 1; }
#tuningCard .ghost { flex: none; }
.preview { font-size: 13px; color: var(--muted); margin: 0; }
.preview b { color: var(--text); font-weight: 600; }

/* ---- modeli u oblaku ---- */
#remoteKeyForm, #rAdd { display: flex; gap: 10px; }
#remoteKeyForm input, #rAdd input { flex: 1; }
#remoteCard .ghost, #remoteCard .primary { flex: none; }
#rStatus { font-size: 13px; color: var(--muted); }
.remote-row { grid-template-columns: 18px 1fr auto 16px; }
.saved.bad { color: #ff7a7a; }
.cloud { font-size: 11px; font-weight: 600; padding: 2px 8px; margin-left: 8px; vertical-align: 2px; border-radius: 999px; border: 1px solid #e0a23c; color: #f0b755; white-space: nowrap; cursor: help; }
.cloud[hidden] { display: none; }

/* ---- forms ---- */
.card-form { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 24px; margin-top: 22px; display: flex; flex-direction: column; gap: 18px; }
.card-form label { display: flex; flex-direction: column; gap: 7px; font-size: 13px; color: var(--muted); font-weight: 600; flex: 1; min-width: 0; }
.card-form label small { font-weight: 400; }
.card-form input, .card-form textarea, .card-form select { padding: 11px 13px; border-radius: 12px; background: var(--panel-2); border: 1px solid var(--line); color: var(--text); outline: none; font-weight: 400; width: 100%; }
.card-form input:focus, .card-form textarea:focus, .card-form select:focus { border-color: var(--accent); }
.card-form .row { display: flex; gap: 14px; flex-wrap: wrap; }
.card-form .row label { min-width: 170px; }
.form-foot { display: flex; align-items: center; gap: 14px; }
.saved { color: #3ddc84; font-size: 13px; }

@media (max-width: 1180px) { #view-chat.active { grid-template-columns: 240px minmax(0, 1fr); } .profile-panel { display: none; } }
@media (max-width: 820px) {
  .shell { grid-template-columns: 64px 1fr; }
  .rail { padding: 14px 8px; align-items: center; }
  .brand span, .nav span, .rail-foot span:last-child { display: none; }
  .brand { padding: 4px 0 14px; }
  #view-chat.active { grid-template-columns: minmax(0, 1fr); }
  .threads { display: none; }
  .grid { padding: 18px 16px 40px; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; }
  .page-head { padding: 24px 16px 4px; }
  .view.narrow { padding: 0 16px 32px; }
  .switch .lbl { display: none; }
}

/* ---- javna beta (body.public); u privatnom nacinu se nista od ovoga ne prikazuje ---- */
body:not(.public) .public-only { display: none !important; }
.public .owner-only { display: none !important; }
.public .shell { height: 100dvh; }
.public .rail .nav.fb { margin-top: auto; }
.left-info { font-size: 12px; color: var(--muted); text-align: center; padding: 0 22px 12px; margin-top: -8px; }
.left-info:empty { display: none; }
.left-info.low { color: var(--accent-2); }
.note.soft { color: var(--text); background: var(--panel-2); border-color: var(--line); line-height: 1.45; text-align: center; }
.back { display: none; width: 34px; height: 34px; margin-left: -6px; border-radius: 50%; place-items: center; color: var(--muted); flex: none; }
.back:hover { color: var(--text); background: var(--panel-2); }
.public .who > div:last-child { min-width: 0; }
.public .who .name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#view-chat.list.active { grid-template-columns: minmax(0, 1fr); }
#view-chat.list .convo, #view-chat.list .profile-panel { display: none; }
#view-chat.list .threads { display: block; border-right: 0; width: 100%; max-width: 720px; margin: 0 auto; padding: 28px 16px; }
#view-chat.list .thread > div:last-child { min-width: 0; }
#view-chat.list .thread .t-prev { max-width: none; }
.public .profile-panel .greet button small, .pdialog .greet button small { display: block; color: var(--muted); font-size: 12px; margin-top: 2px; }

/* dijalozi: povratne informacije, novi razgovor */
dialog.pdialog { background: var(--panel); color: var(--text); border: 1px solid var(--line); border-radius: 16px; padding: 22px 24px; width: min(460px, calc(100vw - 32px)); }
dialog.pdialog::backdrop { background: rgba(0, 0, 0, .6); }
.pdialog h3 { margin: 0 0 12px; font-size: 17px; }
.pdialog p { margin: 0 0 14px; color: var(--muted); font-size: 13.5px; line-height: 1.45; }
.pdialog textarea { width: 100%; resize: vertical; padding: 11px 13px; border-radius: 12px; background: var(--panel-2); border: 1px solid var(--line); outline: none; margin-bottom: 10px; }
.pdialog textarea:focus { border-color: var(--accent); }
.pdialog .rp-err { color: #ff9a9a; margin: 0 0 10px; font-size: 13px; }
.pdialog .rp-err:empty { display: none; }
.pdialog #fbThanks { color: var(--text); font-size: 15px; }
.pdialog .greet { display: flex; flex-direction: column; gap: 8px; margin-bottom: 16px; }
.pdialog .greet button { text-align: left; padding: 11px 13px; border-radius: 12px; border: 1px solid var(--line); font-size: 14px; color: #dddbe6; }
.pdialog .greet button:hover { border-color: var(--accent); }

/* prijava */
.auth { position: fixed; inset: 0; z-index: 50; overflow-y: auto; display: flex; justify-content: center; align-items: flex-start; padding: 6vh 16px 32px;
  background: radial-gradient(ellipse at top, rgba(255, 61, 127, .16), transparent 60%), var(--bg); }
.auth[hidden] { display: none; }
.auth-open .shell { display: none; }
.auth-card { width: 100%; max-width: 420px; background: var(--panel); border: 1px solid var(--line); border-radius: 20px; padding: 24px 22px 20px; }
.auth-top { display: flex; justify-content: space-between; align-items: center; }
.auth-top .brand { padding: 0; }
.auth-top .brand span { display: inline; }
.auth-lang { display: flex; border: 1px solid var(--line); border-radius: 999px; overflow: hidden; font-size: 12px; }
.auth-lang button { padding: 5px 11px; color: var(--muted); }
.auth-lang button + button { border-left: 1px solid var(--line); }
.auth-lang button.on { background: var(--grad); color: #fff; font-weight: 600; }
.auth-tag { color: var(--muted); margin: 10px 0 18px; font-size: 14px; }
.auth-tabs { display: grid; grid-template-columns: 1fr 1fr; background: var(--panel-2); border-radius: 12px; padding: 4px; margin-bottom: 18px; }
.auth-tabs button { padding: 9px; border-radius: 9px; color: var(--muted); font-weight: 600; font-size: 14px; }
.auth-tabs button.on { background: var(--bg); color: var(--text); }
.auth-form { display: flex; flex-direction: column; gap: 12px; }
.auth-form > label:not(.check) { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--muted); font-weight: 600; }
.auth-form input:not([type="checkbox"]), .auth-form select { padding: 11px 13px; border-radius: 12px; background: var(--panel-2); border: 1px solid var(--line); color: var(--text); outline: none; font-weight: 400; font-size: 16px; width: 100%; }
.auth-form input:focus, .auth-form select:focus { border-color: var(--accent); }
.auth-hint { color: var(--muted); font-size: 12px; margin-top: -6px; }
#auth:not(.reg) .reg-only { display: none; }
.rules { background: var(--panel-2); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; font-size: 13px; }
.rules ul { margin: 6px 0 0; padding-left: 18px; color: #cfcdd8; display: flex; flex-direction: column; gap: 4px; }
.check { display: flex; gap: 10px; align-items: flex-start; font-size: 14px; cursor: pointer; }
.check input { width: 18px; height: 18px; margin: 2px 0 0; accent-color: var(--accent); flex: none; }
.auth-err { color: #ff9a9a; font-size: 13px; margin: 0; }
.auth-err:empty { display: none; }
.auth-form .primary { padding: 12px 20px; margin-top: 4px; }
.auth-form .primary:disabled { opacity: .6; }
.auth-foot { color: var(--muted); font-size: 12px; margin: 0; text-align: center; }
.auth-google { display: flex; flex-direction: column; gap: 10px; margin-bottom: 4px; }
.auth-google .check { font-size: 13px; color: var(--muted); }
.google-btn { display: flex; align-items: center; justify-content: center; gap: 10px; padding: 12px 16px; border-radius: 12px; background: #fff; color: #1f1f1f; border: 1px solid #dadce0; font-weight: 600; font-size: 15px; cursor: pointer; }
.google-btn svg { width: 20px; height: 20px; }
.google-btn:disabled { opacity: .6; }
.auth-or { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 12px; margin: 4px 0; }
.auth-or::before, .auth-or::after { content: ""; flex: 1; height: 1px; background: var(--line); }

/* javno na mobitelu: donja traka umjesto bocne, popis razgovora, veci tekst da iOS ne zumira */
@media (max-width: 820px) {
  .public .shell { grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(0, 1fr) auto; }
  .public main { grid-row: 1; }
  .public .rail { grid-row: 2; flex-direction: row; align-items: stretch; justify-content: space-around; gap: 0; padding: 4px 4px calc(4px + env(safe-area-inset-bottom)); border-right: 0; border-top: 1px solid var(--line); }
  .public .rail .brand { display: none; }
  .public .nav { flex: 1; flex-direction: column; align-items: center; gap: 2px; padding: 6px 2px; font-size: 11px; border-radius: 10px; }
  .public .nav span { display: inline; white-space: nowrap; }
  .public .rail .nav.fb { margin-top: 0; }
  .public .back { display: grid; }
  .public .convo-head { padding: 8px 12px; gap: 8px; }
  .public .tools { gap: 10px; }
  .public .tools .ghost { padding: 7px 12px; white-space: nowrap; }
  .public .who { gap: 8px; }
  .public .messages { padding: 16px 12px 8px; }
  .public .msg { max-width: 88%; }
  .public .composer { padding: 8px 12px 10px; }
  .public .composer textarea { font-size: 16px; }
  .public .left-info { padding: 0 12px 8px; margin-top: -4px; }
  .public .page-head h1 { font-size: 25px; }
  .public .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .public .card .meta { padding: 12px; }
  .public .card .meta h3 { font-size: 17px; }
  .public .card .meta .tags { display: none; }
  .public .card-form { padding: 18px 16px; }
  .public .card-form input, .public .card-form textarea, .public .card-form select, .pdialog textarea { font-size: 16px; }
}
.check a { color: var(--accent); text-decoration: underline; }

/* ---- mobitel: zaglavlje razgovora (javna beta) ---- */
.public #accountCard { margin-bottom: 16px; }
@media (max-width: 820px) {
  .public .convo-head { padding: 8px 10px; gap: 6px; min-height: 56px; }
  .public .who { flex: 1; min-width: 0; }
  .public .who > div:last-child { min-width: 0; }
  .public .who .name { font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .public .who .sub { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 12px; }
  .public .tools { gap: 6px; flex-shrink: 0; }
  /* naracija: mali prekidac s kratkim natpisom ispod, da se zna sto je */
  .public .tools .switch { flex-direction: column; gap: 2px; }
  .public .tools .switch .lbl { display: block; font-size: 10px; line-height: 1; }
  .public .tools .switch .track { width: 34px; height: 20px; }
  .public .tools .switch .track::after { width: 14px; height: 14px; }
  .public .tools .switch input:checked + .track::after { transform: translateX(14px); }
  /* novi razgovor: ikona umjesto teksta */
  .public #newChat { font-size: 0; width: 40px; height: 40px; padding: 0; display: grid; place-items: center; border-radius: 12px; }
  .public #newChat::before { content: ""; width: 20px; height: 20px; background: currentColor;
    -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12 20h9'/%3E%3Cpath d='M16.5 3.5a2.1 2.1 0 0 1 3 3L7 19l-4 1 1-4z'/%3E%3C/svg%3E") center / contain no-repeat;
            mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12 20h9'/%3E%3Cpath d='M16.5 3.5a2.1 2.1 0 0 1 3 3L7 19l-4 1 1-4z'/%3E%3C/svg%3E") center / contain no-repeat; }
  .public .back { width: 36px; height: 36px; flex-shrink: 0; }
  .public .avatar.sm { width: 38px; height: 38px; flex-shrink: 0; }
}
