/* SMP App PWA — mobile-first, Aurora-inspired chrome. */
:root {
    --bg: #070b1a;
    --bg-elev: #0d1330;
    --bg-input: rgba(255, 255, 255, 0.06);
    --glass: rgba(255, 255, 255, 0.07);
    --glass-strong: rgba(255, 255, 255, 0.11);
    --border: rgba(255, 255, 255, 0.14);
    --text: #eef2ff;
    --text-muted: rgba(238, 242, 255, 0.62);
    --accent: #f5b301;
    --accent-2: #25d0c0;
    --accent-ink: #1a1400;
    --info: #3d9bff;
    --warn: #ffb020;
    --danger: #ff5a5a;
    --radius: 14px;
    --safe-top: env(safe-area-inset-top, 0px);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
    --app-height: 100dvh;
    --composer-height: 68px;
    --keyboard-offset: 0px;
}

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

html {
    height: -webkit-fill-available;
}

html,
body {
    margin: 0;
    padding: 0;
    height: 100%;
    overflow: hidden;
}

body {
    background: var(--bg);
    color: var(--text);
    font-family: "Segoe UI", -apple-system, BlinkMacSystemFont, Roboto, Helvetica, Arial, sans-serif;
    -webkit-font-smoothing: antialiased;
    overscroll-behavior-y: none;
    touch-action: manipulation;
}

.auth-screen {
    position: fixed;
    inset: 0;
    z-index: 50;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: radial-gradient(120% 90% at 50% -10%, transparent 40%, rgba(0, 0, 0, 0.55) 100%), var(--bg);
}

.auth-screen.hidden {
    display: none;
}

.auth-card {
    width: 100%;
    max-width: 380px;
    background: rgba(23, 29, 60, 0.97);
    border: 1px solid rgba(255, 255, 255, 0.16);
    border-radius: calc(var(--radius) + 4px);
    padding: 24px 20px;
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
}

.auth-card__title {
    margin: 0 0 4px;
    font-size: 1.25rem;
}

.auth-card__sub {
    margin: 0 0 16px;
    color: var(--text-muted);
    font-size: 0.85rem;
}

.auth-card__status {
    min-height: 1.2em;
    margin: 0 0 12px;
    font-size: 0.85rem;
    color: var(--text-muted);
}

.auth-card__status.is-error {
    color: #ffc4c4;
}

.auth-card__status.is-success {
    color: #7ee0a2;
}

.auth-card__field {
    display: block;
    margin-bottom: 12px;
}

.auth-card__label {
    display: block;
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-bottom: 6px;
}

.auth-card__field input {
    width: 100%;
    padding: 11px 12px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: var(--glass);
    color: var(--text);
    font: inherit;
}

.auth-card__submit {
    width: 100%;
    margin-top: 8px;
    padding: 12px;
    border: none;
    border-radius: 10px;
    background: linear-gradient(135deg, var(--accent), var(--accent-2));
    color: #fff;
    font: inherit;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 8px 20px -8px rgba(245, 179, 1, 0.55);
}

.app--locked {
    visibility: hidden;
    pointer-events: none;
}

.app.app--ready {
    visibility: visible;
    pointer-events: auto;
}

.app {
    display: flex;
    flex-direction: column;
    height: var(--app-height);
    max-height: var(--app-height);
    max-width: 720px;
    margin: 0 auto;
    overflow: hidden;
}

/* Single flex child for both Cursor + Ideas panels — avoids split-height bug. */
.app-main {
    flex: 1 1 0%;
    min-height: 0;
    position: relative;
    overflow: hidden;
    padding-bottom: var(--composer-height);
}

/* Header */
.app-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-shrink: 0;
    padding: calc(var(--safe-top) + 10px) 16px 10px;
    border-bottom: 1px solid var(--border);
    background: linear-gradient(180deg, rgba(0, 0, 0, 0.35), rgba(0, 0, 0, 0.05));
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
}

.app-header__title {
    display: flex;
    align-items: center;
    gap: 10px;
}

.app-header__title h1 {
    font-size: 1rem;
    font-weight: 700;
    margin: 0;
    letter-spacing: 0.2px;
}

