:root {
  --bg: #07090f;
  --glass: rgba(255, 255, 255, 0.045);
  --glass-strong: rgba(255, 255, 255, 0.08);
  --line: rgba(255, 255, 255, 0.09);
  --txt: #e8ecf6;
  --dim: #7c869e;
  --acc: #818cf8;
  --acc2: #a855f7;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0; height: 100%; overflow: hidden;
  background: var(--bg); color: var(--txt);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  user-select: none; -webkit-user-select: none;
  touch-action: manipulation; overscroll-behavior: none;
}

body { display: flex; flex-direction: column; height: 100dvh; }

body::before {
  content: ""; position: fixed; inset: -25%; z-index: -1; pointer-events: none;
  background:
    radial-gradient(42% 32% at 18% 8%, rgba(99, 102, 241, 0.20), transparent 62%),
    radial-gradient(38% 30% at 88% 16%, rgba(168, 85, 247, 0.15), transparent 62%),
    radial-gradient(50% 38% at 50% 105%, rgba(56, 189, 248, 0.11), transparent 65%);
  filter: blur(46px);
}

.glass {
  background: var(--glass);
  border: 1px solid var(--line);
  backdrop-filter: blur(20px) saturate(150%);
  -webkit-backdrop-filter: blur(20px) saturate(150%);
  box-shadow: 0 10px 34px rgba(0, 0, 0, 0.38);
}

#conn {
  position: fixed; top: calc(env(safe-area-inset-top) + 8px); right: 10px;
  width: 8px; height: 8px; border-radius: 50%; z-index: 90; opacity: .9;
  box-shadow: 0 0 10px currentColor;
}
#conn.on { background: #34d399; color: #34d399 }
#conn.off { background: #ef4444; color: #ef4444 }
#conn.auth { background: #f59e0b; color: #f59e0b }

main { flex: 1; display: flex; min-height: 0; width: 100%; overflow-x: hidden }
.view { display: none; flex: 1; flex-direction: column; min-height: 0; padding: 8px; gap: 8px; width: 100%; max-width: 100% }
.view.active { display: flex }
#view-more > *, #view-kbd > * { flex-shrink: 0 }

svg.ic {
  width: 21px; height: 21px; fill: none;
  stroke: currentColor; stroke-width: 1.8;
  stroke-linecap: round; stroke-linejoin: round;
  display: block; flex: none;
}

button {
  font-family: inherit; color: var(--txt); cursor: pointer;
  background: var(--glass); border: 1px solid var(--line); border-radius: 13px;
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  transition: background .15s, border-color .15s;
}
button:active { background: rgba(129, 140, 248, 0.28); border-color: rgba(129, 140, 248, 0.55) }
button.accent { background: linear-gradient(135deg, rgba(99, 102, 241, .8), rgba(168, 85, 247, .8)); border-color: transparent }

/* ---- тачпад ---- */
#padWrap { flex: 1; display: flex; gap: 6px; min-height: 0; flex-wrap: nowrap }

#pad {
  flex: 1 1 0; min-width: 0; border-radius: 18px; position: relative;
  touch-action: none;
  background: linear-gradient(160deg, rgba(255,255,255,.05), rgba(255,255,255,.02));
  border: 1px solid var(--line);
  backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.06), 0 10px 34px rgba(0,0,0,.35);
}

#strip {
  flex: 0 0 44px; width: 44px; min-width: 44px; border-radius: 16px; position: relative; touch-action: none;
  background: linear-gradient(180deg, rgba(255,255,255,.06), rgba(255,255,255,.02));
  border: 1px solid var(--line);
  backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
}
#strip::before, #strip::after {
  position: absolute; left: 0; right: 0; text-align: center;
  color: rgba(255,255,255,.22); font-size: 11px; pointer-events: none;
}
#strip::before { content: "▲"; top: 7px }
#strip::after { content: "▼"; bottom: 7px }

#btnRow { display: flex; gap: 6px; height: 48px; flex-shrink: 0 }
.mbtn { backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px) }
#btnRow .wide { flex: 1 }
#btnRow .mbtn:not(.wide) { width: 58px; flex: none }

