:root {
  --bg: #080608;
  --surface: #120a0b;
  --surface-2: #160a0a;
  --line: #2a1012;
  --line-hot: #3d1518;
  --ink: #e9e6e7;
  --muted: #a59ea0;
  --brand: #ef4444;
  --brand-dark: #7f1212;
  --brand-mid: #dc2626;
  --brand-tint: #2a0e10;
  --green: #22c55e;
  --display: "Space Grotesk", ui-sans-serif, system-ui, sans-serif;
  --stencil: "Oswald", "Space Grotesk", Impact, sans-serif;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  color: var(--ink);
  background-color: var(--bg);
  background-image:
    radial-gradient(60rem 50rem at 100% 0%, rgba(190, 30, 30, 0.18), transparent 60%),
    radial-gradient(50rem 50rem at 0% 100%, rgba(190, 30, 30, 0.12), transparent 60%);
  background-attachment: fixed;
  overscroll-behavior: none;
}
.hidden { display: none !important; }
.screen {
  position: fixed; inset: 0; display: flex; flex-direction: column;
  padding-top: env(safe-area-inset-top); padding-bottom: env(safe-area-inset-bottom);
}

/* ===== FX overlays (grain + vignette) ===== */
.fx { position: fixed; inset: 0; pointer-events: none; z-index: 40; }
.fx-grain {
  opacity: .32; mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='200' height='200'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='3'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.06'/%3E%3C/svg%3E");
}
.fx-vignette {
  z-index: 39;
  background:
    radial-gradient(120% 90% at 50% 0%, transparent 58%, rgba(0, 0, 0, .55) 100%),
    radial-gradient(80% 60% at 72% 6%, rgba(190, 30, 30, .10), transparent 60%);
}

/* ===== SVG brand marks ===== */
.grin { display: block; filter: drop-shadow(0 0 10px rgba(220, 30, 30, .55)); }
.audi-rings { display: block; filter: drop-shadow(0 0 8px rgba(220, 30, 30, .45)); }