.app-header__dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--accent);
    box-shadow: 0 0 10px var(--accent);
}

/* Mode tabs — compact pill switcher */
.mode-tabs {
    display: flex;
    flex-shrink: 0;
    gap: 4px;
    padding: 8px 16px;
    background: var(--bg);
    border-bottom: 1px solid var(--border);
}

.mode-tab {
    flex: 1;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--glass);
    color: var(--text-muted);
    font: inherit;
    font-size: 0.82rem;
    font-weight: 600;
    padding: 7px 12px;
    cursor: pointer;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.mode-tab.is-active {
    color: var(--text);
    background: rgba(245, 179, 1, 0.18);
    border-color: rgba(245, 179, 1, 0.45);
}

/* Chat */
.chat-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: auto;
}

.chat-scroll--empty .chat-list {
    margin-top: 0;
}

.chat-bubble {
    max-width: 88%;
    display: flex;
    flex-direction: column;
    animation: rise 0.18s ease-out;
}

.chat-bubble--user {
    align-self: flex-end;
}

.chat-bubble--assistant {
    align-self: flex-start;
}

.chat-bubble--pending {
    opacity: 0.75;
}

.chat-bubble__body {
    padding: 10px 12px;
    border-radius: 14px;
    white-space: pre-wrap;
    word-break: break-word;
    line-height: 1.45;
    font-size: 0.92rem;
}

.chat-bubble--user .chat-bubble__body {
    background: rgba(245, 179, 1, 0.22);
    border: 1px solid rgba(245, 179, 1, 0.38);
    border-bottom-right-radius: 4px;
}

.chat-bubble--assistant .chat-bubble__body {
    background: var(--glass-strong);
    border: 1px solid var(--border);
    border-bottom-left-radius: 4px;
}

.chat-bubble__images {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 8px;
}

.chat-bubble__images img {
    max-width: 160px;
    max-height: 160px;
    border-radius: 8px;
    object-fit: cover;
    border: 1px solid rgba(255, 255, 255, 0.12);
}

.chat-bubble__meta {
    font-size: 0.62rem;
    font-weight: 600;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    color: var(--text-muted);
    margin-bottom: 4px;
    padding: 0 2px;
}

/* Pills */
.pill {
    display: inline-block;
    font-size: 0.68rem;
    font-weight: 600;
    padding: 3px 9px;
    border-radius: 999px;
    border: 1px solid var(--border);
    white-space: nowrap;
}

.pill--muted {
    color: var(--text-muted);
}

.pill--ok {
    color: #7ee0a2;
    border-color: rgba(126, 224, 162, 0.4);
}

.pill--info {
    color: var(--info);
    border-color: rgba(61, 155, 255, 0.4);
}

.pill--rec {
    color: var(--danger);
    border-color: rgba(255, 90, 90, 0.5);
    animation: pulse 1.2s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.45; }
}

/* Banner */
.banner {
    flex-shrink: 0;
    margin: 8px 16px 0;
    padding: 10px 12px;
    border-radius: var(--radius);
    font-size: 0.85rem;
    border: 1px solid var(--border);
}

.banner--warn {
    background: rgba(255, 176, 32, 0.1);
    border-color: rgba(255, 176, 32, 0.4);
    color: #ffd98a;
}

.banner p {
    margin: 0;
}

.banner a {
    color: var(--accent);
    font-weight: 600;
}