/* ---- медиа-панель ---- */
#mediaBar { display: flex; align-items: center; gap: 4px; padding: 5px 8px; border-radius: 16px; flex-shrink: 0; max-width: 100% }
#mediaBar button { flex: none; width: 44px; padding: 9px 0; background: none; border: none }
#mediaBar .sep { width: 1px; height: 22px; background: var(--line); margin: 0 5px }
#volSlider {
  flex: 1; min-width: 0; height: 30px; margin: 0 16px 0 4px;
  -webkit-appearance: none; appearance: none; background: transparent;
}
#volSlider::-webkit-slider-runnable-track {
  height: 6px; border-radius: 3px;
  background: linear-gradient(90deg, #818cf8 var(--fill, 50%), rgba(255,255,255,.14) var(--fill, 50%));
}
#volSlider::-webkit-slider-thumb {
  -webkit-appearance: none; width: 18px; height: 18px; border-radius: 50%;
  background: #a5b4fc; margin-top: -6px; box-shadow: 0 1px 5px rgba(0,0,0,.5);
}

/* ---- ряды с текстом ---- */
.txtRow { display: flex; gap: 6px }
.txtRow button {
  flex: 1; padding: 11px 2px; font-size: 12px; white-space: nowrap;
  backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
}
#modRow button.on {
  background: linear-gradient(135deg, rgba(99,102,241,.75), rgba(168,85,247,.75));
  border-color: transparent; color: white;
}

/* ---- клавиатура ---- */
#kbd {
  width: 100%; border-radius: 13px; color: var(--txt); padding: 11px; font-size: 16px;
  resize: none; user-select: text; -webkit-user-select: text;
  background: var(--glass); border: 1px solid var(--line);
  backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
}
.keys { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px }
.keys button { padding: 13px 0; font-size: 14px; backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px) }

/* ---- навигация ---- */
nav {
  position: relative;
  display: flex; margin: 6px 10px calc(env(safe-area-inset-bottom) + 8px);
  border-radius: 20px; padding: 5px; flex-shrink: 0;
  touch-action: pan-y;
}
#notifList { display: flex; flex-direction: column; gap: 6px; margin-top: 8px }
.notif-item { background: rgba(255,255,255,.04); border: 1px solid rgba(255,255,255,.06); border-radius: 12px; padding: 8px 12px; font-size: 12.5px; line-height: 1.45; color: var(--text-dim, #aab); overflow: hidden; text-overflow: ellipsis }
.notif-item b { color: var(--text, #eef) }

#thumb {
  position: absolute; top: 5px; bottom: 5px; left: 0; width: 60px;
  border-radius: 15px;
  background: linear-gradient(135deg, rgba(99,102,241,.5), rgba(168,85,247,.5));
  transition: transform .3s cubic-bezier(.3,1.4,.4,1);
  pointer-events: none;
}
#thumb.free { transition: none }
nav button { flex: 1; background: none; border: none; border-radius: 15px; padding: 0 }
nav button:active { background: none; border-color: transparent }
nav .icp { display: block; padding: 8px 0; color: var(--dim); border-radius: 15px; transition: color .25s }
nav button.lit .icp { color: #e0e7ff }

/* ---- окна-пузыри ---- */
#winHead {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 2px 4px; color: var(--dim); font-size: 11.5px; flex-shrink: 0;
}
#winHead button { padding: 7px 10px }
#bubbleField {
  flex: 1; position: relative; overflow: hidden; border-radius: 18px;
  background: linear-gradient(160deg, rgba(255,255,255,.04), rgba(255,255,255,.015));
  border: 1px solid var(--line);
  touch-action: none;
}
#bubbleField.empty::after {
  content: "Нет видимых окон";
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  color: var(--dim); font-size: 13px;
}
.bubble {
  position: absolute; left: 0; top: 0; border-radius: 50%;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; color: #dfe6f5; padding: 10px; overflow: hidden;
  gap: 3px;
  background: radial-gradient(circle at 32% 26%, rgba(255,255,255,.16), rgba(255,255,255,.04) 60%), rgba(22,28,48,.6);
  border: 1px solid rgba(255,255,255,.15);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  box-shadow: 0 8px 24px rgba(0,0,0,.4), inset 0 0 22px 6px rgba(52,211,153,.25);
  transition: width .8s ease, height .8s ease, font-size .8s ease, box-shadow .8s ease;
  touch-action: none;
}
.bubble .bicon {
  display: none; width: 46%; max-width: 46px; max-height: 46px;
  pointer-events: none; filter: drop-shadow(0 2px 4px rgba(0,0,0,.4));
}
.bubble.hasIcon .bicon { display: block }
.bubble.hasIcon .t { font-size: .85em; -webkit-line-clamp: 2 }
.bubble .t {
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical;
  overflow: hidden; word-break: break-word; pointer-events: none;
}
.bubble.drag {
  z-index: 10;
  outline: 1.5px solid rgba(129,140,248,.7);
  outline-offset: 2px;
}
.bubble.pop { opacity: 0 }
#dropZone {
  position: absolute; top: 10px; left: 50%;
  transform: translateX(-50%) translateY(-90px);
  display: flex; align-items: center; gap: 6px; padding: 9px 16px; border-radius: 16px;
  background: linear-gradient(135deg, rgba(239,68,68,.9), rgba(244,63,94,.7));
  color: white; font-size: 12.5px; border: 1px solid rgba(255,255,255,.25);
  transition: transform .22s cubic-bezier(.2,.9,.3,1.2), box-shadow .15s;
  z-index: 20; pointer-events: none;
}
#dropZone .ic { width: 16px; height: 16px }
#dropZone.show { transform: translateX(-50%) translateY(0) }
#dropZone.hot { box-shadow: 0 0 0 3px rgba(255,255,255,.55), 0 0 34px rgba(239,68,68,.85) }

