/* JARVIS 8.0.9 — оболочка сайта как в приложении: нижняя панель из пяти разделов (Сервер, Джарвис, Чаты, Инструменты, Меню),
   маленький щит с «.ru» вверху, шестерёнка настроек на каждом экране, плитки инструментов. Подключается последним. */
:root { --nav-h: 74px; --tile-r: 18px; --bubble-mine: var(--accent); --bubble-theirs: var(--surface); --bubble-mine-text: #06222a; --good: var(--green, #4fd18b); --warn: var(--amber, #f0b340); }
body.has-nav .screen:not(.tool-view) { height: calc(100% - var(--nav-h) - var(--safe-b)); }
body.has-nav.in-chat .screen { height: 100%; }
body.has-nav #drawer { inset: 0 0 calc(var(--nav-h) + var(--safe-b)) 0 !important; width: auto !important; max-width: none !important; border-radius: 0 !important; box-shadow: none !important; }
body.has-nav #drawer .drawer-head h2 { letter-spacing: .06em; font-weight: 700; font-size: 22px; }
body.has-nav #drawer-close { display: none; }

/* шапка: щит + «.ru», заголовок, шестерёнка */
.topbar { gap: 10px; padding-left: 14px !important; padding-right: 10px !important; }
.topbar::before { display: none !important; }
.brand-shield { position: relative; flex: none; width: 34px; height: 40px; }
.brand-shield img { width: 34px; height: 40px; display: block; }
.topbar .logo { font-size: 22px !important; letter-spacing: .02em !important; margin-left: 6px; }
.topbar .brand { margin-left: 4px; }
.gear { width: 44px; height: 44px; padding: 10px !important; border-radius: 14px !important; background: var(--surface) !important; flex: none; }
.gear svg { width: 100%; height: 100%; }
.status .st-label { display: none; }
.hud { padding: 0; }
.hud #core, .hud .shield, #titan-talk { display: none !important; }
.hud .state-label { margin: 0; padding: 2px 14px 0; letter-spacing: .12em; text-align: center; }

/* старая металлическая рамка (titan.css, black-metal.css) отменяется: ровные скруглённые панели */
.card, .composer, .pair-card, .msg.assistant, .msg-row, .owner-banner, .sheet, .modal-card, .msg-pinned, .titan-setting, .titan-font-preview, .drawer {
  border: 0 !important; background: var(--surface) !important; box-shadow: none !important; border-radius: var(--radius) !important; }
.drawer { background: var(--bg2) !important; border-radius: 0 !important; }
.msg.assistant { background: var(--bubble-theirs) !important; border-radius: 18px 18px 18px 5px !important; }
.msg.user { border: 0 !important; box-shadow: none !important; }
.composer { border-radius: 24px !important; margin: 6px 10px 8px !important; }
.card::before, .card::after, .composer::before, .composer::after, .sheet::before, .sheet::after, .pair-card::after, .owner-banner::after, .drawer::before, .drawer::after { display: none !important; }
.composer select { background: var(--surface-2, var(--surface)) !important; border-radius: 14px !important; }
.drawer-head { border-bottom: 0 !important; }

/* страницы разделов */
.page > * { flex-shrink: 0; }
.page { flex: 1; overflow-y: auto; padding: 8px 16px 24px; display: flex; flex-direction: column; gap: 12px; }
.page .card { margin: 0 !important; }
.section-title { margin: 6px 4px 0; font-size: 12px; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); font-weight: 700; }

/* нижняя панель */
.bnav { position: fixed; z-index: 60; left: 10px; right: 10px; bottom: calc(8px + var(--safe-b)); height: 62px; display: flex; align-items: stretch; gap: 2px; padding: 6px;
  background: var(--surface); border-radius: 26px; box-shadow: 0 10px 30px rgba(0,0,0,.35), inset 0 0 0 1px var(--line); max-width: 640px; margin: 0 auto; }
body.in-chat .bnav { display: none !important; }
.bnav button { flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; padding: 4px 2px !important; border-radius: 20px !important;
  background: transparent !important; box-shadow: none !important; color: var(--muted); font-size: 11px; font-weight: 600; position: relative; }
