:root {
    color-scheme: dark;
    --bg: #000;
    --surface: #1c1c1e;
    --surface-2: #1c1c1e;
    --surface-3: #2c2c2e;
    --line: rgba(255,255,255,.09);
    --line-strong: rgba(255,255,255,.15);
    --text: #f4f7fb;
    --muted: #8993a5;
    --quiet: #5f697b;
    --blue: #6d8eff;
    --blue-bright: #82a0ff;
    --green: #46d8ab;
    --red: #ff6470;
    font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", sans-serif;
    font-synthesis: none;
}

* { box-sizing: border-box; }
html { background: var(--bg); -webkit-text-size-adjust: 100%; }
body { margin: 0; min-width: 280px; min-height: 100vh; min-height: 100dvh; color: var(--text); background: var(--bg); -webkit-font-smoothing: antialiased; }
button, input, textarea { font: inherit; }
button, a, label { -webkit-tap-highlight-color: transparent; }
button { color: inherit; }
svg { fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }

.ambient { display: none; }

.view { display: none; position: relative; min-height: 100vh; min-height: 100dvh; }
.view.is-active { display: block; animation: view-in .25s ease-out; }
.eyebrow { margin: 0 0 8px; color: #71809a; font-size: 10px; line-height: 1; letter-spacing: .19em; font-weight: 750; }

/* Slot selection */
.slots-view.is-active { display: grid; place-items: center; padding: max(28px, env(safe-area-inset-top)) 24px max(28px, env(safe-area-inset-bottom)); }
.slots-shell { width: min(100%, 900px); }
.back-link { display: inline-flex; gap: 5px; align-items: center; margin-bottom: 32px; color: #8c97ab; text-decoration: none; font-size: 14px; }
.back-link:hover { color: var(--text); }
.page-intro { text-align: center; margin-bottom: 34px; }
.pulse-logo { height: 27px; display: inline-flex; align-items: end; gap: 3px; margin-bottom: 14px; }
.pulse-logo i, .brand-bars i { width: 4px; display: block; border-radius: 5px; background: var(--blue); box-shadow: 0 0 18px rgba(109,142,255,.55); }
.pulse-logo i:nth-child(1), .brand-bars i:nth-child(1) { height: 10px; }
.pulse-logo i:nth-child(2), .brand-bars i:nth-child(2) { height: 25px; }
.pulse-logo i:nth-child(3), .brand-bars i:nth-child(3) { height: 16px; }
.page-intro h1 { margin: 0; font-size: clamp(34px, 6vw, 52px); line-height: 1; letter-spacing: -.05em; }
.page-intro > p:last-child { margin: 12px auto 0; color: var(--muted); font-size: 14px; }
.slots-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 12px; }
.slot-card {
    position: relative;
    min-height: 142px;
    padding: 17px;
    border: 1px solid var(--line);
    border-radius: 22px;
    text-align: left;
    cursor: pointer;
    background: #1c1c1e;
    transition: transform .18s ease, border-color .18s ease, background .18s ease;
}
.slot-card:hover { transform: translateY(-2px); border-color: rgba(109,142,255,.5); background: #242428; }
.slot-card:active { transform: scale(.97); }
.slot-card-number { display: grid; place-items: center; width: 39px; height: 39px; border-radius: 13px; color: var(--blue-bright); background: rgba(109,142,255,.11); font-size: 16px; font-weight: 750; }
.slot-card strong { position: absolute; left: 17px; bottom: 29px; font-size: 15px; }
.slot-card small { position: absolute; left: 17px; bottom: 14px; color: var(--quiet); font-size: 10px; text-transform: uppercase; letter-spacing: .08em; }
.slot-arrow { position: absolute; right: 16px; top: 21px; color: #596478; font-size: 22px; font-weight: 300; }
.connection-line { margin-top: 25px; display: flex; justify-content: center; align-items: center; gap: 8px; color: var(--quiet); font-size: 11px; }
.status-dot { display: inline-block; width: 7px; height: 7px; flex: 0 0 auto; border-radius: 50%; background: #6d7582; transition: background .2s, box-shadow .2s; }
body.is-online .status-dot { background: var(--green); box-shadow: 0 0 10px rgba(70,216,171,.7); }
body.is-offline .status-dot { background: var(--red); }

/* PIN */
.pin-view.is-active { display: grid; place-items: center; padding: max(22px, env(safe-area-inset-top)) 20px max(22px, env(safe-area-inset-bottom)); }
.pin-panel { width: min(100%, 354px); text-align: center; }
.pin-close { position: fixed; top: max(18px, env(safe-area-inset-top)); right: 20px; }
.lock-mark { margin: 0 auto 20px; width: 58px; height: 58px; display: grid; place-items: center; border-radius: 19px; color: var(--blue-bright); background: rgba(109,142,255,.11); border: 1px solid rgba(109,142,255,.17); }
.lock-mark svg { width: 25px; }
.pin-panel h1 { margin: 0; font-size: 30px; letter-spacing: -.04em; }
.pin-caption { margin: 9px 0 0; color: var(--muted); font-size: 13px; }
.pin-dots { display: flex; justify-content: center; gap: 14px; margin: 32px 0; height: 11px; }
.pin-dot { width: 10px; height: 10px; border: 1.5px solid #4e5868; border-radius: 50%; transition: .13s ease; }
.pin-dot.is-filled { border-color: var(--text); background: var(--text); transform: scale(1.08); }
.pin-dots.has-error { animation: shake .35s ease; }
.pin-dots.has-error .pin-dot { background: var(--red); border-color: var(--red); }
.pin-pad { display: grid; grid-template-columns: repeat(3, 72px); justify-content: center; gap: 13px 19px; }
.pin-key { width: 72px; height: 58px; border: 1px solid var(--line); border-radius: 19px; background: var(--surface-2); cursor: pointer; font-size: 23px; transition: transform .1s, background .1s; }
.pin-key:active { background: var(--text); color: #090b10; transform: scale(.94); }
.pin-key.is-empty { visibility: hidden; }
.pin-key.is-delete { color: var(--muted); background: transparent; border-color: transparent; font-size: 13px; }

/* Main workspace */
.dashboard-view.is-active { display: grid; grid-template-columns: 232px minmax(0, 1fr); }
.sidebar { position: sticky; top: 0; height: 100vh; height: 100dvh; padding: 30px 18px 20px; border-right: 1px solid var(--line); background: #080808; }
.sidebar-brand { display: flex; align-items: center; gap: 11px; margin: 0 9px 45px; color: var(--text); text-decoration: none; font-size: 20px; letter-spacing: -.04em; }
.brand-bars { display: inline-flex; height: 20px; align-items: end; gap: 2px; transform: scale(.72); transform-origin: left center; width: 19px; }
.sidebar-label { margin: 0 10px 10px; color: var(--quiet); font-size: 9px; font-weight: 750; letter-spacing: .16em; }
.sidebar-slots { display: grid; gap: 5px; }
.sidebar-slot { width: 100%; padding: 11px 12px; display: flex; align-items: center; gap: 11px; border: 1px solid transparent; border-radius: 12px; color: var(--muted); background: transparent; cursor: pointer; text-align: left; font-size: 13px; font-weight: 650; transition: .15s ease; }
.sidebar-slot span { display: grid; place-items: center; width: 27px; height: 27px; border-radius: 9px; color: #73809a; background: rgba(255,255,255,.04); font-size: 11px; }
.sidebar-slot:hover { color: var(--text); background: rgba(255,255,255,.035); }
.sidebar-slot.is-active { color: var(--text); border-color: rgba(109,142,255,.15); background: rgba(109,142,255,.1); }
.sidebar-slot.is-active span { color: #adc0ff; background: rgba(109,142,255,.19); }
.sidebar-live { position: absolute; bottom: max(24px, env(safe-area-inset-bottom)); left: 29px; display: flex; align-items: center; gap: 8px; color: var(--quiet); font-size: 10px; }
.workspace { width: min(100%, 1240px); padding: 52px clamp(28px, 5vw, 72px) 64px; }
.workspace-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 25px; }
.workspace-head h1 { margin: 0; font-size: 32px; letter-spacing: -.045em; }
.head-live { display: flex; align-items: center; gap: 8px; padding: 8px 11px; border: 1px solid var(--line); border-radius: 99px; color: var(--muted); font-size: 10px; background: rgba(255,255,255,.025); }
.mobile-header { display: none; }
.segmented { display: inline-flex; gap: 4px; padding: 4px; margin-bottom: 28px; border: 1px solid var(--line); border-radius: 14px; background: rgba(255,255,255,.035); }
.segment { min-height: 40px; padding: 0 15px; display: flex; align-items: center; gap: 8px; border: 0; border-radius: 10px; color: var(--muted); background: transparent; cursor: pointer; font-size: 12px; font-weight: 700; transition: .16s ease; }
.segment svg { width: 16px; height: 16px; }
.segment > span { min-width: 19px; padding: 2px 5px; border-radius: 7px; color: var(--quiet); background: rgba(255,255,255,.055); font-size: 9px; }
.segment.is-active { color: var(--text); background: var(--surface-3); box-shadow: 0 4px 12px rgba(0,0,0,.18), inset 0 1px rgba(255,255,255,.07); }
.segment.is-active > span { color: #b7c7ff; background: rgba(109,142,255,.15); }
.tab-panel { display: none; }
.tab-panel.is-active { display: block; animation: panel-in .2s ease-out; }
.messages-layout { display: grid; grid-template-columns: minmax(290px, 410px) minmax(330px, 1fr); gap: clamp(24px, 4vw, 50px); align-items: start; }
.card { border: 1px solid var(--line); border-radius: 20px; background: #1c1c1e; }
.composer { padding: 20px; display: grid; gap: 9px; position: sticky; top: 32px; }
.card-heading { display: flex; align-items: center; gap: 11px; margin-bottom: 9px; }
.heading-icon { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 11px; color: #aec0ff; background: rgba(109,142,255,.13); font-size: 18px; }
.card-heading strong, .section-title strong { display: block; font-size: 13px; }
.card-heading small, .section-title small { display: block; margin-top: 3px; color: var(--quiet); font-size: 10px; font-weight: 450; }
.composer label { margin: 5px 2px 0; color: var(--muted); font-size: 10px; font-weight: 650; }
.composer input, .composer textarea { width: 100%; border: 1px solid var(--line); border-radius: 12px; outline: none; color: var(--text); background: #101012; caret-color: var(--blue); transition: border .15s, box-shadow .15s; }
.composer input { height: 45px; padding: 0 13px; font-size: 13px; }
.composer textarea { min-height: 152px; padding: 12px 13px; resize: vertical; line-height: 1.5; font-size: 13px; }
.composer input::placeholder, .composer textarea::placeholder { color: #4f596a; }
.composer input:focus, .composer textarea:focus { border-color: rgba(109,142,255,.55); box-shadow: 0 0 0 3px rgba(109,142,255,.08); }
.composer-foot { min-height: 40px; margin-top: 5px; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.composer-foot > span { color: var(--quiet); font-size: 9px; }
.primary-button { min-height: 40px; padding: 0 15px; border: 0; border-radius: 11px; color: white; background: linear-gradient(135deg, #607fe8, #7495ff); box-shadow: 0 8px 24px rgba(71,100,214,.25); cursor: pointer; font-size: 11px; font-weight: 750; transition: transform .12s, opacity .12s; }
.primary-button span { margin-left: 7px; }
.primary-button:hover { filter: brightness(1.07); }
.primary-button:active { transform: scale(.97); }
.primary-button:disabled { opacity: .55; cursor: wait; }
.feed-column { min-width: 0; }
.section-title { min-height: 34px; margin-bottom: 13px; display: flex; align-items: center; justify-content: space-between; }
.messages-list { display: grid; gap: 10px; }
.message-card { width: 100%; padding: 16px; display: grid; grid-template-columns: minmax(0,1fr) auto; gap: 13px; border: 1px solid var(--line); border-radius: 16px; text-align: left; color: inherit; background: #1c1c1e; transition: border .15s, background .15s, transform .15s; }
.message-open { min-width: 0; border: 0; padding: 0; color: inherit; text-align: left; background: transparent; cursor: pointer; }
.message-card:hover { border-color: rgba(255,255,255,.15); background: #242428; transform: translateY(-1px); }
.message-card h3 { margin: 0 0 6px; overflow: hidden; color: var(--text); font-size: 13px; line-height: 1.25; text-overflow: ellipsis; white-space: nowrap; }
.message-card p { margin: 0; overflow: hidden; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 3; color: var(--muted); font-size: 11px; line-height: 1.55; overflow-wrap: anywhere; white-space: pre-line; }
.delete-button { width: 31px; height: 31px; display: grid; place-items: center; border: 1px solid transparent; border-radius: 9px; color: #667084; background: transparent; cursor: pointer; font-size: 15px; transition: .15s; }
.delete-button svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 1.7; }
.delete-button:hover { color: var(--red); border-color: rgba(255,100,112,.15); background: rgba(255,100,112,.08); }
.empty-state { padding: 45px 16px; border: 1px dashed var(--line); border-radius: 18px; text-align: center; color: var(--quiet); font-size: 11px; }
.empty-state span { display: grid; place-items: center; width: 36px; height: 36px; margin: 0 auto 10px; border-radius: 12px; background: rgba(255,255,255,.035); font-size: 17px; }

/* Gallery */
.upload-zone { min-height: 145px; display: flex; flex-direction: column; align-items: center; justify-content: center; border: 1px dashed rgba(109,142,255,.3); border-radius: 20px; cursor: pointer; background: rgba(109,142,255,.035); transition: border .15s, background .15s; }
.upload-zone:hover, .upload-zone.is-uploading { border-color: rgba(109,142,255,.65); background: rgba(109,142,255,.065); }
.upload-zone input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.upload-icon { width: 35px; height: 35px; margin-bottom: 9px; display: grid; place-items: center; border-radius: 12px; color: #afc1ff; background: rgba(109,142,255,.14); font-size: 19px; }
.upload-zone strong { font-size: 12px; }
.upload-zone small { margin-top: 4px; color: var(--quiet); font-size: 9px; }
.upload-state { margin-top: 11px; color: var(--blue-bright); font-size: 9px; font-weight: 700; }
.gallery-title { margin-top: 27px; }
.images-grid { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 10px; }
.image-card { position: relative; aspect-ratio: 1; overflow: hidden; border: 1px solid var(--line); border-radius: 15px; background: var(--surface-2); cursor: zoom-in; }
.image-card img { width: 100%; height: 100%; display: block; object-fit: cover; transition: transform .3s ease, filter .2s; }
.image-card:hover img { transform: scale(1.035); filter: brightness(.75); }
.image-card .delete-button { position: absolute; top: 7px; right: 7px; color: white; background: rgba(4,6,9,.72); backdrop-filter: blur(8px); opacity: 0; transform: translateY(-3px); transition: .15s; }
.image-card:hover .delete-button, .image-card:focus-within .delete-button { opacity: 1; transform: none; }

/* Detail overlays */
dialog { padding: 0; color: var(--text); }
dialog::backdrop { background: rgba(2,3,5,.78); backdrop-filter: blur(12px); }
.detail-dialog { width: min(680px, calc(100vw - 32px)); max-height: min(760px, calc(100dvh - 42px)); border: 1px solid var(--line-strong); border-radius: 23px; background: #11151c; box-shadow: 0 30px 100px rgba(0,0,0,.6); }
.dialog-head { height: 59px; padding: 0 18px 0 22px; display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid var(--line); }
.dialog-head > span { color: var(--quiet); font-size: 9px; font-weight: 750; letter-spacing: .17em; }
.icon-button { width: 36px; height: 36px; display: grid; place-items: center; border: 1px solid var(--line); border-radius: 50%; color: var(--muted); background: rgba(255,255,255,.04); cursor: pointer; font-size: 21px; font-weight: 300; }
.icon-button:hover { color: var(--text); background: rgba(255,255,255,.08); }
.dialog-scroll { max-height: calc(100dvh - 124px); padding: clamp(23px, 5vw, 45px); overflow-y: auto; overscroll-behavior: contain; }
.dialog-scroll h2 { margin: 0 0 20px; font-size: clamp(24px, 5vw, 38px); line-height: 1.12; letter-spacing: -.04em; overflow-wrap: anywhere; }
.dialog-scroll p { margin: 0; color: #c1c8d4; font-size: 15px; line-height: 1.72; overflow-wrap: anywhere; white-space: pre-wrap; }
.image-dialog { width: 100vw; max-width: none; height: 100dvh; max-height: none; border: 0; background: #020304; overflow: hidden; }
.image-stage { width: 100%; height: 100%; display: grid; place-items: center; overflow: auto; overscroll-behavior: contain; }
.image-stage img { width: min(100vw, 1200px); height: auto; max-height: 100dvh; display: block; object-fit: contain; transform-origin: center; transition: width .12s ease; }
.lightbox-close { position: fixed; z-index: 2; top: max(14px, env(safe-area-inset-top)); left: max(14px, env(safe-area-inset-left)); width: 42px; height: 42px; border: 1px solid rgba(255,255,255,.18); border-radius: 50%; color: white; background: rgba(5,7,10,.72); backdrop-filter: blur(12px); cursor: pointer; font-size: 25px; }
.zoom-controls { position: fixed; z-index: 2; left: 50%; bottom: max(18px, env(safe-area-inset-bottom)); transform: translateX(-50%); height: 42px; display: flex; align-items: center; border: 1px solid rgba(255,255,255,.14); border-radius: 99px; background: rgba(8,10,14,.8); backdrop-filter: blur(12px); overflow: hidden; }
.zoom-controls button { width: 43px; height: 100%; border: 0; color: white; background: transparent; cursor: pointer; font-size: 18px; }
.zoom-controls button:hover { background: rgba(255,255,255,.08); }
.zoom-controls output { min-width: 56px; text-align: center; color: #a9b2c1; font-size: 10px; }
.toast { position: fixed; z-index: 100; left: 50%; bottom: max(22px, env(safe-area-inset-bottom)); transform: translate(-50%, 18px); max-width: calc(100vw - 34px); padding: 11px 15px; border: 1px solid var(--line-strong); border-radius: 12px; color: var(--text); background: rgba(25,30,40,.95); box-shadow: 0 15px 45px rgba(0,0,0,.4); opacity: 0; pointer-events: none; font-size: 11px; transition: opacity .18s, transform .18s; }
.toast.is-visible { opacity: 1; transform: translate(-50%, 0); }
.toast.is-error { border-color: rgba(255,100,112,.3); color: #ffc4c9; }

@keyframes view-in { from { opacity: 0; transform: translateY(5px); } }
@keyframes panel-in { from { opacity: 0; transform: translateY(4px); } }
@keyframes shake { 25% { transform: translateX(-7px); } 50% { transform: translateX(7px); } 75% { transform: translateX(-4px); } }

@media (max-width: 980px) {
    .slots-grid { grid-template-columns: repeat(3, 1fr); }
    .messages-layout { grid-template-columns: minmax(280px, 360px) minmax(300px, 1fr); gap: 24px; }
    .images-grid { grid-template-columns: repeat(3, minmax(0,1fr)); }
}

@media (max-width: 760px) {
    .ambient { display: none; }
    .slots-view.is-active { display: block; padding: max(18px, env(safe-area-inset-top)) 16px max(25px, env(safe-area-inset-bottom)); }
    .slots-shell { margin: 0 auto; }
    .back-link { margin: 0 0 29px; min-height: 34px; }
    .page-intro { text-align: left; margin-bottom: 26px; }
    .pulse-logo { display: none; }
    .page-intro h1 { font-size: 34px; }
    .page-intro > p:last-child { margin-left: 0; line-height: 1.45; }
    .slots-grid { grid-template-columns: 1fr; gap: 9px; }
    .slot-card { min-height: 78px; padding: 14px; display: flex; align-items: center; gap: 13px; border-radius: 17px; }
    .slot-card-number { width: 42px; height: 42px; }
    .slot-card strong, .slot-card small, .slot-arrow { position: static; }
    .slot-card strong { font-size: 14px; }
    .slot-card small { margin-left: auto; }
    .slot-arrow { margin-left: 2px; }
    .dashboard-view.is-active { display: block; }
    .sidebar, .workspace-head { display: none; }
    .workspace { width: 100%; padding: calc(67px + env(safe-area-inset-top)) 15px calc(35px + env(safe-area-inset-bottom)); }
    .mobile-header { position: fixed; z-index: 20; top: 0; left: 0; right: 0; height: calc(56px + env(safe-area-inset-top)); padding: env(safe-area-inset-top) 16px 0; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; border-bottom: 1px solid var(--line); background: rgba(8,10,15,.88); backdrop-filter: blur(18px); }
    .mobile-header > strong { font-size: 14px; }
    .text-button { justify-self: start; padding: 10px 0; border: 0; color: var(--blue-bright); background: transparent; cursor: pointer; font-size: 13px; }
    .mobile-live { justify-self: end; }
    .segmented { width: 100%; margin-bottom: 19px; }
    .segment { flex: 1; justify-content: center; min-width: 0; padding: 0 8px; }
    .messages-layout { display: flex; flex-direction: column; gap: 28px; }
    .composer { position: static; width: 100%; padding: 17px; }
    .composer textarea { min-height: 118px; }
    .feed-column { width: 100%; }
    .message-card { padding: 15px; }
    .message-card p { -webkit-line-clamp: 4; font-size: 12px; }
    .images-grid { grid-template-columns: repeat(3, minmax(0,1fr)); gap: 6px; }
    .image-card { border-radius: 11px; }
    .image-card .delete-button { opacity: 1; transform: none; top: 5px; right: 5px; background: rgba(4,6,9,.66); }
    .upload-zone { min-height: 133px; }
    .detail-dialog { width: 100vw; max-width: none; max-height: 88dvh; margin: auto 0 0; border-width: 1px 0 0; border-radius: 24px 24px 0 0; }
    .dialog-scroll { max-height: calc(88dvh - 59px); padding: 25px 20px max(35px, env(safe-area-inset-bottom)); }
    .dialog-scroll h2 { font-size: 28px; }
    .dialog-scroll p { font-size: 16px; line-height: 1.68; }
}

@media (max-width: 370px) {
    .pin-panel { transform: scale(.94); }
    .pin-dots { margin: 25px 0; }
    .pin-pad { grid-template-columns: repeat(3, 66px); gap: 10px 15px; }
    .pin-key { width: 66px; height: 53px; }
    .segment svg { display: none; }
    .images-grid { grid-template-columns: repeat(2, minmax(0,1fr)); }
    .composer-foot { align-items: end; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
}