/* ---- ещё ---- */
#powerGrid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px }
#powerGrid button {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: 12px 0; backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
}
#powerGrid button span { font-size: 11px; color: var(--dim) }

h3 {
  font-size: 11px; color: var(--dim); margin: 8px 0 2px;
  text-transform: uppercase; letter-spacing: .09em; font-weight: 600;
}
.row { display: flex; gap: 6px }
.row button {
  flex: 1; padding: 11px; font-size: 13.5px;
  background: linear-gradient(135deg, rgba(99,102,241,.7), rgba(168,85,247,.7));
  border-color: transparent;
}
#clipBox {
  width: 100%; border-radius: 13px; color: var(--txt); padding: 11px; font-size: 14px;
  resize: none; user-select: text; -webkit-user-select: text;
  background: var(--glass); border: 1px solid var(--line);
}
#shot { max-width: 100%; border-radius: 13px; border: 1px solid var(--line) }
#shot.big { position: fixed; inset: 0; width: 100vw; height: 100dvh; object-fit: contain; background: black; z-index: 50 }
.kv { display: flex; gap: 8px; font-size: 13px; color: var(--dim); align-items: center; margin: 3px 0 }
.kv input[type=range] { flex: 1; accent-color: var(--acc) }
.kv b { color: var(--txt) }
#tokenInput {
  flex: 1; min-width: 0; border-radius: 10px; color: var(--txt); padding: 8px 10px; font-size: 13px;
  background: var(--glass); border: 1px solid var(--line); user-select: text; -webkit-user-select: text;
}
#tokenEye { padding: 7px 9px }
#view-more { overflow-y: auto }

/* ---- файлы ---- */
#fmHead { display: flex; gap: 6px; flex-shrink: 0 }
#fmHead button { flex: 1; padding: 10px; font-size: 13px; backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px) }
.fitem .fmeta { display: flex; flex-direction: column; align-items: flex-end; gap: 1px; flex: none }
.fitem .fdate { color: var(--dim); font-size: 10.5px; opacity: .8 }
#scrBtn {
  display: flex; align-items: center; justify-content: flex-start; gap: 10px;
  padding: 12px 14px; font-size: 13.5px; flex-shrink: 0;
  backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
}
#scrBtn.on { border-color: rgba(52, 211, 153, .5); color: #a7f3d0 }
#dbgState { font-size: 12.5px; color: var(--dim); margin: 2px 0 6px }
#dbgBtn { flex: 1; padding: 11px; font-size: 13px; background: var(--glass) }
#dbgBtn.off-act, #notifBtn.off-act {
  background: linear-gradient(135deg, rgba(239,68,68,.5), rgba(168,85,247,.45));
  border-color: transparent;
}
#dlgCancel { background: var(--glass) }
#crumbs {
  display: flex; gap: 1px; overflow-x: auto; padding: 2px 2px; flex-shrink: 0;
  white-space: nowrap; scrollbar-width: none;
}
#crumbs::-webkit-scrollbar { display: none }
#crumbs button { background: none; border: none; padding: 7px 5px; color: var(--dim); font-size: 12.5px; flex: none }
#crumbs button.cur { color: var(--txt) }
#crumbs .csep { color: var(--dim); opacity: .45; align-self: center; flex: none; font-size: 11px }
#fileList {
  flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 4px; min-height: 0;
  border-radius: 16px; padding: 6px;
  background: linear-gradient(160deg, rgba(255,255,255,.04), rgba(255,255,255,.015));
  border: 1px solid var(--line);
}
.fitem {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px;
  text-align: left; border-radius: 12px; font-size: 13.5px;
  backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
}
.fitem .ic { color: var(--dim) }
.fitem .fname { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap }
.fitem .fsize { color: var(--dim); font-size: 11.5px; flex: none }
.fmEmpty { color: var(--dim); text-align: center; padding: 30px 0; font-size: 13px }