/* Feed — panels stack in .app-main and fill it completely. */
.feed {
    position: absolute;
    inset: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.feed[hidden] {
    display: none;
}

.feed--chat {
    padding: 0;
}

.feed--ideas {
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 12px 14px;
}

.chat-scroll {
    flex: 1 1 0%;
    min-height: 0;
    height: 100%;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 12px 14px;
    display: flex;
    flex-direction: column;
}

.idea-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.idea {
    background: var(--glass-strong);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 12px 14px;
    animation: rise 0.18s ease-out;
}

@keyframes rise {
    from { transform: translateY(6px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

.idea__body {
    margin: 0;
    white-space: pre-wrap;
    word-break: break-word;
    line-height: 1.45;
    font-size: 0.95rem;
}

.idea__meta {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 8px;
    font-size: 0.72rem;
    color: var(--text-muted);
}

.idea__source {
    text-transform: capitalize;
}

.idea--pending {
    opacity: 0.6;
}

/* Empty state */
.empty {
    text-align: center;
    color: var(--text-muted);
    padding: 24px 16px;
}

.empty--chat {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    margin: auto 0;
}

.empty__title {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text);
    margin: 0 0 6px;
}

.empty__hint {
    margin: 0;
    font-size: 0.82rem;
    max-width: 260px;
    line-height: 1.4;
}

/* Composer — pinned to bottom so mobile browsers can't push it off-screen. */
.composer {
    position: fixed;
    left: 0;
    right: 0;
    bottom: var(--keyboard-offset);
    z-index: 15;
    max-width: 720px;
    margin: 0 auto;
    border-top: 1px solid var(--border);
    background: linear-gradient(180deg, rgba(0, 0, 0, 0.08), rgba(0, 0, 0, 0.22));
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    padding: 10px 12px calc(var(--safe-bottom) + 10px);
    transition: bottom 0.15s ease-out;
}

.record-hint {
    font-size: 0.75rem;
    color: var(--text-muted);
    padding: 0 4px 8px;
}

.composer__row {
    display: flex;
    align-items: flex-end;
    gap: 8px;
}

.composer__input {
    flex: 1;
    resize: none;
    max-height: 120px;
    min-height: 40px;
    padding: 9px 14px;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: var(--glass);
    color: var(--text);
    font: inherit;
    font-size: 0.92rem;
    line-height: 1.4;
}

.composer__input:focus {
    outline: none;
    border-color: rgba(245, 179, 1, 0.55);
}

.btn {
    border: none;
    border-radius: 999px;
    font: inherit;
    font-weight: 600;
    cursor: pointer;
    touch-action: manipulation;
    transition: transform 0.12s;
}

.btn:active:not(:disabled) {
    transform: scale(0.94);
}

.btn--send {
    background: linear-gradient(135deg, var(--accent), var(--accent-2));
    color: #fff;
    width: 40px;
    height: 40px;
    flex-shrink: 0;
    padding: 0;
    font-size: 0;
    box-shadow: 0 6px 16px -6px rgba(245, 179, 1, 0.65);
    background-image: linear-gradient(135deg, var(--accent), var(--accent-2));
    position: relative;
}

.btn--send::after {
    content: "\2191";
    font-size: 1.05rem;
    line-height: 1;
}

.btn--send:disabled {
    opacity: 0.35;
    cursor: default;
    transform: none;
}

.btn--attach,
.btn--mic {
    width: 40px;
    height: 40px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--glass);
    border: 1px solid var(--border);
    font-size: 1.05rem;
    border-radius: 50%;
}

.btn--attach:disabled {
    opacity: 0.35;
    cursor: default;
}

.image-preview {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 0 4px 10px;
}

.image-preview__item {
    position: relative;
    width: 64px;
    height: 64px;
}

.image-preview__item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 10px;
    border: 1px solid var(--border);
}

.image-preview__remove {
    position: absolute;
    top: -6px;
    right: -6px;
    width: 22px;
    height: 22px;
    border: none;
    border-radius: 999px;
    background: var(--bg-elev);
    color: var(--text);
    border: 1px solid var(--border);
    font-size: 0.85rem;
    line-height: 1;
    cursor: pointer;
    touch-action: manipulation;
}

.btn--mic.is-recording {
    background: rgba(255, 90, 90, 0.16);
    border-color: var(--danger);
}

.btn--mic.is-busy {
    opacity: 0.5;
    cursor: default;
}

.composer__source {
    padding: 6px 4px 0;
}

/* Toast */
.toast {
    position: fixed;
    left: 50%;
    bottom: calc(var(--safe-bottom) + var(--composer-height) + 12px);
    transform: translateX(-50%);
    background: var(--glass-strong);
    color: var(--text);
    border: 1px solid var(--border);
    padding: 10px 16px;
    border-radius: 999px;
    font-size: 0.82rem;
    z-index: 20;
    max-width: 90vw;
    text-align: center;
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}

.toast--error {
    border-color: var(--danger);
    color: #ffc4c4;
}