/* ===== LOGIN ===== */
#login { align-items: center; justify-content: center; background: transparent; }
.login-box { text-align: center; width: 84%; max-width: 340px; position: relative; z-index: 2; }
.brand-lockup { display: flex; flex-direction: column; align-items: center; gap: 14px; margin-bottom: 22px; }
.brand-lockup .audi-rings { width: 132px; height: auto; }
.brand-lockup .grin-hero { width: 240px; height: auto; }
.login-box h1 {
  margin: 0; font-family: var(--display); font-size: 24px; font-weight: 700;
  letter-spacing: .2em; text-transform: uppercase; text-indent: .2em;
  color: var(--ink); max-width: 100%;
}
.login-box .sub {
  margin: 8px 0 30px; color: var(--muted); font-size: 12px;
  letter-spacing: .3em; text-transform: uppercase;
}
#pin {
  width: 100%; text-align: center; font-size: 22px; letter-spacing: 8px;
  padding: 15px; border: 1.5px solid var(--line-hot); border-radius: 12px;
  background: var(--surface); color: var(--ink); outline: none; margin-bottom: 12px;
  font-family: var(--display);
}
#pin::placeholder { color: #6b4a4c; letter-spacing: 4px; }
#pin:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(239, 68, 68, .16); }
#login-btn, #send-btn { font-family: inherit; }
#login-btn {
  width: 100%; padding: 15px; border: none; border-radius: 12px;
  background: linear-gradient(180deg, #ef4444, #b91c1c); color: #fff;
  font-family: var(--display); font-size: 15px; font-weight: 700;
  letter-spacing: .18em; text-transform: uppercase;
  box-shadow: 0 10px 28px -12px rgba(239, 68, 68, .8);
}
#login-btn:active { background: linear-gradient(180deg, #dc2626, #7f1212); }
.err { color: #ff6b6b; font-size: 13px; margin-top: 12px; min-height: 18px; letter-spacing: .02em; }

/* ===== HEADER ===== */
header {
  display: flex; align-items: center; gap: 10px; padding: 8px 12px;
  background: var(--surface); border-bottom: 1px solid var(--line-hot); flex-shrink: 0;
  box-shadow: 0 8px 26px -16px rgba(239, 68, 68, .5);
}
.logo-sm {
  width: 40px; height: 36px; border-radius: 10px; background: #0a0506;
  border: 1px solid var(--line-hot);
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
  position: relative;
}
.logo-sm .grin-mark { width: 30px; height: auto; }
.status-dot {
  position: absolute; right: -3px; bottom: -3px; width: 11px; height: 11px;
  border-radius: 50%; background: var(--muted); border: 2px solid var(--surface);
}
.status-dot.on { background: var(--green); box-shadow: 0 0 8px rgba(34, 197, 94, .8); }
.status-dot.off { background: var(--brand); box-shadow: 0 0 8px rgba(239, 68, 68, .8); }

/* BANNER */
.banner { padding: 9px 14px; font-size: 13px; line-height: 1.35; text-align: center; flex-shrink: 0; color: #fff; background: var(--surface-2); border-bottom: 1px solid var(--line); }
.banner.warn { background: #7a4a0a; }
.banner.err { background: #7f1212; }
.head-mid { flex: 1; min-width: 0; }
.head-title { font-family: var(--display); font-weight: 700; font-size: 15px; line-height: 1.1; letter-spacing: .22em; text-transform: uppercase; }
.org-pill {
  border: none; background: transparent; color: var(--brand);
  font-size: 11px; padding: 3px 0; display: inline-flex; align-items: center; gap: 3px;
  font-family: var(--display); letter-spacing: .14em; text-transform: uppercase;
}
.org-pill i { font-size: 13px; }
.icon-btn {
  width: 40px; height: 40px; border: none; background: transparent; color: var(--muted);
  border-radius: 10px; display: flex; align-items: center; justify-content: center;
}
.icon-btn i { font-size: 22px; }
.icon-btn:active { background: var(--surface-2); color: var(--brand); }

/* DRIVE LAUNCH (veliki crveni gumb odmah na pocetnom zaslonu) */
.drive-launch {
  flex-shrink: 0; margin: 12px 12px 4px; padding: 14px 16px;
  display: flex; align-items: center; gap: 14px; width: calc(100% - 24px);
  border: 1px solid #ef4444; border-radius: 18px; font-family: inherit;
  background: linear-gradient(135deg, #ef4444, #991b1b);
  color: #fff; text-align: left;
  box-shadow: 0 12px 30px -12px rgba(239, 68, 68, .85), inset 0 1px 0 rgba(255,255,255,.18);
  animation: dlpulse 2.6s ease-in-out infinite;
}
.drive-launch:active { background: linear-gradient(135deg, #dc2626, #7f1212); transform: scale(.99); }
.dl-orb {
  width: 46px; height: 46px; flex-shrink: 0; border-radius: 50%;
  background: rgba(0,0,0,.22); display: flex; align-items: center; justify-content: center;
}
.dl-orb i { font-size: 24px; }
.dl-txt { flex: 1; display: flex; flex-direction: column; line-height: 1.2; }
.dl-txt b { font-family: var(--display); font-size: 17px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; }
.dl-txt small { font-size: 12px; opacity: .85; margin-top: 2px; }
.dl-go { width: 34px; height: 34px; flex-shrink: 0; border-radius: 50%; background: rgba(0,0,0,.18); display: flex; align-items: center; justify-content: center; }
.dl-go i { font-size: 19px; }
@keyframes dlpulse {
  0%,100% { box-shadow: 0 12px 30px -12px rgba(239,68,68,.85), inset 0 1px 0 rgba(255,255,255,.18); }
  50% { box-shadow: 0 12px 42px -8px rgba(239,68,68,1), inset 0 1px 0 rgba(255,255,255,.18); }
}

/* MESSAGES */
#messages { flex: 1; overflow-y: auto; padding: 14px 12px 6px; display: flex; flex-direction: column; gap: 9px; }
.bubble {
  max-width: 84%; padding: 9px 13px; font-size: 15px; line-height: 1.45;
  border-radius: 16px; white-space: pre-wrap; word-wrap: break-word;
}
.bubble.user { align-self: flex-end; background: linear-gradient(180deg, #dc2626, #991b1b); color: #fff; border-bottom-right-radius: 5px; box-shadow: 0 6px 20px -12px rgba(239, 68, 68, .8); }
.bubble.assistant { align-self: flex-start; background: var(--surface); border: 1px solid var(--line); border-bottom-left-radius: 5px; }
.bubble.typing { align-self: flex-start; background: var(--surface); border: 1px solid var(--line); color: var(--muted); font-size: 14px; }
.bubble.typing.stream { color: var(--ink); font-size: 15px; }
.typing .dots span { animation: blink 1.2s infinite; }
.typing .dots span:nth-child(2){ animation-delay:.2s } .typing .dots span:nth-child(3){ animation-delay:.4s }
@keyframes blink { 0%,60%,100%{opacity:.25} 30%{opacity:1} }
.bubble .play {
  margin-top: 7px; display: inline-flex; align-items: center; gap: 7px;
  background: var(--surface-2); border: 1px solid var(--line); border-radius: 20px; padding: 5px 11px;
  color: var(--brand); font-size: 13px; font-family: inherit;
}
.bubble .play i { font-size: 15px; color: var(--brand); }

/* QUICK ACTIONS */
.quick-row {
  display: flex; gap: 7px; overflow-x: auto; padding: 6px 12px;
  flex-shrink: 0; scrollbar-width: none;
}
.quick-row::-webkit-scrollbar { display: none; }
.chip {
  white-space: nowrap; font-size: 12px; background: var(--brand-tint); color: #f87171;
  border: 1px solid var(--line-hot); padding: 7px 13px; border-radius: 20px; display: inline-flex; align-items: center; gap: 5px;
  font-family: inherit; flex-shrink: 0; letter-spacing: .02em;
}
.chip i { font-size: 15px; }
.chip:active { background: #3a1214; }

/* PRIVITAK u poruci */
.bubble .att-img { max-width: 100%; max-height: 220px; border-radius: 12px; display: block; }
.bubble .att-chip { background: rgba(255,255,255,.07); border-radius: 10px; padding: 6px 10px; font-size: 13px; display: inline-block; }
.bubble.user .att-chip { background: rgba(0,0,0,.22); }
.bubble .att-img + div, .bubble .att-chip + div { margin-top: 6px; }

/* GRESKA + retry */
.err-bubble { align-self: center; background: #2a0e10; border: 1px solid #7f1212; color: #ff9b8f; font-size: 13px; display: flex; align-items: center; gap: 10px; }
.err-bubble .retry { border: none; background: var(--brand); color: #fff; border-radius: 16px; padding: 5px 12px; font-family: inherit; font-size: 13px; }

/* PRETPREGLED priloga iznad inputa */
.attach-preview { display: flex; align-items: center; gap: 10px; padding: 8px 14px; background: var(--surface); border-top: 1px solid var(--line); }
.attach-preview img { width: 40px; height: 40px; object-fit: cover; border-radius: 8px; }
.attach-preview .att-name { flex: 1; font-size: 13px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.attach-preview .att-x { border: none; background: var(--surface-2); color: var(--muted); width: 28px; height: 28px; border-radius: 50%; font-size: 14px; }

/* INPUT */
.input-bar {
  display: flex; align-items: flex-end; gap: 8px; padding: 8px 12px 12px;
  background: var(--surface); border-top: 1px solid var(--line-hot); flex-shrink: 0;
}
#input {
  flex: 1; resize: none; max-height: 120px; font-family: inherit; font-size: 15px;
  padding: 10px 14px; border: 1px solid var(--line-hot); border-radius: 20px;
  background: var(--surface-2); color: var(--ink); outline: none; line-height: 1.35;
}
#input::placeholder { color: #6b4a4c; }
#input:focus { border-color: var(--brand); }
.round-btn {
  width: 42px; height: 42px; flex-shrink: 0; border: none; border-radius: 50%;
  background: linear-gradient(180deg, #ef4444, #b91c1c); color: #fff; display: flex; align-items: center; justify-content: center;
  box-shadow: 0 6px 18px -10px rgba(239, 68, 68, .9);
}
.round-btn i { font-size: 20px; }
.round-btn:active { background: linear-gradient(180deg, #dc2626, #7f1212); }
.round-btn.ghost { background: var(--surface-2); color: var(--muted); box-shadow: none; border: 1px solid var(--line-hot); }
.round-btn.ghost.rec { background: var(--brand); color: #fff; animation: pulse 1s infinite; }
@keyframes pulse { 0%,100%{transform:scale(1)} 50%{transform:scale(1.08)} }

/* SHEETS */
.sheet { position: fixed; inset: 0; background: rgba(0,0,0,.6); display: flex; align-items: flex-end; z-index: 50; }
.sheet-card {
  width: 100%; background: var(--surface); border: 1px solid var(--line-hot); border-bottom: none;
  border-radius: 20px 20px 0 0; padding: 10px 14px 24px;
  padding-bottom: calc(24px + env(safe-area-inset-bottom));
  box-shadow: 0 -10px 40px -12px rgba(239, 68, 68, .35);
}
.sheet-title { text-align: center; color: var(--brand); font-family: var(--display); font-size: 11px; padding: 8px 0 12px; font-weight: 700; letter-spacing: .28em; text-transform: uppercase; }
#org-list .org-opt, .menu-item {
  width: 100%; text-align: left; border: none; background: transparent; font-family: inherit;
  font-size: 16px; padding: 14px 8px; display: flex; align-items: center; gap: 12px; border-radius: 12px; color: var(--ink);
}
#org-list .org-opt:active, .menu-item:active { background: var(--surface-2); }
#org-list .org-opt.active { color: var(--brand); font-weight: 600; }
#org-list .org-opt.active::after { content: "✓"; margin-left: auto; color: var(--brand); }
.menu-item i, .row-toggle i { font-size: 20px; color: var(--muted); }
.menu-item.danger { color: var(--brand); } .menu-item.danger i { color: var(--brand); }
.row-toggle { display: flex; align-items: center; justify-content: space-between; padding: 12px 8px; font-size: 16px; color: var(--ink); }
.row-toggle span { display: flex; align-items: center; gap: 12px; }
.row-toggle input { width: 46px; height: 28px; appearance: none; background: var(--line-hot); border-radius: 20px; position: relative; transition: .2s; }
.row-toggle input:checked { background: var(--brand); }
.row-toggle input::after { content: ""; position: absolute; width: 22px; height: 22px; border-radius: 50%; background: #fff; top: 3px; left: 3px; transition: .2s; }
.row-toggle input:checked::after { left: 21px; }
.menu-foot { text-align: center; color: var(--muted); font-size: 11px; padding-top: 14px; letter-spacing: .1em; }

/* HISTORY */
.hist-search { display: flex; align-items: center; gap: 8px; margin: 12px; padding: 10px 14px; background: var(--surface); border: 1px solid var(--line-hot); border-radius: 14px; }
.hist-search i { color: var(--muted); font-size: 18px; }
.hist-search input { flex: 1; border: none; background: transparent; outline: none; font-family: inherit; font-size: 15px; color: var(--ink); }
.hist-search input::placeholder { color: #6b4a4c; }
#hist-list { flex: 1; overflow-y: auto; padding: 0 12px 20px; }

/* skill-prijedlozi (Hermes model) */
.skills-count { margin-left: auto; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px; background: var(--brand); color: #fff; font-size: 12px; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; }
.skills-dot { position: absolute; top: 6px; right: 6px; width: 9px; height: 9px; border-radius: 50%; background: var(--brand); box-shadow: 0 0 6px var(--brand); }
#menu-btn { position: relative; }
.skills-hint { padding: 12px 16px 4px; font-size: 13px; color: var(--muted); line-height: 1.45; }
.skills-body { flex: 1; overflow-y: auto; margin: 8px 12px 20px; padding: 14px; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 12.5px; line-height: 1.5; color: var(--ink); white-space: pre-wrap; word-break: break-word; }
.hist-item { padding: 12px 14px; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; margin-bottom: 8px; }
.hist-item .who { font-size: 11px; color: var(--brand); font-weight: 700; margin-bottom: 3px; letter-spacing: .1em; text-transform: uppercase; }
.hist-item .txt { font-size: 14px; color: var(--ink); line-height: 1.4; }
.hist-item .when { font-size: 11px; color: var(--muted); margin-top: 5px; }
.hist-empty { text-align: center; color: var(--muted); padding: 40px 20px; font-size: 15px; }

/* VOZNJA (hands-free) */
#drive {
  color: #fff; z-index: 60;
  background:
    radial-gradient(80% 55% at 50% 40%, rgba(190, 30, 30, .35), transparent 70%),
    #0a0506;
}
.drive-top { display: flex; align-items: center; justify-content: space-between; padding: 14px 18px; }
.drive-org { font-family: var(--display); font-size: 12px; opacity: .85; font-weight: 600; letter-spacing: .2em; text-transform: uppercase; color: #f87171; }
.drive-x { width: 44px; height: 44px; border: none; background: rgba(239, 68, 68, .14); color: #fff; border-radius: 50%; display: flex; align-items: center; justify-content: center; }
.drive-x i { font-size: 24px; }
.drive-brand { display: flex; justify-content: center; padding: 4px 0 2px; }
.drive-brand .drive-audi { width: 118px; height: auto; }
.drive-center { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 0 26px; text-align: center; }
.orb {
  width: 240px; height: 240px; flex-shrink: 0; border-radius: 50%; padding: 0;
  border: 1px solid rgba(239, 68, 68, .28); font-family: inherit; cursor: pointer;
  background:
    radial-gradient(circle at 50% 46%, rgba(239, 68, 68, .55), rgba(153, 27, 27, .18) 55%, transparent 72%);
  display: flex; align-items: center; justify-content: center; margin-bottom: 34px; transition: transform .15s;
}
.orb .grin-drive { width: 176px; height: auto; filter: drop-shadow(0 0 18px rgba(239, 68, 68, .85)); }
.orb:active { transform: scale(.97); }
.orb.listen { animation: orbpulse 1.6s ease-in-out infinite; }
.orb.think { animation: orbpulse .9s ease-in-out infinite; }
.orb.speak { animation: orbpulse .6s ease-in-out infinite; }
@keyframes orbpulse { 0%,100%{ transform: scale(1); } 50%{ transform: scale(1.09); } }
.drive-state { font-family: var(--display); font-size: 24px; font-weight: 700; margin-bottom: 14px; letter-spacing: .12em; text-transform: uppercase; }
.drive-text { font-size: 19px; line-height: 1.4; opacity: .95; max-height: 34vh; overflow: hidden; }
.drive-stop { margin: 0 18px 26px; padding: 18px; border: 1px solid var(--line-hot); border-radius: 16px; background: rgba(0,0,0,.4); color: #fff; font-family: var(--display); font-size: 15px; font-weight: 700; letter-spacing: .16em; text-transform: uppercase; }
.drive-stop:active { background: rgba(239, 68, 68, .25); }
#drive-btn i { font-size: 24px; }

.org-del { margin-left: auto; color: var(--muted); padding: 2px 8px; font-size: 14px; }
.org-del:active { color: var(--brand); }
#org-list .org-opt.active .org-del { margin-left: 8px; }

/* NOVA TEMA (org sheet) */
#org-list .org-opt.org-new { color: var(--brand); border: 1px dashed var(--line-hot); margin-top: 6px; justify-content: center; }

/* ACTION ROW (UBACI + SASTANAK, dva polugumba ispod Vožnje) */
.action-row { display: flex; gap: 8px; margin: 4px 12px; flex-shrink: 0; }
.action-btn {
  flex: 1; height: 52px; display: flex; align-items: center; justify-content: center; gap: 9px;
  border: 1px solid var(--line-hot); border-radius: 14px; font-family: var(--display);
  background: var(--surface); color: var(--ink);
  font-size: 14px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase;
}
.action-btn:active { background: var(--surface-2); }
.action-btn .ab-ico { display: inline-flex; }
.action-btn .ab-ico i { font-size: 20px; color: var(--brand); }

/* CAPTURE SHEET (UBACI) */
.cap-text {
  width: 100%; min-height: 92px; resize: none; font-family: inherit; font-size: 15px;
  padding: 12px 14px; border: 1px solid var(--line-hot); border-radius: 14px;
  background: var(--surface-2); color: var(--ink); outline: none; line-height: 1.4; margin-bottom: 10px;
}
.cap-text::placeholder { color: #6b4a4c; }
.cap-text:focus { border-color: var(--brand); }
.cap-tools { display: flex; gap: 8px; margin-bottom: 10px; }
.cap-tool {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 5px;
  padding: 11px 4px; border: 1px solid var(--line-hot); border-radius: 12px;
  background: var(--surface-2); color: var(--muted); font-family: inherit; font-size: 11px;
}
.cap-tool i { font-size: 21px; color: var(--brand); }
.cap-tool:active { background: #3a1214; }
.cap-tool.rec { background: var(--brand); color: #fff; }
.cap-tool.rec i { color: #fff; }
#cap-preview { border-top: none; border: 1px solid var(--line); border-radius: 12px; margin-bottom: 10px; }
.cap-send {
  width: 100%; padding: 15px; border: none; border-radius: 14px;
  background: linear-gradient(180deg, #ef4444, #b91c1c); color: #fff;
  font-family: var(--display); font-size: 15px; font-weight: 700; letter-spacing: .18em; text-transform: uppercase;
  box-shadow: 0 10px 28px -12px rgba(239, 68, 68, .8);
}
.cap-send:active { background: linear-gradient(180deg, #dc2626, #7f1212); }
.shake { animation: shake .4s; }
@keyframes shake { 0%,100%{transform:translateX(0)} 20%,60%{transform:translateX(-8px)} 40%,80%{transform:translateX(8px)} }

/* SASTANAK */
#meet { display: flex; flex-direction: column; background: var(--bg); }
.meet-state {
  font-family: var(--display); font-size: 15px; font-weight: 700; color: var(--brand);
  letter-spacing: .14em; text-transform: uppercase; padding: 6px 18px 10px;
}
#meet-log { flex: 1; overflow-y: auto; padding: 4px 18px 12px; }
.meet-line { font-size: 14px; line-height: 1.5; color: var(--muted); margin-bottom: 10px; border-left: 2px solid var(--line-hot); padding-left: 10px; }
.meet-line:last-child { color: var(--ink); }

/* Red scrollbar */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-thumb { background: var(--brand-mid); border-radius: 4px; }
::-webkit-scrollbar-track { background: var(--surface-2); }