/* ---- нижняя панель действий ---- */
#sheet { position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 110; display: flex; align-items: flex-end }
#sheet.hidden, #dlg.hidden, #imgView.hidden, #pv.hidden { display: none }
#sheetCard {
  width: 100%; border-radius: 22px 22px 0 0;
  padding: 14px 14px calc(env(safe-area-inset-bottom) + 14px);
  display: flex; flex-direction: column; gap: 6px;
}
#sheetTitle { font-size: 12.5px; color: var(--dim); padding: 2px 6px 8px; word-break: break-all; text-align: center }
#sheetBtns { display: flex; flex-direction: column; gap: 6px }
#sheetBtns button { padding: 12px; font-size: 14px; justify-content: center; backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px) }
#sheetBtns button.danger { color: #fca5a5; border-color: rgba(239,68,68,.4) }

/* ---- диалог ввода ---- */
#dlg { position: fixed; inset: 0; background: rgba(0,0,0,.55); display: flex; align-items: center; justify-content: center; z-index: 115 }
#dlgInput {
  border-radius: 11px; color: var(--txt); padding: 10px 12px; font-size: 14px;
  background: var(--glass); border: 1px solid var(--line); user-select: text; -webkit-user-select: text;
}

/* ---- просмотр картинки ---- */
#imgView { position: fixed; inset: 0; background: rgba(0,0,0,.93); z-index: 105; display: flex; align-items: center; justify-content: center }
#imgBig { max-width: 100%; max-height: 100%; object-fit: contain }

/* ---- toast / modal ---- */
#toast {
  position: fixed; bottom: calc(env(safe-area-inset-bottom) + 78px); left: 50%;
  transform: translateX(-50%); color: white;
  background: rgba(30, 35, 55, 0.85); border: 1px solid var(--line);
  backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  padding: 9px 18px; border-radius: 22px; font-size: 13px;
  opacity: 0; transition: opacity .25s; pointer-events: none; z-index: 120;
  white-space: nowrap;
}
#toast.show { opacity: 1 }

#modal { position: fixed; inset: 0; background: rgba(0,0,0,.55); display: flex; align-items: center; justify-content: center; z-index: 100 }
#modal.hidden { display: none }
.card {
  padding: 20px; width: min(90vw, 360px);
  display: flex; flex-direction: column; gap: 10px; border-radius: 20px;
}
.card h3 { margin: 0 }
.card p { color: var(--dim); font-size: 13px; margin: 0 }
.card input {
  border-radius: 11px; color: var(--txt); padding: 10px 12px; font-size: 14px;
  background: var(--glass); border: 1px solid var(--line); user-select: text; -webkit-user-select: text;
}
.card button {
  padding: 11px; border-radius: 12px;
  background: linear-gradient(135deg, rgba(99,102,241,.8), rgba(168,85,247,.8)); border-color: transparent;
}

/* галерея */
#fmGal.act { background: var(--acc); border-color: transparent }
#galGrid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px }
#galGrid button { aspect-ratio: 1; padding: 0; border-radius: 10px; overflow: hidden; background: var(--glass) }
#galGrid img { width: 100%; height: 100%; object-fit: cover; display: block }

/* просмотрщик фото */
#pv { position: fixed; inset: 0; z-index: 95; background: rgba(4,5,9,.97); display: flex; flex-direction: column }
#pvBar { display: flex; align-items: center; gap: 10px; padding: 10px 12px; font-size: 12.5px; color: var(--dim) }
#pvCount { flex: 0 0 auto }
#pvName { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap }
.pvBtn { padding: 8px; background: var(--glass) }
#pvWrap { flex: 1; position: relative; overflow: hidden; touch-action: none }
#pvImg { position: absolute; inset: 0; margin: auto; max-width: 100%; max-height: 100%; transition: transform .18s ease }
