/* XRPIN v3 · MOZAIKA ČASU – vzhled (mobile-first, tmavý, sklo) */
:root {
  --bg: #07080d;
  --panel: rgba(18, 21, 34, 0.86);
  --panel-solid: #121522;
  --line: rgba(255, 255, 255, 0.1);
  --line2: rgba(255, 255, 255, 0.18);
  --text: #eef1ff;
  --muted: #9aa3c2;
  --accent: #35f0d0;
  --accent2: #ff3ea5;
  --live: #3dff9a;
  --hist: #ffc24a;
  --r: 14px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); overflow: hidden; }
body { font: 14px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; -webkit-font-smoothing: antialiased; }
#stage { position: fixed; inset: 0; width: 100vw; height: 100dvh; display: block; touch-action: none; cursor: default; }
#stage.hover { cursor: pointer; }
button, input, select, textarea { font: inherit; color: inherit; }
.mono { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
[hidden] { display: none !important; }
kbd { font: 11px ui-monospace, monospace; border: 1px solid var(--line2); border-radius: 4px; padding: 0 4px; }

/* ---------- HUD ---------- */
.hud {
  position: fixed; left: 12px; top: calc(10px + var(--safe-t)); z-index: 5;
  padding: 8px 12px 9px; border-radius: var(--r);
  background: linear-gradient(180deg, rgba(10, 12, 20, 0.72), rgba(10, 12, 20, 0.5));
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  border: 1px solid var(--line); max-width: calc(100vw - 150px);
  pointer-events: auto; transition: opacity .4s;
}
.brand { display: flex; align-items: center; gap: 8px; font-size: 13px; letter-spacing: .06em; }
.brand b { font-weight: 800; }
.brand-sub { color: var(--muted); font-size: 11px; letter-spacing: .04em; }
.logo { display: inline-grid; grid-template-columns: 7px 7px; gap: 2px; }
.logo i { width: 7px; height: 7px; border-radius: 2px; background: var(--accent); }
.logo i:nth-child(2) { background: var(--accent2); }
.logo i:nth-child(3) { background: #ffd23f; grid-column: 1 / 3; justify-self: center; }
.hud-row { display: flex; align-items: center; gap: 10px; margin-top: 5px; flex-wrap: wrap; }
.hud-row.small { font-size: 11.5px; color: var(--muted); gap: 10px; }
.hud-ledger { font-weight: 700; font-variant-numeric: tabular-nums; font-size: 15px; }
.chip { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line2); border-radius: 99px; padding: 2px 9px; font-size: 11.5px; font-weight: 700; letter-spacing: .05em; background: rgba(255,255,255,.04); cursor: pointer; }
.chip .dot, .live .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--live); box-shadow: 0 0 8px var(--live); }
.chip.hist .dot { background: var(--hist); box-shadow: 0 0 8px var(--hist); }
.chip.off .dot { background: #ff6b6b; box-shadow: 0 0 8px #ff6b6b; }
.chip.live .dot { animation: blink 2s infinite; }
@keyframes blink { 50% { opacity: .35; } }

.conn {
  position: fixed; right: 12px; top: calc(10px + var(--safe-t)); z-index: 5;
  display: flex; align-items: center; gap: 8px; padding: 7px 11px; border-radius: 99px;
  background: rgba(10, 12, 20, 0.6); border: 1px solid var(--line); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  font-size: 11.5px; cursor: pointer; max-width: 46vw;
}
.conn-dot { width: 8px; height: 8px; border-radius: 50%; background: #666; flex: none; }
.conn-dot.ok { background: var(--live); box-shadow: 0 0 8px var(--live); }
.conn-dot.wait { background: var(--hist); animation: blink 1s infinite; }
.conn-dot.off { background: #ff6b6b; }
.conn-text { display: flex; flex-direction: column; line-height: 1.15; overflow: hidden; text-align: left; }
.conn-text span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conn-text small { color: var(--muted); font-size: 10.5px; }

.banner {
  position: fixed; left: 50%; transform: translateX(-50%); top: calc(92px + var(--safe-t)); z-index: 6;
  background: rgba(60, 30, 10, 0.88); border: 1px solid rgba(255, 180, 90, 0.4); color: #ffe2bf;
  padding: 7px 14px; border-radius: 99px; font-size: 12.5px; max-width: calc(100vw - 24px); text-align: center;
}
.banner button { margin-left: 8px; background: rgba(255,255,255,.12); border: 1px solid rgba(255,255,255,.25); border-radius: 99px; padding: 2px 10px; cursor: pointer; }
.buffering, .peekhint {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(84px + var(--safe-b)); z-index: 6;
  background: rgba(10, 12, 20, 0.8); border: 1px solid var(--line); border-radius: 99px; padding: 5px 12px; font-size: 12px; color: var(--muted);
  display: flex; align-items: center; gap: 8px;
}
.peekhint { bottom: calc(120px + var(--safe-b)); }
.spinner { width: 12px; height: 12px; border-radius: 50%; border: 2px solid var(--line2); border-top-color: var(--accent); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- dok ---------- */
.dock {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(12px + var(--safe-b)); z-index: 5;
  display: flex; align-items: center; gap: 6px; padding: 6px; border-radius: 20px;
  background: rgba(12, 14, 24, 0.74); border: 1px solid var(--line); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  box-shadow: 0 10px 40px rgba(0,0,0,.45); transition: opacity .4s; max-width: calc(100vw - 16px);
}
.hist-ctl { display: flex; align-items: center; gap: 6px; padding-right: 6px; margin-right: 2px; border-right: 1px solid var(--line); }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 40px; min-width: 40px; padding: 0 12px;
  border-radius: 13px; border: 1px solid var(--line); background: rgba(255,255,255,.05); cursor: pointer; font-weight: 650; white-space: nowrap;
  transition: background .15s, border-color .15s, transform .1s;
}
.btn:hover { background: rgba(255,255,255,.1); border-color: var(--line2); }
.btn:active { transform: scale(.96); }
.btn:focus-visible, .chip:focus-visible, .conn:focus-visible, .seg button:focus-visible, .swatches button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn.icon { padding: 0; width: 40px; }
.btn svg { width: 20px; height: 20px; fill: currentColor; }
.btn.primary { background: linear-gradient(135deg, #1fd6b9, #7c5cff); border-color: transparent; color: #061016; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.primary:disabled { opacity: .45; cursor: not-allowed; filter: grayscale(.6); }
.btn.ghost { background: transparent; }
.btn.live { color: var(--live); border-color: rgba(61,255,154,.35); font-weight: 800; letter-spacing: .04em; }
.btn .badge { background: rgba(61,255,154,.16); border-radius: 99px; padding: 0 6px; font-size: 11px; }
.btn .badge:empty { display: none; }
#btnSound .snd-on { display: none; }
#btnSound[aria-pressed="true"] .snd-on { display: block; }
#btnSound[aria-pressed="true"] .snd-off { display: none; }
#btnSound[aria-pressed="true"] { color: var(--accent); }
select { height: 40px; border-radius: 12px; border: 1px solid var(--line); background: #151827; padding: 0 8px; }

/* ---------- bublina ---------- */
.bubble {
  position: fixed; z-index: 8; width: min(360px, calc(100vw - 20px)); max-height: min(70dvh, 560px); overflow: auto;
  background: var(--panel); border: 1px solid var(--line2); border-radius: 18px; padding: 14px 14px 12px;
  backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px); box-shadow: 0 20px 60px rgba(0,0,0,.55);
  animation: pop .18s ease-out;
}
@keyframes pop { from { opacity: 0; transform: translateY(6px) scale(.97); } }
.bubble .b-head { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; padding-right: 24px; }
.bubble .b-sw { width: 18px; height: 18px; border-radius: 5px; flex: none; border: 1px solid rgba(255,255,255,.25); }
.bubble h3 { margin: 0; font-size: 15px; line-height: 1.2; overflow-wrap: anywhere; }
.bubble .b-addr { font-size: 11.5px; color: var(--muted); }
.bubble .b-text { font-size: 17px; line-height: 1.38; margin: 6px 0 10px; white-space: pre-wrap; overflow-wrap: anywhere; }
.bubble .b-close { position: absolute; right: 8px; top: 8px; width: 30px; height: 30px; border-radius: 10px; border: 0; background: rgba(255,255,255,.06); cursor: pointer; font-size: 18px; }
.bubble dl { display: grid; grid-template-columns: auto 1fr; gap: 3px 10px; margin: 0 0 10px; font-size: 12.5px; }
.bubble dt { color: var(--muted); }
.bubble dd { margin: 0; overflow-wrap: anywhere; }
.bubble a { color: var(--accent); }
.tag { display: inline-block; font-size: 10.5px; font-weight: 700; letter-spacing: .04em; padding: 1px 7px; border-radius: 99px; border: 1px solid var(--line2); color: var(--muted); }
.tag.sim { color: #ffc24a; border-color: rgba(255,194,74,.4); }
.tag.own { color: #ffe68c; border-color: rgba(255,230,140,.5); }
.tag.real { color: var(--live); border-color: rgba(61,255,154,.4); }
.tag.bad { color: #ff8b8b; border-color: rgba(255,120,120,.45); }
.note { font-size: 11.5px; color: #ffd9a0; background: rgba(255,194,74,.08); border: 1px solid rgba(255,194,74,.2); border-radius: 10px; padding: 6px 9px; margin: 0 0 10px; }
.thread { border-top: 1px solid var(--line); padding-top: 8px; margin-top: 4px; font-size: 12.5px; }
.thread h4 { margin: 0 0 5px; font-size: 12px; color: var(--muted); font-weight: 600; }
.tlink { display: flex; gap: 7px; align-items: center; width: 100%; text-align: left; background: rgba(255,255,255,.04); border: 1px solid var(--line); border-radius: 10px; padding: 6px 8px; cursor: pointer; margin-bottom: 4px; }
.tlink:hover { background: rgba(255,255,255,.09); }
.tlink i { width: 10px; height: 10px; border-radius: 3px; flex: none; }
.tlink span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.b-actions { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 10px; }
.b-actions .btn { height: 34px; font-size: 13px; }

/* ---------- toasty ---------- */
.toasts { position: fixed; left: 50%; transform: translateX(-50%); top: calc(96px + var(--safe-t)); z-index: 9; display: flex; flex-direction: column; gap: 6px; align-items: center; pointer-events: none; width: min(420px, calc(100vw - 20px)); }
.toast { pointer-events: auto; background: var(--panel); border: 1px solid var(--line2); border-radius: 14px; padding: 8px 12px; font-size: 13px; box-shadow: 0 8px 30px rgba(0,0,0,.4); animation: pop .2s ease-out; display: flex; align-items: center; gap: 10px; }
.toast button { background: rgba(255,255,255,.1); border: 1px solid var(--line2); border-radius: 99px; padding: 3px 10px; cursor: pointer; font-weight: 600; }

/* ---------- dialogy (sheet) ---------- */
dialog.sheet {
  border: 1px solid var(--line2); background: var(--panel-solid); color: var(--text); padding: 0; border-radius: 20px;
  width: min(520px, calc(100vw - 16px)); max-height: calc(100dvh - 24px); box-shadow: 0 30px 80px rgba(0,0,0,.6);
  opacity: 1; transform: none;
  transition: opacity .2s, transform .2s, overlay .2s allow-discrete, display .2s allow-discrete;
}
dialog.sheet.wide { width: min(880px, calc(100vw - 16px)); }
dialog.sheet:not([open]) { opacity: 0; transform: translateY(16px); }
@starting-style { dialog.sheet[open] { opacity: 0; transform: translateY(16px); } }
dialog::backdrop { background: rgba(3, 4, 8, 0.55); backdrop-filter: blur(3px); }
.sheet-in { padding: 16px 18px 16px; display: flex; flex-direction: column; gap: 12px; max-height: calc(100dvh - 26px); overflow: auto; }
.sheet header { display: flex; align-items: center; justify-content: space-between; }
.sheet h2 { margin: 0; font-size: 18px; }
.sheet h3 { margin: 0 0 6px; font-size: 14px; }
.sheet p { margin: 0; }
.x { width: 34px; height: 34px; border-radius: 10px; border: 1px solid var(--line); background: transparent; font-size: 20px; cursor: pointer; }
.sheet footer { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; position: sticky; bottom: -16px; background: var(--panel-solid); padding: 8px 0 0; }
label { display: flex; flex-direction: column; gap: 4px; font-size: 12.5px; color: var(--muted); }
input, textarea, select { background: #0c0e18; border: 1px solid var(--line2); border-radius: 11px; padding: 9px 10px; color: var(--text); font-size: 14px; }
textarea { resize: vertical; }
input:focus, textarea:focus, select:focus { outline: 2px solid rgba(53,240,208,.5); outline-offset: 0; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.quick, .row-btns, .checks { display: flex; flex-wrap: wrap; gap: 6px; }
.quick button { border: 1px solid var(--line2); background: rgba(255,255,255,.04); border-radius: 99px; padding: 5px 11px; cursor: pointer; font-size: 12.5px; }
.quick button:hover { background: rgba(255,255,255,.1); }
.seg { display: flex; gap: 4px; flex-wrap: nowrap; background: #0c0e18; padding: 3px; border-radius: 12px; border: 1px solid var(--line); overflow-x: auto; }
.seg.wrap { flex-wrap: wrap; }
.seg button { border: 0; background: transparent; padding: 6px 10px; border-radius: 9px; cursor: pointer; font-size: 13px; color: var(--muted); white-space: nowrap; }
.seg button.on { background: rgba(255,255,255,.12); color: var(--text); }
.seg button:disabled { opacity: .3; cursor: not-allowed; text-decoration: line-through; }
.seg button small { opacity: .7; font-size: 10.5px; margin-left: 4px; }
.sw { flex-direction: row; align-items: center; gap: 8px; color: var(--text); font-size: 13.5px; }
.sw input { width: 18px; height: 18px; accent-color: var(--accent); }
.settings { display: grid; grid-template-columns: 1fr 1fr; gap: 16px 22px; }
.settings section { display: flex; flex-direction: column; gap: 8px; }
.own-list:empty { display: none; }
.own-list { font-size: 12.5px; }
.own-list button { margin: 2px 4px 2px 0; }

/* ---------- composer ---------- */
.compose { display: grid; grid-template-columns: 1fr 300px; gap: 16px; }
.c-left { display: flex; flex-direction: column; gap: 9px; }
.c-right { display: flex; flex-direction: column; gap: 10px; align-items: stretch; }
#cPreview { width: 300px; height: 300px; border-radius: 16px; background: radial-gradient(circle at 50% 40%, #151a2e, #07080d); border: 1px solid var(--line); align-self: center; }
.counter { font-size: 11.5px; color: var(--muted); text-align: right; margin-top: -5px; }
.counter.bad { color: #ff8b8b; }
.opt { display: flex; flex-direction: column; gap: 4px; }
.opt-l { font-size: 12.5px; color: var(--muted); }
.swatches { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.swatches button { width: 28px; height: 28px; border-radius: 8px; border: 2px solid rgba(255,255,255,.14); cursor: pointer; padding: 0; position: relative; }
.swatches button.on { border-color: #fff; box-shadow: 0 0 0 2px rgba(255,255,255,.2); }
.swatches button.auto { width: auto; padding: 0 9px; background: #0c0e18; border: 1px solid var(--line2); color: var(--muted); font-size: 12px; }
.swatches button.auto.on { color: var(--text); border-color: #fff; }
.swatches button:disabled { opacity: .3; cursor: not-allowed; }
.swatches input[type=color] { width: 34px; height: 30px; padding: 2px; border-radius: 8px; }
.replying { font-size: 12.5px; background: rgba(53,240,208,.07); border: 1px solid rgba(53,240,208,.25); border-radius: 10px; padding: 6px 9px; display: flex; justify-content: space-between; gap: 8px; }
.replying button { background: none; border: 0; color: var(--muted); cursor: pointer; }
.budget-top { display: flex; justify-content: space-between; align-items: baseline; }
.budget-top b { font-size: 18px; }
.bar { height: 12px; border-radius: 99px; background: #0c0e18; border: 1px solid var(--line); display: flex; overflow: hidden; margin: 6px 0; }
.bar i { display: block; height: 100%; }
.legend { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 2px 10px; font-size: 11.5px; color: var(--muted); }
.legend li { display: flex; align-items: center; gap: 5px; }
.legend li i { width: 8px; height: 8px; border-radius: 2px; flex: none; }
.legend li b { margin-left: auto; color: var(--text); font-weight: 600; font-variant-numeric: tabular-nums; }
.errors { color: #ff9a9a; font-size: 12.5px; }
.errors:empty { display: none; }
details summary { cursor: pointer; font-size: 12.5px; color: var(--muted); }
pre { font-size: 11px; background: #0c0e18; border: 1px solid var(--line); border-radius: 10px; padding: 8px; overflow: auto; max-height: 200px; white-space: pre-wrap; word-break: break-all; }
.wallet-box { display: flex; gap: 14px; align-items: center; }
#wQr { border-radius: 12px; background: #fff; width: 150px; height: 150px; flex: none; }
.wstate { font-size: 13px; padding: 8px 10px; border-radius: 10px; background: rgba(255,255,255,.05); }

/* ---------- ambientní režim ---------- */
body.ambient .hud, body.ambient .dock, body.ambient .conn { opacity: 0; pointer-events: none; }
body.ambient.show-ui .hud, body.ambient.show-ui .dock, body.ambient.show-ui .conn { opacity: 1; pointer-events: auto; }

/* ---------- mobil ---------- */
@media (max-width: 640px) {
  .hud { left: 8px; padding: 7px 10px; max-width: calc(100vw - 16px); }
  .hud-row.small #hudTx { display: none; }
  .conn { right: 8px; padding: 9px; }
  .conn-text { display: none; }
  .hud { max-width: calc(100vw - 60px); }
  .dock { gap: 4px; padding: 5px; bottom: calc(8px + var(--safe-b)); }
  .btn { height: 38px; min-width: 38px; padding: 0 9px; }
  .btn.icon { width: 38px; }
  #btnCompose span { display: none; }
  #btnAmbient { display: none; }
  .dock { flex-wrap: wrap; justify-content: center; }
  .hist-ctl { gap: 4px; padding: 0 0 5px; margin: 0 0 1px; border-right: 0; border-bottom: 1px solid var(--line); flex-basis: 100%; justify-content: center; }
  #btnStep { display: none; }
  .compose { grid-template-columns: 1fr; }
  .c-right { order: -1; }
  #cPreview { width: 200px; height: 200px; }
  .settings { grid-template-columns: 1fr; }
  .grid2 { grid-template-columns: 1fr; }
  dialog.sheet, dialog.sheet.wide { width: 100vw; max-width: 100vw; margin: auto 0 0; border-radius: 20px 20px 0 0; max-height: 92dvh; }
  .sheet-in { max-height: 92dvh; padding-bottom: calc(16px + var(--safe-b)); }
  .bubble { left: 0 !important; right: 0; top: auto !important; bottom: 0; width: 100vw; border-radius: 20px 20px 0 0; max-height: 72dvh; padding-bottom: calc(14px + var(--safe-b)); }
  .buffering { bottom: calc(118px + var(--safe-b)); }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
