@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

:root {
  --bg: #0b0d12; --bg-2: #10131a; --surface: #161a23; --surface-2: #1c2130; --line: rgba(255,255,255,.08); --line-2: rgba(255,255,255,.14);
  --text: #e9ecf3; --text-2: #a4abbd; --muted: #6c7386;
  --accent: #7c6cff; --accent-2: #a78bfa; --accent-grad: linear-gradient(135deg, #6d5dfc 0%, #a855f7 100%);
  --ok: #34d399; --warn: #fbbf24; --danger: #fb7185;
  --radius: 14px; --shadow: 0 20px 60px rgba(0,0,0,.45), 0 2px 8px rgba(0,0,0,.3);
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font: 14px/1.45 Inter, -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", sans-serif; color: var(--text);
  background: radial-gradient(1200px 600px at 20% -10%, rgba(124,108,255,.18), transparent 60%),
              radial-gradient(900px 500px at 100% 0%, rgba(168,85,247,.12), transparent 55%), var(--bg);
  display: flex; flex-direction: column; overflow: hidden; -webkit-font-smoothing: antialiased;
}
a { color: var(--accent-2); text-decoration: none; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; border-radius: 10px; padding: 7px 10px; transition: background .15s, color .15s, transform .1s; }
button:hover { background: rgba(255,255,255,.06); }
button:active { transform: scale(.97); }
button.on { background: rgba(124,108,255,.18); color: #cfc8ff; }
button.primary { background: var(--accent-grad); color: #fff; padding: 9px 16px; font-weight: 600; white-space: nowrap; box-shadow: 0 6px 20px rgba(124,108,255,.35); }
button.primary:hover { filter: brightness(1.08); }
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 8px 14px; border-radius: 10px; background: rgba(255,255,255,.06); color: var(--text); font-weight: 500; border: 1px solid var(--line); transition: background .15s; white-space: nowrap; }
.btn:hover { background: rgba(255,255,255,.1); }
.btn.primary { background: var(--accent-grad); border-color: transparent; color: #fff; box-shadow: 0 6px 20px rgba(124,108,255,.3); }
.muted { color: var(--text-2); } .small { font-size: 12px; }
code { font: 12px ui-monospace, "SF Mono", Menlo, monospace; background: rgba(255,255,255,.06); padding: 2px 6px; border-radius: 6px; word-break: break-all; color: #c7d2fe; }
svg.i { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* ── top bar ── */
.bar { display: flex; align-items: center; gap: 14px; padding: 0 16px; height: 56px; flex: none;
  background: rgba(16,19,26,.7); backdrop-filter: blur(18px) saturate(1.4); -webkit-backdrop-filter: blur(18px) saturate(1.4); border-bottom: 1px solid var(--line); }
.bar .back { display: inline-flex; align-items: center; justify-content: center; width: 36px; height: 36px; border-radius: 10px; color: var(--text-2); border: 1px solid var(--line); }
.bar .back:hover { color: var(--text); background: rgba(255,255,255,.06); }
.bar .title { display: flex; flex-direction: column; line-height: 1.2; min-width: 140px; }
.bar .title b { font-weight: 600; }
.bar .title span { font-size: 11.5px; color: var(--muted); max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-family: ui-monospace, Menlo, monospace; }
.seg { display: inline-flex; background: rgba(255,255,255,.05); border: 1px solid var(--line); border-radius: 12px; padding: 3px; }
.seg button { display: inline-flex; align-items: center; gap: 7px; padding: 6px 12px; border-radius: 9px; color: var(--text-2); }
.seg button.on { background: var(--surface-2); color: var(--text); box-shadow: 0 1px 3px rgba(0,0,0,.4); }
.right { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.pill { display: inline-flex; align-items: center; gap: 6px; background: rgba(255,255,255,.05); border: 1px solid var(--line); border-radius: 20px; padding: 5px 12px; font-size: 12.5px; color: var(--text-2); }
.pill b { color: var(--text); font-weight: 600; }

/* ── main ── */
.main { flex: 1; display: flex; min-height: 0; }
.stage { flex: 1; position: relative; overflow: auto; display: flex; justify-content: center; align-items: flex-start; padding: 22px 22px 110px; }
#frameBox { position: relative; }
.chrome { display: none; height: 38px; align-items: center; gap: 8px; padding: 0 12px; background: #1b1f2a; border: 1px solid var(--line-2); border-bottom: 0; border-radius: 12px 12px 0 0; }
.chrome i { width: 11px; height: 11px; border-radius: 50%; background: #3a4052; display: inline-block; }
.chrome i:nth-child(1) { background: #ff5f57; } .chrome i:nth-child(2) { background: #febc2e; } .chrome i:nth-child(3) { background: #28c840; }
.chrome span { flex: 1; margin-left: 10px; height: 24px; background: rgba(255,255,255,.06); border-radius: 7px; font: 11.5px ui-monospace, Menlo, monospace; color: var(--text-2); display: flex; align-items: center; padding: 0 10px; overflow: hidden; white-space: nowrap; }
.frame { position: relative; background: #fff; box-shadow: var(--shadow); overflow: hidden; }
.frame.device-mobile { width: 390px; height: min(844px, calc(100vh - 56px - 44px - 88px)); border-radius: 44px; border: 10px solid #0f1117; outline: 1px solid rgba(255,255,255,.12); }
.frame.device-mobile::before { content: ""; position: absolute; top: 10px; left: 50%; transform: translateX(-50%); width: 110px; height: 26px; background: #0f1117; border-radius: 0 0 16px 16px; z-index: 5; pointer-events: none; }
.device-desktop .chrome, #frameBox.desktop .chrome { display: flex; }
.frame.device-desktop { width: 1280px; height: 800px; transform-origin: top left; border-radius: 0 0 12px 12px; border: 1px solid var(--line-2); border-top: 0; }
.frame iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; background: #fff; }
.frame canvas { position: absolute; inset: 0; pointer-events: none; }

/* ── floating toolbar ── */
.tools { position: absolute; left: 50%; bottom: 22px; transform: translateX(-50%); display: flex; align-items: center; gap: 2px; padding: 6px;
  background: rgba(22,26,35,.82); backdrop-filter: blur(20px) saturate(1.5); -webkit-backdrop-filter: blur(20px) saturate(1.5);
  border: 1px solid var(--line-2); border-radius: 18px; box-shadow: var(--shadow); z-index: 20; }
.tools button { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 7px 10px; min-width: 60px; border-radius: 12px; color: var(--text-2); }
.tools button svg.i { width: 20px; height: 20px; }
.tools button span { font-size: 10.5px; letter-spacing: .01em; }
.tools button:hover { color: var(--text); }
.tools button.on { background: var(--accent-grad); color: #fff; box-shadow: 0 6px 18px rgba(124,108,255,.35); }
.tools .sep { width: 1px; height: 30px; background: var(--line-2); margin: 0 6px; }
.colors { display: flex; gap: 6px; padding: 0 6px; }
.sw { width: 20px; height: 20px; border-radius: 50%; padding: 0; border: 2px solid transparent; box-shadow: inset 0 0 0 1px rgba(0,0,0,.3); }
.sw:hover { transform: scale(1.12); background: inherit; }
.sw.on { border-color: #fff; }
.hint { position: absolute; left: 50%; bottom: 96px; transform: translateX(-50%); background: rgba(22,26,35,.9); border: 1px solid var(--line); color: var(--text-2); font-size: 12px; padding: 7px 14px; border-radius: 10px; opacity: 0; pointer-events: none; transition: opacity .2s; white-space: nowrap; max-width: 90%; overflow: hidden; text-overflow: ellipsis; z-index: 19; }
.hint.show { opacity: 1; }

/* ── side panel ── */
.panel { width: 340px; flex: none; background: rgba(16,19,26,.6); border-left: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; backdrop-filter: blur(12px); }
.panel-head { padding: 16px 18px 12px; border-bottom: 1px solid var(--line); display: flex; flex-direction: column; gap: 2px; }
.panel-head b { font-size: 15px; font-weight: 600; }
.panel-foot { padding: 12px 18px; border-top: 1px solid var(--line); color: var(--muted); font-size: 11.5px; line-height: 1.6; }
.panel-foot kbd { display: inline-block; min-width: 18px; text-align: center; padding: 0 5px; border-radius: 5px; background: rgba(255,255,255,.07); border: 1px solid var(--line-2); font: 10.5px ui-monospace, Menlo, monospace; color: var(--text-2); }
.list { list-style: none; margin: 0; padding: 10px; overflow: auto; flex: 1; display: flex; flex-direction: column; gap: 8px; }
.list:empty::after { content: "Пока пусто. Выбери инструмент внизу и отметь первую правку."; display: block; color: var(--muted); font-size: 12.5px; padding: 20px 10px; text-align: center; line-height: 1.6; }
.list li { position: relative; display: flex; gap: 12px; padding: 12px 12px 12px 14px; border-radius: 12px; cursor: pointer; align-items: flex-start; background: var(--surface); border: 1px solid var(--line); transition: border-color .15s, background .15s; overflow: hidden; }
.list li::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--c, var(--accent)); }
.list li:hover { border-color: var(--line-2); background: var(--surface-2); }
.list li.other { opacity: .5; }
.list .num { flex: none; width: 26px; height: 26px; border-radius: 50%; color: #fff; font-weight: 700; font-size: 12px; display: flex; align-items: center; justify-content: center; box-shadow: 0 2px 8px rgba(0,0,0,.4); }
.list .body { flex: 1; min-width: 0; }
.list .kind { font-size: 11.5px; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.list .kind svg.i { width: 13px; height: 13px; }
.list .cmt { margin-top: 4px; white-space: pre-wrap; word-break: break-word; color: var(--text); }
.list .del { position: absolute; right: 6px; top: 6px; opacity: 0; padding: 2px 7px; font-size: 16px; color: var(--muted); }
.list li:hover .del { opacity: 1; }
.diff { font-size: 13px; margin-top: 4px; display: flex; flex-direction: column; gap: 2px; }
.diff s { color: var(--danger); opacity: .85; }
.diff b { color: var(--ok); font-weight: 500; }
.etext { font-size: 12px; color: var(--text-2); margin-top: 4px; }

/* ── popover ── */
.pop { position: absolute; width: 330px; background: rgba(28,33,48,.94); backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px); border: 1px solid var(--line-2); border-radius: 16px; box-shadow: var(--shadow); padding: 12px 14px 14px; z-index: 50; animation: popin .16s ease-out; }
@keyframes popin { from { opacity: 0; transform: translateY(6px) scale(.98); } to { opacity: 1; transform: none; } }
.pop-head { display: flex; justify-content: space-between; align-items: center; font-weight: 600; }
.pop-head span { display: inline-flex; align-items: center; gap: 8px; }
.pop .x { font-size: 18px; padding: 0 6px; color: var(--muted); }
.pop-meta { margin: 8px 0; max-height: 120px; overflow: auto; font-size: 12.5px; }
.pop-meta code { display: inline-block; margin-bottom: 4px; }
.pop textarea { width: 100%; min-height: 88px; background: rgba(0,0,0,.25); border: 1px solid var(--line-2); border-radius: 10px; padding: 10px; font: inherit; color: var(--text); resize: vertical; }
.pop textarea::placeholder { color: var(--muted); }
.pop textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(124,108,255,.25); }
.pop-actions { display: flex; justify-content: flex-end; gap: 6px; margin-top: 10px; }
.shake { animation: shake .35s; }
@keyframes shake { 25% { transform: translateX(-4px); } 75% { transform: translateX(4px); } }

/* ── modal ── */
.modal { position: fixed; inset: 0; background: rgba(5,7,12,.6); backdrop-filter: blur(6px); display: flex; align-items: center; justify-content: center; z-index: 100; }
.modal[hidden] { display: none; }
.modal-box { background: var(--surface); border: 1px solid var(--line-2); border-radius: 18px; padding: 26px 28px; width: 440px; max-width: 92vw; box-shadow: var(--shadow); }
.modal-box h3 { margin: 0 0 8px; font-size: 17px; }
.modal-box p { margin: 0; color: var(--text-2); line-height: 1.6; }
.modal-box p b { color: var(--text); }
.modal-box #modalActions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 18px; }
.spinner { width: 22px; height: 22px; border: 2.5px solid var(--line-2); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; display: inline-block; vertical-align: middle; margin-right: 10px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── pages (dashboard / session / login) ── */
body.page { display: block; overflow: auto; }
.wrap { max-width: 1040px; margin: 0 auto; padding: 44px 28px 80px; }
.hero { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; margin-bottom: 30px; }
.hero h1 { font-size: 30px; font-weight: 700; letter-spacing: -.02em; margin: 0; background: linear-gradient(90deg, #fff, #c7c2ff); -webkit-background-clip: text; background-clip: text; color: transparent; }
.hero p { margin: 6px 0 0; color: var(--text-2); }
.section { display: flex; align-items: center; justify-content: space-between; margin: 34px 0 14px; }
.section h2 { font-size: 12px; margin: 0; color: var(--muted); text-transform: uppercase; letter-spacing: .12em; font-weight: 600; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; }
.site { background: var(--surface); border: 1px solid var(--line); border-radius: 18px; overflow: hidden; display: flex; flex-direction: column; transition: border-color .15s, transform .15s, box-shadow .15s; }
.site:hover { border-color: var(--line-2); transform: translateY(-2px); box-shadow: var(--shadow); }
.site .thumb { position: relative; height: 170px; background: linear-gradient(135deg, #1e2233, #151827); overflow: hidden; }
.site .thumb img { width: 100%; height: 100%; object-fit: cover; object-position: top; display: block; }
.site .thumb .ph { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: 46px; font-weight: 700; color: rgba(255,255,255,.12); }
.site .thumb .kind { position: absolute; top: 10px; left: 10px; font-size: 10.5px; padding: 3px 8px; border-radius: 20px; background: rgba(0,0,0,.55); color: var(--text-2); border: 1px solid var(--line-2); text-transform: uppercase; letter-spacing: .08em; backdrop-filter: blur(6px); }
.site .thumb .del { position: absolute; top: 8px; right: 8px; width: 28px; height: 28px; border-radius: 8px; background: rgba(0,0,0,.5); color: var(--text-2); opacity: 0; display: flex; align-items: center; justify-content: center; }
.site:hover .thumb .del { opacity: 1; }
.site .body { padding: 14px 16px 16px; display: flex; flex-direction: column; gap: 10px; }
.site .name { font-weight: 600; font-size: 15px; }
.site .src { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-family: ui-monospace, Menlo, monospace; }
.site .actions { display: flex; gap: 8px; }
.site .actions .btn { flex: 1; justify-content: center; }
.add { display: grid; grid-template-columns: 1fr 2fr auto; gap: 10px; background: var(--surface); border: 1px dashed var(--line-2); border-radius: 16px; padding: 14px; }
.add input { padding: 10px 12px; background: rgba(0,0,0,.25); border: 1px solid var(--line-2); border-radius: 10px; font: inherit; color: var(--text); }
.add input::placeholder { color: var(--muted); }
.add input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(124,108,255,.2); }
.sessions { display: flex; flex-direction: column; gap: 8px; }
.sess { display: flex; align-items: center; gap: 14px; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 12px 16px; }
.sess .n { width: 40px; height: 40px; border-radius: 12px; display: flex; align-items: center; justify-content: center; font-weight: 700; background: rgba(124,108,255,.15); color: #cfc8ff; flex: none; }
.sess .grow { flex: 1; min-width: 0; }
.sess .name { font-weight: 600; }
.sess .src { font-size: 12px; color: var(--muted); }
.tag { font-size: 11px; padding: 3px 9px; border-radius: 20px; background: rgba(255,255,255,.06); color: var(--text-2); border: 1px solid var(--line); }
.tag.sent { background: rgba(52,211,153,.12); color: var(--ok); border-color: rgba(52,211,153,.25); }
.tag.open { background: rgba(251,191,36,.12); color: var(--warn); border-color: rgba(251,191,36,.25); }
.empty { color: var(--muted); padding: 30px; text-align: center; border: 1px dashed var(--line); border-radius: 14px; }

/* session view */
.ann { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 16px; margin-bottom: 14px; display: flex; gap: 18px; }
.ann img { max-width: 390px; width: 44%; border: 1px solid var(--line-2); border-radius: 10px; align-self: flex-start; background: #fff; }
.ann .info { flex: 1; min-width: 0; }
.ann .cmt { font-size: 15px; margin: 8px 0; white-space: pre-wrap; }
.ann .num { display: inline-flex; width: 26px; height: 26px; border-radius: 50%; color: #fff; font-weight: 700; font-size: 12px; align-items: center; justify-content: center; margin-right: 8px; }
@media (max-width: 700px) { .ann { flex-direction: column; } .ann img { width: 100%; max-width: none; } .wrap { padding: 28px 16px 60px; } .add { grid-template-columns: 1fr; } }

/* login */
.login { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.login form { width: 340px; background: var(--surface); border: 1px solid var(--line-2); border-radius: 20px; padding: 28px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 12px; }
.login h3 { margin: 0 0 4px; font-size: 20px; }
.login p { margin: 0 0 8px; color: var(--text-2); font-size: 13px; }
.login input { padding: 11px 12px; background: rgba(0,0,0,.25); border: 1px solid var(--line-2); border-radius: 10px; font: inherit; color: var(--text); }
.login input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(124,108,255,.2); }
.logo { display: inline-flex; align-items: center; gap: 10px; font-weight: 700; letter-spacing: -.01em; }
.logo i { width: 28px; height: 28px; border-radius: 9px; background: var(--accent-grad); display: inline-block; box-shadow: 0 4px 14px rgba(124,108,255,.45); }