.bnav button:active { transform: scale(.94); }
.bnav button svg { width: 24px; height: 24px; }
.bnav button.on { color: var(--accent); background: color-mix(in srgb, var(--accent) 16%, transparent) !important; }
.bnav .badge { position: absolute; top: 2px; right: calc(50% - 22px); background: var(--accent); color: #06222a; border-radius: 9px; min-width: 17px; height: 17px; font-size: 11px; line-height: 17px; text-align: center; padding: 0 4px; }

svg.ic { fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* чаты: в списке без стрелки «назад» (раздел открывается нижней панелью) */
body.chats-list #msg-back { display: none; }
body:not(.chats-list) #msg-gear, body:not(.chats-list) #msg-screen .brand-shield { display: none; }
.msg-row { display: flex; align-items: center; gap: 12px; }
.msg-row .row-text { min-width: 0; flex: 1; }
.msg-row .row-text b { display: block; }

/* сервер */
.hero { display: flex; align-items: center; gap: 14px; padding: 16px; border-radius: 22px; background: var(--surface); }
.hero .big { font-size: 20px; font-weight: 700; }
.hero .sub { color: var(--muted); font-size: 13px; }
.pulse { width: 14px; height: 14px; border-radius: 50%; background: var(--muted); flex: none; }
.pulse.ok { background: var(--good); box-shadow: 0 0 0 5px color-mix(in srgb, var(--good) 22%, transparent); }
.pulse.warn { background: var(--warn); box-shadow: 0 0 0 5px color-mix(in srgb, var(--warn) 22%, transparent); }
.pulse.bad { background: #f0584a; box-shadow: 0 0 0 5px rgba(240,88,74,.22); }
.stat-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.stat { background: var(--surface); border-radius: var(--tile-r); padding: 14px; display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.stat .k { color: var(--muted); font-size: 12px; }
.stat .v { font-size: 20px; font-weight: 700; overflow-wrap: anywhere; }
.stat .v.ok { color: var(--good); } .stat .v.warn { color: var(--warn); } .stat .v.bad { color: #f0584a; }
.bar { height: 6px; border-radius: 3px; background: color-mix(in srgb, var(--text) 12%, transparent); overflow: hidden; margin-top: 6px; }
.bar > i { display: block; height: 100%; background: var(--accent); border-radius: 3px; }
.action { display: flex; align-items: center; gap: 12px; padding: 14px 16px; background: var(--surface); border-radius: var(--tile-r); color: var(--text); text-decoration: none; width: 100%; text-align: left; }
.action .t { font-weight: 700; } .action .s { color: var(--muted); font-size: 12.5px; }
.action > div { flex: 1; min-width: 0; }
.gem { width: 42px; height: 42px; border-radius: 14px; display: flex; align-items: center; justify-content: center; flex: none; color: #fff; box-shadow: inset 0 -3px 0 rgba(0,0,0,.22); }
.gem svg { width: 24px; height: 24px; }

/* инструменты */
#tool-search { width: 100%; box-sizing: border-box; border-radius: 16px !important; background: var(--surface) !important; padding: 12px 16px; }
.chips { display: flex; gap: 8px; overflow-x: auto; padding: 2px 0 4px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; padding: 8px 14px !important; border-radius: 18px !important; font-size: 14px; background: var(--surface-2, var(--surface)) !important; color: var(--text); }
.chip.on { background: var(--accent) !important; color: #06222a !important; }
.tool-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.tile { position: relative; display: flex; flex-direction: column; align-items: flex-start; gap: 8px; text-align: left; padding: 14px !important; min-height: 120px; border-radius: var(--tile-r) !important; background: var(--surface) !important; }
.tile .t { font-weight: 700; font-size: 15px; line-height: 1.2; }
.tile .s { color: var(--muted); font-size: 12px; font-weight: 400; line-height: 1.3; }
.tile .star { position: absolute; top: 10px; right: 12px; color: var(--warn); font-size: 16px; }
/* 8.0.126: фирменный оттенок плитки — тонкая полоска слева в цвет значка (как в приложении) */
.tile { border-left: 3px solid var(--tint, var(--accent)) !important; }
.tool-view { position: fixed; inset: 0; z-index: 70; background: var(--bg); height: 100% !important; }
.field { display: flex; flex-direction: column; gap: 5px; }
.field label { font-size: 13px; color: var(--muted); }
.field .unit { color: var(--muted); font-size: 13px; }
.field input, .field select { width: 100%; box-sizing: border-box; background: var(--surface) !important; border-radius: 14px !important; padding: 12px 14px; font-size: 17px; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.result { background: var(--surface); border-radius: var(--tile-r); padding: 6px 16px; }
.result .r { display: flex; justify-content: space-between; gap: 12px; padding: 11px 0; border-bottom: 1px solid var(--line); }
.result .r:last-child { border-bottom: 0; }
.result .r span { color: var(--muted); }
.result .r b { font-size: 17px; text-align: right; overflow-wrap: anywhere; }
.hint { color: var(--muted); font-size: 13px; padding: 4px 2px; }
.hint.err { color: #f0584a; }
.bands { display: flex; gap: 8px; flex-wrap: wrap; align-items: flex-end; }
.bands select { width: auto; min-width: 0; font-size: 14px; padding: 8px; }
.resistor { height: 46px; border-radius: 23px; background: #c9b693; display: flex; align-items: stretch; justify-content: center; gap: 12px; padding: 0 28px; box-shadow: inset 0 3px 6px rgba(255,255,255,.35), inset 0 -4px 8px rgba(0,0,0,.25); }
.resistor i { width: 12px; display: block; }
table.pins { width: 100%; border-collapse: collapse; font-size: 14px; }
table.pins td { padding: 9px 6px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.pins td:first-child { font-weight: 700; white-space: nowrap; color: var(--accent); }
.note-card { background: var(--surface); border-radius: var(--tile-r); padding: 12px 14px; display: flex; gap: 10px; align-items: flex-start; }
.note-card .x { margin-left: auto; background: transparent !important; box-shadow: none !important; color: var(--muted); }
.note-card p { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; flex: 1; }
.calc-display { background: var(--surface); border-radius: var(--tile-r); padding: 14px 16px; min-height: 64px; display: flex; flex-direction: column; justify-content: flex-end; align-items: flex-end; gap: 4px; }
.calc-display .res { font-size: 30px; font-weight: 700; overflow-wrap: anywhere; text-align: right; }
.calc-display .res.err { color: #f0584a; font-size: 15px; }
.keys { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.keys button { min-height: 52px; font-size: 20px; border-radius: 16px !important; }
.keys button.op { color: var(--accent); }
.keys button.eq { background: var(--accent) !important; color: #06222a !important; }
.tabs-inline { display: flex; gap: 8px; flex-wrap: wrap; }

/* цвета и вид (меню) */
.swatches { display: flex; gap: 10px; overflow-x: auto; padding: 4px 0 8px; scrollbar-width: none; }
.preset { flex: none; width: 138px; padding: 10px 12px !important; border-radius: 16px !important; text-align: left; display: flex; flex-direction: column; gap: 8px; }
.preset .dots { display: flex; gap: 4px; }
.preset .dots i { width: 18px; height: 18px; border-radius: 50%; box-shadow: inset 0 0 0 1px rgba(128,128,128,.4); }
.preset.on { box-shadow: inset 0 0 0 3px var(--accent) !important; }
.color-row { display: flex; align-items: center; gap: 12px; padding: 8px 0; }
.color-row input[type=color] { width: 44px; height: 34px; padding: 0; border-radius: 10px !important; background: transparent !important; flex: none; }
.color-row .name { flex: 1; }
.color-row .name small { display: block; color: var(--muted); }
.color-row button { padding: 6px 10px !important; font-size: 13px; }
.slider-row { display: flex; flex-direction: column; gap: 4px; padding: 6px 0; }
.slider-row .head { display: flex; justify-content: space-between; }
.slider-row input[type=range] { width: 100%; accent-color: var(--accent); background: transparent !important; box-shadow: none !important; padding: 0 !important; }
.look-preview { background: var(--bg); border-radius: 16px; padding: 12px; display: flex; flex-direction: column; gap: 8px; box-shadow: inset 0 0 0 1px var(--line); }
.look-preview .b { padding: 8px 12px; border-radius: 16px; max-width: 80%; font-size: 14px; }
.look-preview .b.mine { align-self: flex-end; background: var(--bubble-mine); color: var(--bubble-mine-text); border-bottom-right-radius: 5px; }
.look-preview .b.theirs { align-self: flex-start; background: var(--bubble-theirs); color: var(--text); border-bottom-left-radius: 5px; }

/* пузыри берут цвета из настроек вида */
.msg.user { background: var(--bubble-mine) !important; color: var(--bubble-mine-text) !important; }
.msg.assistant { background: var(--bubble-theirs) !important; }

/* картинки, нарисованные JARVIS */
.gen-image { margin: 0; display: flex; flex-direction: column; gap: 8px; max-width: 100%; }
.gen-image img { width: 100%; max-width: 520px; border-radius: 16px; display: block; background: var(--surface-2, var(--surface)); }
.gen-image figcaption { color: var(--muted); font-size: 13px; }
.gen-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.gen-actions .button, .gen-actions button { padding: 8px 14px; min-height: 0; font-size: 14px; text-decoration: none; display: inline-flex; align-items: center; }
.msg.assistant:has(.gen-image) { max-width: min(560px, 96%); }

/* аватары, истории, контакты */
.av { display: inline-flex; align-items: center; justify-content: center; border-radius: 50%; color: #fff; font-weight: 700; flex: none; background-size: cover; background-position: center; box-shadow: inset 0 -3px 0 rgba(0,0,0,.18); }
.av.plus { background: var(--surface-2, var(--surface)) !important; color: var(--accent); }
.story-row { display: flex; gap: 12px; overflow-x: auto; padding: 4px 2px 12px; scrollbar-width: none; }
.story-row::-webkit-scrollbar { display: none; }
.story-bubble { flex: none; width: 66px; display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 0 !important; background: transparent !important; box-shadow: none !important; color: var(--text); }
.story-bubble small { font-size: 12px; max-width: 66px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); }
.story-bubble .av { box-shadow: 0 0 0 3px var(--bg), 0 0 0 5px var(--muted); }
.story-bubble.new .av, .story-bubble.has .av { box-shadow: 0 0 0 3px var(--bg), 0 0 0 5px var(--accent); }
.add-contact { width: 100%; margin-top: 8px; }
.story-view { position: fixed; inset: 0; z-index: 90; background: #000; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.story-view img { max-width: 100%; max-height: 100%; object-fit: contain; }
.story-bars { position: absolute; top: calc(8px + var(--safe-t)); left: 10px; right: 10px; display: flex; gap: 4px; z-index: 3; }
.story-bars i { flex: 1; height: 3px; border-radius: 2px; background: rgba(255,255,255,.35); overflow: hidden; position: relative; }
.story-bars i.done { background: #fff; }
.story-bars i.now::after { content: ""; position: absolute; inset: 0; background: #fff; transform-origin: left; animation: storybar 6s linear forwards; }
@keyframes storybar { from { transform: scaleX(0); } to { transform: scaleX(1); } }
.story-head { position: absolute; top: calc(18px + var(--safe-t)); left: 10px; right: 10px; display: flex; align-items: center; gap: 10px; z-index: 3; color: #fff; }
.story-head .story-who { flex: 1; display: flex; flex-direction: column; font-size: 14px; }
.story-head .icon-btn { color: #fff; }
.story-cap { position: absolute; bottom: calc(70px + var(--safe-b)); left: 16px; right: 16px; text-align: center; color: #fff; font-size: 17px; text-shadow: 0 1px 6px #000; z-index: 3; }
.story-tools { position: absolute; bottom: calc(14px + var(--safe-b)); left: 16px; right: 16px; display: flex; gap: 10px; justify-content: center; z-index: 4; }
.story-hit { position: absolute; top: 60px; bottom: 90px; width: 40%; z-index: 2; }
.story-hit.prev { left: 0; } .story-hit.next { right: 0; }
