/* telepatty demo: Catppuccin Mocha / Latte, same tokens and class names as the real web client */

@font-face {
    font-family: 'JetBrains Mono';
    src: url('fonts/jetbrains-mono-latin-wght-normal.woff2') format('woff2');
    font-weight: 100 800;
    font-style: normal;
    font-display: swap;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --m-base: #1e1e2e; --m-mantle: #181825; --m-crust: #11111b;
    --m-text: #cdd6f4; --m-sub: #a6adc8; --m-overlay: #7f849c; --m-surface0: #313244; --m-surface1: #45475a;
    --m-mauve: #cba6f7; --m-green: #a6e3a1; --m-peach: #fab387;
    --mono: 'JetBrains Mono', 'SF Mono', 'Cascadia Code', ui-monospace, 'DejaVu Sans Mono', monospace;
}

html, body {
    height: 100%;
    background: var(--m-crust);
    color: var(--m-text);
    font-family: var(--mono);
    -webkit-text-size-adjust: 100%;
    -webkit-tap-highlight-color: transparent;
}
body { overflow: hidden; }

button { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--m-mauve); outline-offset: 2px; }

/* ===== desktop stage: tablet + phone side by side ===== */
.stage {
    position: fixed; inset: 0;
    display: flex; align-items: center; justify-content: center;
    background-color: var(--m-crust);
    background-image: radial-gradient(circle at 1px 1px, rgba(205, 214, 244, .07) 1px, transparent 0);
    background-size: 22px 22px;
    overflow: hidden;
}
.stage-inner {
    width: 1320px;
    flex-shrink: 0;
    display: flex; flex-direction: column; gap: 22px;
    transform-origin: center center;
}
.intro { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; padding: 0 4px; }
.brand { display: flex; align-items: center; gap: 14px; }
.brand-mark { width: 40px; height: 40px; color: var(--m-mauve); }
.brand-name { font-size: 26px; font-weight: 700; color: var(--m-mauve); letter-spacing: -.5px; line-height: 1.1; }
.brand-sub { font-size: 13px; color: var(--m-overlay); margin-top: 3px; }
.steps { list-style: none; display: flex; gap: 10px; }
.steps li {
    display: flex; align-items: center; gap: 9px;
    font-size: 12px; color: var(--m-sub);
    background: var(--m-mantle); border: 1px solid var(--m-surface0);
    padding: 7px 12px 7px 8px; border-radius: 8px;
}
.step-n {
    display: inline-grid; place-items: center; width: 20px; height: 20px; border-radius: 5px;
    background: var(--m-surface0); color: var(--m-mauve); font-weight: 700; font-size: 11px;
}
.steps kbd {
    font: 600 11px var(--mono); color: var(--m-green);
    border: 1px solid var(--m-surface1); background: var(--m-surface0); border-radius: 4px; padding: 1px 6px;
}
.caption { font-size: 12.5px; color: var(--m-overlay); text-align: center; }

.devices { display: flex; align-items: center; justify-content: center; gap: 44px; }
.device { position: relative; background: #0b0b12; flex-shrink: 0; box-shadow: 0 0 0 1px #2a2b3c, 0 30px 80px rgba(0, 0, 0, .55), inset 0 0 0 1px rgba(255, 255, 255, .04); }
.device .screen { position: relative; overflow: hidden; display: flex; flex-direction: column; background: var(--m-base); }
.tablet { padding: 18px; border-radius: 30px; }
.tablet .screen { width: 900px; height: 624px; border-radius: 14px; }
.phone { padding: 11px; border-radius: 48px; }
.phone .screen { width: 330px; height: 694px; border-radius: 38px; }

.statusbar {
    flex-shrink: 0; height: 24px; display: flex; align-items: center; justify-content: space-between;
    padding: 0 18px; font: 600 11px/1 system-ui, -apple-system, sans-serif; color: var(--m-text); background: var(--m-mantle);
    position: relative;
}
.phone .statusbar { height: 40px; padding: 4px 26px 0 30px; font-size: 12.5px; }
.island { position: absolute; left: 50%; top: 10px; width: 92px; height: 26px; margin-left: -46px; background: #000; border-radius: 14px; }
.sb-icons { display: flex; gap: 5px; align-items: center; }
.sb-icons svg { height: 10px; width: auto; }
.sb-icons svg:last-child { height: 11px; }
.home-bar { position: absolute; left: 50%; bottom: 6px; width: 110px; height: 4px; margin-left: -55px; border-radius: 3px; background: rgba(205, 214, 244, .55); pointer-events: none; z-index: 60; }
.mount { flex: 1; min-height: 0; display: flex; }
.phone .mount .input-bar { padding-bottom: 18px; }

/* ===== single mode: one full-bleed app (phones, narrow iframes) ===== */
html.single .intro, html.single .caption, html.single .tablet, html.single .statusbar, html.single .home-bar { display: none; }
html.single .stage { background: var(--m-base); display: block; }
html.single .stage-inner { width: 100%; height: 100%; transform: none !important; display: block; }
html.single .devices { display: block; height: 100%; }
html.single .phone { padding: 0; border-radius: 0; box-shadow: none; background: none; height: 100%; }
html.single .phone .screen { width: 100%; height: 100%; border-radius: 0; }
html.single .phone .mount .input-bar { padding-bottom: calc(8px + env(safe-area-inset-bottom)); }

.ribbon {
    position: fixed; right: 14px; top: 14px; z-index: 100;
    font: 600 11px/1 var(--mono); letter-spacing: .02em;
    color: var(--m-sub); background: rgba(24, 24, 37, .9); border: 1px solid var(--m-surface0);
    padding: 7px 10px; border-radius: 999px; text-decoration: none;
}
.ribbon:hover { color: var(--m-text); border-color: var(--m-surface1); }
html.single .ribbon { top: auto; bottom: 108px; right: 8px; padding: 5px 8px; font-size: 10px; opacity: .85; }

/* ===== the app (one instance per device) ===== */
.tp {
    --base: #1e1e2e; --mantle: #181825; --crust: #11111b;
    --text: #cdd6f4; --subtext1: #bac2de; --subtext0: #a6adc8;
    --overlay2: #9399b2; --overlay1: #7f849c; --overlay0: #6c7086;
    --surface2: #585b70; --surface1: #45475a; --surface0: #313244;
    --blue: #89b4fa; --lavender: #b4befe; --sapphire: #74c7ec; --sky: #89dceb; --teal: #94e2d5;
    --green: #a6e3a1; --yellow: #f9e2af; --peach: #fab387; --maroon: #eba0ac; --red: #f38ba8;
    --mauve: #cba6f7; --pink: #f5c2e7;
    --accent: #cba6f7;
    --radius: 8px; --radius-sm: 4px;
    --font-size: 13px; --header-h: 48px; --sidebar-w: 260px;

    position: relative; flex: 1; min-width: 0;
    display: flex; flex-direction: column;
    background: var(--base); color: var(--text);
    font-family: var(--mono); font-size: var(--font-size);
    container-type: inline-size; container-name: tp;
    overflow: hidden;
}
.tp[data-theme="light"] {
    --base: #eff1f5; --mantle: #e6e9ef; --crust: #dce0e8;
    --text: #4c4f69; --subtext1: #5c5f77; --subtext0: #6c6f85;
    --overlay2: #7c7f93; --overlay1: #8c8fa1; --overlay0: #9ca0b0;
    --surface2: #acb0be; --surface1: #bcc0cc; --surface0: #ccd0da;
    --blue: #1e66f5; --lavender: #7287fd; --sapphire: #209fb5; --sky: #04a5e5; --teal: #179299;
    --green: #40a02b; --yellow: #df8e1d; --peach: #fe640b; --maroon: #e64553; --red: #d20f39;
    --mauve: #8839ef; --pink: #ea76cb; --accent: #8839ef;
}
.phone .tp { --font-size: 11.5px; }
html.single .phone .tp { --font-size: 12.5px; }
.tp .hidden { display: none !important; }

.btn {
    display: inline-flex; align-items: center; justify-content: center;
    border: none; cursor: pointer; font-family: var(--mono); font-size: 13px;
    transition: background .15s, color .15s, opacity .15s; user-select: none; -webkit-user-select: none;
}
.btn-icon { width: 36px; height: 36px; border-radius: var(--radius-sm); background: transparent; color: var(--subtext0); flex-shrink: 0; }
.btn-icon:hover { color: var(--text); }
.btn-icon:active { background: var(--surface0); }
.btn-sm { width: 28px; height: 28px; }
.btn-fit-active { color: var(--green) !important; }

.header {
    display: flex; align-items: center; gap: 6px; padding: 0 6px;
    height: var(--header-h); flex-shrink: 0;
    background: var(--mantle); border-bottom: 1px solid var(--surface0); z-index: 20;
}
.header-title { flex: 1; min-width: 0; font-weight: 600; font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.header-title .ht-sess { color: var(--accent); }
.header-title .ht-sep { color: var(--overlay0); }
.header-actions { display: flex; gap: 2px; }
.conn { width: 7px; height: 7px; border-radius: 50%; background: var(--green); margin-right: 4px; flex-shrink: 0; box-shadow: 0 0 0 3px color-mix(in srgb, var(--green) 18%, transparent); }

.app-body { display: flex; flex: 1; min-height: 0; position: relative; overflow: hidden; }

.sidebar {
    position: absolute; top: 0; left: 0; bottom: 0; width: min(var(--sidebar-w), 84%);
    background: var(--mantle); border-right: 1px solid var(--surface0); z-index: 30;
    transform: translateX(-100%); transition: transform .2s ease;
    display: flex; flex-direction: column; overflow: hidden;
    visibility: hidden;
}
.sidebar.open { transform: none; visibility: visible; }
.sidebar-overlay { position: absolute; inset: 0; background: rgba(0, 0, 0, .5); z-index: 25; }
.sidebar-header {
    display: flex; align-items: center; justify-content: space-between; padding: 12px 10px 8px 12px;
    font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .5px; color: var(--overlay1); flex-shrink: 0;
}
.sidebar-foot { margin-top: auto; padding: 10px 12px 12px; border-top: 1px solid var(--surface0); font-size: 10.5px; color: var(--overlay0); line-height: 1.6; }
.sidebar-foot b { color: var(--green); font-weight: 600; }

.tree { padding: 0 8px 12px; flex: 1; min-height: 0; overflow-y: auto; }
.tree-session { margin-bottom: 8px; }
.tree-session-name {
    display: flex; align-items: center; gap: 6px; width: 100%; padding: 6px 8px; border: 0; background: none;
    font-size: 12px; font-weight: 600; color: var(--accent); cursor: pointer; border-radius: var(--radius-sm); text-align: left;
}
.tree-session-name:hover, .tree-window-name:hover, .tree-pane:hover { background: color-mix(in srgb, var(--surface0) 60%, transparent); }
.tree-session-name svg { width: 10px; height: 10px; transition: transform .15s; flex-shrink: 0; }
.tree-session-name .ts-count { margin-left: auto; font-weight: 400; font-size: 10.5px; color: var(--overlay0); }
.tree-session.collapsed .tree-session-name svg { transform: rotate(-90deg); }
.tree-session.collapsed .tree-windows { display: none; }
.tree-window { margin-left: 8px; margin-top: 2px; }
.tree-window-name { display: flex; align-items: center; gap: 7px; padding: 4px 8px; font-size: 12px; color: var(--subtext1); border-radius: var(--radius-sm); }
.tree-window-name svg { width: 13px; height: 13px; flex-shrink: 0; color: var(--overlay1); }
.tree-window.active > .tree-window-name { color: var(--accent); }
.tree-window.active > .tree-window-name svg { color: var(--accent); }
.tree-window-label { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tree-window-idx { color: var(--overlay0); }
.tree-pane {
    display: flex; align-items: center; gap: 7px; width: calc(100% - 22px); margin-left: 22px; padding: 4px 8px;
    border: 0; background: none; font-size: 11px; color: var(--subtext0); cursor: pointer; border-radius: var(--radius-sm); text-align: left;
}
.tree-pane.active { background: var(--surface0); color: var(--accent); }
.tree-pane-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--overlay0); flex-shrink: 0; }
.tree-pane.active .tree-pane-dot { background: var(--accent); }
.tree-pane.busy .tree-pane-dot { background: var(--peach); animation: pulse 1s ease infinite; }
.tree-pane-cmd { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tree-pane-size { color: var(--overlay0); font-size: 10px; }

.terminal-area { flex: 1; display: flex; flex-direction: column; overflow: hidden; min-width: 0; position: relative; }
.terminal {
    flex: 1; overflow-y: auto; overflow-x: hidden; padding: 8px 10px;
    background: var(--base); font-size: var(--font-size); line-height: 1.42;
    white-space: pre-wrap; word-break: break-word; overflow-wrap: anywhere;
    scrollbar-width: thin; scrollbar-color: var(--surface1) transparent;
}
.terminal .ln { min-height: 1.42em; }
.cursor { display: inline-block; width: .62em; height: 1.15em; vertical-align: -.2em; background: var(--text); animation: blink 1.1s steps(1) infinite; }
@keyframes blink { 50% { opacity: 0; } }
.spin { color: var(--peach); }

.ansi-bold { font-weight: 700; }
.ansi-dim { opacity: .6; }
.ansi-italic { font-style: italic; }
.ansi-fg-black { color: var(--surface1); }
.ansi-fg-red { color: var(--red); }
.ansi-fg-green { color: var(--green); }
.ansi-fg-yellow { color: var(--yellow); }
.ansi-fg-blue { color: var(--blue); }
.ansi-fg-magenta { color: var(--mauve); }
.ansi-fg-cyan { color: var(--teal); }
.ansi-fg-white { color: var(--text); }
.ansi-fg-bright-black { color: var(--overlay0); }
.ansi-fg-bright-red { color: var(--maroon); }
.ansi-fg-bright-blue { color: var(--sapphire); }
.ansi-fg-bright-magenta { color: var(--pink); }
.ansi-fg-bright-cyan { color: var(--sky); }
.ansi-bg-black { background: var(--surface0); }
.ansi-bg-green { background: color-mix(in srgb, var(--green) 16%, transparent); }
.ansi-bg-red { background: color-mix(in srgb, var(--red) 16%, transparent); }

.term-keys { flex-shrink: 0; background: var(--mantle); border-top: 1px solid var(--surface0); overflow: hidden; }
.term-keys-row { display: flex; gap: 4px; padding: 6px 8px; overflow-x: auto; scrollbar-width: none; }
.term-keys-row::-webkit-scrollbar { display: none; }
.tk {
    flex-shrink: 0; display: inline-flex; align-items: center; justify-content: center;
    min-width: 36px; height: 32px; padding: 0 8px;
    border: 1px solid var(--surface1); border-radius: var(--radius-sm); background: var(--surface0);
    color: var(--text); font-family: var(--mono); font-size: 12px; font-weight: 500; cursor: pointer;
    user-select: none; -webkit-user-select: none; transition: background .1s, border-color .1s, transform .08s;
}
.tk svg { width: 10px; height: 10px; }
.tk:hover { border-color: var(--surface2); }
.tk:active, .tk.pressed { background: var(--surface1); transform: translateY(1px); }
.tk-mod { color: var(--subtext0); }
.tk-mod.active { background: var(--accent); color: var(--base); border-color: var(--accent); }
.tk-shortcut { color: var(--peach); border-color: var(--surface2); }
.tk-yes { color: var(--green); }
.tk-no { color: var(--red); }
.tk.attn { border-color: var(--green); box-shadow: 0 0 0 2px color-mix(in srgb, var(--green) 30%, transparent); animation: attn 1.6s ease infinite; }
@keyframes attn { 50% { box-shadow: 0 0 0 5px color-mix(in srgb, var(--green) 8%, transparent); } }
.tk-sep { flex-shrink: 0; width: 1px; height: 24px; margin: 4px 2px; background: var(--surface1); }

.input-bar {
    display: flex; align-items: center; gap: 6px; padding: 8px;
    background: var(--mantle); border-top: 1px solid var(--surface0); min-height: 52px; flex-shrink: 0;
}
.input-text {
    flex: 1; min-width: 0; height: 36px; padding: 8px 12px;
    border: 1px solid var(--surface1); border-radius: var(--radius); background: var(--surface0); color: var(--text);
    font-family: var(--mono); font-size: 14px; line-height: 1.4; outline: none; resize: none; overflow: hidden;
}
.input-text::placeholder { color: var(--overlay0); }
.input-text:focus { border-color: var(--accent); }
.btn-mic { color: var(--subtext0); }
.btn-mic.recording { color: var(--red); animation: pulse 1s ease infinite; }
.btn-mic.attn { color: var(--accent); }
.btn-send { color: var(--accent); }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: .5; } }

.voice {
    flex: 1; min-width: 0; height: 36px; display: flex; align-items: center; gap: 10px; padding: 0 12px;
    border: 1px solid color-mix(in srgb, var(--red) 55%, var(--surface1)); border-radius: var(--radius);
    background: color-mix(in srgb, var(--red) 7%, var(--surface0));
}
.voice.transcribing { border-color: var(--surface1); background: var(--surface0); }
.voice-bars { flex: 1; min-width: 0; height: 22px; display: flex; align-items: center; gap: 2px; overflow: hidden; }
.voice-bars i { flex: 1; min-width: 2px; max-width: 4px; height: 3px; border-radius: 2px; background: var(--red); transition: height .08s linear; }
.voice.transcribing .voice-bars i { background: var(--overlay0); height: 3px !important; }
.voice-label { font-size: 11px; color: var(--subtext0); white-space: nowrap; }
.voice-time { font-size: 11px; color: var(--red); font-variant-numeric: tabular-nums; }
.voice.transcribing .voice-time { color: var(--overlay1); }

.toast {
    position: absolute; left: 50%; bottom: 104px; transform: translate(-50%, 8px); z-index: 40;
    max-width: calc(100% - 24px); padding: 8px 12px; border-radius: var(--radius);
    background: var(--crust); color: var(--text); border: 1px solid var(--surface1); font-size: 11.5px;
    opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; text-align: center;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* wide container (tablet, desktop): sidebar inline, like the real client at 768 px and up */
@container tp (min-width: 640px) {
    .sidebar { position: static; transform: none; width: 0; min-width: 0; flex-shrink: 0; overflow: hidden; border-right: 0; visibility: hidden; transition: width .2s ease, min-width .2s ease; }
    .sidebar.open { width: var(--sidebar-w); min-width: var(--sidebar-w); border-right: 1px solid var(--surface0); visibility: visible; }
    .sidebar-overlay { display: none !important; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation: none !important; transition: none !important; }
}
