:root {
    --home-border: rgba(61, 58, 57, 0.88);
    --home-border-strong: rgba(87, 81, 79, 0.96);
    --home-panel: rgba(16, 16, 16, 0.92);
    --home-panel-strong: rgba(8, 8, 9, 0.98);
    --home-accent: rgba(77, 163, 255, 0.18);
    --home-accent-strong: rgba(77, 163, 255, 0.55);
    --home-shadow: 0 20px 52px rgba(0, 0, 0, 0.4);
    --home-shadow-strong: 0 30px 84px rgba(0, 0, 0, 0.56);
}

body.home-body {
    position: relative;
    overflow-x: hidden;
}

.page-backdrop {
    position: fixed;
    inset: 0;
    pointer-events: none;
    background:
        radial-gradient(circle at top right, rgba(77, 163, 255, 0.09), transparent 28%),
        radial-gradient(circle at 15% 12%, rgba(48, 108, 206, 0.1), transparent 20%),
        linear-gradient(180deg, rgba(255, 255, 255, 0.02), transparent 18%);
    opacity: 0.9;
    z-index: -1;
}

.shell-header {
    position: sticky;
    top: 0;
    z-index: 20;
    backdrop-filter: blur(20px);
    background: rgba(5, 5, 7, 0.84);
    border-bottom: 1px solid rgba(61, 58, 57, 0.85);
}

.shell-header__inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-5);
    min-height: 80px;
}

.home-header {
    padding: var(--space-3) 0;
}

.header-status {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    flex-wrap: wrap;
    justify-content: flex-end;
}

.shell-link {
    min-height: 40px;
}

.auth-link {
    white-space: nowrap;
}

.status-chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: 40px;
    padding: 0 14px;
    border-radius: var(--radius-pill);
    border: 1px solid var(--border-default);
    background: rgba(255, 255, 255, 0.02);
    color: var(--text-secondary);
    font-family: var(--mono-font);
    font-size: 0.8rem;
    letter-spacing: 0.04em;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--warning);
    box-shadow: 0 0 0 0 rgba(255, 186, 0, 0.26);
    transition: background 160ms ease, box-shadow 160ms ease;
}

.status-dot.is-live {
    background: var(--accent-primary);
    box-shadow: 0 0 0 6px rgba(77, 163, 255, 0.08);
}

.status-dot.is-offline {
    background: var(--danger);
    box-shadow: 0 0 0 6px rgba(251, 86, 91, 0.08);
}

.app-main {
    padding: var(--space-6) 0 var(--space-10);
    display: flex;
    flex-direction: column;
    gap: var(--space-6);
}

.hero {
    display: grid;
    grid-template-columns: minmax(0, 1.3fr) minmax(320px, 0.9fr);
    gap: var(--space-6);
    padding: var(--space-6);
    border-radius: var(--radius-md);
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.012), transparent 24%),
        var(--bg-surface);
    border: 1px solid var(--border-default);
    box-shadow: var(--home-shadow);
}

.hero-copy h2 {
    margin: 10px 0 0;
    font-family: var(--display-font);
    font-size: clamp(2rem, 4vw, 3.6rem);
    font-weight: 600;
    line-height: 0.98;
    letter-spacing: -0.05em;
    max-width: 14ch;
}

.hero-description {
    margin: var(--space-4) 0 0;
    max-width: 68ch;
    color: var(--text-secondary);
    font-size: 1rem;
}

.hero-metrics {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: var(--space-3);
    align-content: start;
}

.metric-card {
    padding: var(--space-4);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-md);
    background: var(--home-panel);
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.015);
}

.metric-card span {
    display: block;
    color: var(--text-tertiary);
    font-family: var(--mono-font);
    font-size: 0.74rem;
    letter-spacing: 0.2em;
    text-transform: uppercase;
}

.metric-card strong {
    display: block;
    margin-top: 10px;
    color: var(--text-primary);
    font-family: var(--mono-font);
    font-size: 1.05rem;
    font-weight: 700;
    overflow-wrap: anywhere;
}

.workspace-grid {
    display: grid;
    grid-template-columns: minmax(0, 2.1fr) minmax(320px, 0.86fr);
    gap: var(--space-6);
    align-items: start;
}

.workspace-main {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: var(--space-5);
}

.workspace-rail {
    display: flex;
    flex-direction: column;
    gap: var(--space-5);
}

.operator-panel,
.rail-panel,
.history-section,
.chat-drawer,
.overlay-shell {
    border-radius: var(--radius-md);
    border: 1px solid var(--border-default);
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.01), transparent 18%),
        var(--home-panel);
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.01);
}

.operator-panel,
.rail-panel,
.history-section {
    padding: var(--space-5);
}

.operator-panel {
    display: flex;
    flex-direction: column;
    min-height: 620px;
}

.panel-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: var(--space-4);
    margin-bottom: var(--space-4);
}

.panel-kicker {
    margin: 0;
    color: var(--text-tertiary);
    font-family: var(--mono-font);
    font-size: 0.75rem;
    letter-spacing: 0.24em;
    text-transform: uppercase;
}

.panel-title {
    margin: 6px 0 0;
    font-family: var(--display-font);
    font-size: clamp(1.2rem, 2vw, 1.7rem);
    font-weight: 600;
    letter-spacing: -0.04em;
}

.panel-copy {
    margin: 8px 0 0;
    color: var(--text-secondary);
    font-size: 0.96rem;
}

.panel-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.field-label {
    display: block;
    margin-bottom: 8px;
    color: var(--text-secondary);
    font-size: 0.86rem;
    font-weight: 600;
}

.panel-textarea,
.panel-input,
.panel-select,
.chat-input {
    border: 1px solid var(--border-default);
    border-radius: var(--radius-sm);
    background: rgba(6, 6, 8, 0.88);
    color: var(--text-primary);
    transition: border-color 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

.panel-textarea {
    width: 100%;
    min-height: 320px;
    padding: 14px 14px 16px;
    resize: vertical;
    font-family: var(--body-font);
    line-height: 1.75;
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.015);
}

.panel-textarea--result {
    min-height: 320px;
    color: rgba(208, 255, 232, 0.96);
}

.panel-textarea:focus,
.panel-input:focus,
.panel-select:focus,
.chat-input:focus {
    outline: none;
    border-color: rgba(77, 163, 255, 0.6);
    box-shadow: var(--ring-accent);
}

.panel-textarea::placeholder,
.panel-input::placeholder,
.chat-input::placeholder {
    color: var(--text-tertiary);
}

.panel-footer {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: var(--space-3);
    margin-top: auto;
    padding-top: var(--space-4);
    border-top: 1px solid rgba(61, 58, 57, 0.75);
}

.panel-footer--result {
    align-items: center;
}

.mono-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-height: 30px;
    padding: 0 10px;
    border-radius: var(--radius-pill);
    border: 1px solid var(--border-default);
    color: var(--text-secondary);
    background: rgba(255, 255, 255, 0.02);
    font-family: var(--mono-font);
    font-size: 0.78rem;
}

.select-stack {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: var(--space-3);
    min-width: min(420px, 100%);
}

.select-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
    color: var(--text-secondary);
    font-size: 0.82rem;
}

.panel-select {
    width: 100%;
    min-height: 40px;
    padding: 0 12px;
    appearance: none;
}

.panel-input {
    width: 100%;
    min-height: 42px;
    padding: 0 12px;
    margin-bottom: var(--space-3);
}

.full-width {
    width: 100%;
}

.primary-button,
.secondary-button,
.ghost-button,
.utility-button {
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-default);
    text-decoration: none;
    transition: transform 160ms ease, border-color 160ms ease, background 160ms ease, box-shadow 160ms ease, color 160ms ease;
}

.primary-button,
.secondary-button,
.ghost-button {
    min-height: 42px;
    padding: 0 14px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    color: var(--text-primary);
    background: var(--home-panel);
    font-family: var(--body-font);
    font-size: 0.95rem;
    font-weight: 600;
}

.primary-button {
    border-color: rgba(77, 163, 255, 0.52);
    background: linear-gradient(180deg, rgba(77, 163, 255, 0.18), rgba(77, 163, 255, 0.08));
    box-shadow: 0 0 0 1px rgba(77, 163, 255, 0.15), inset 0 0 0 1px rgba(255, 255, 255, 0.02);
}

.secondary-button {
    background: rgba(255, 255, 255, 0.01);
}

.ghost-button {
    background: transparent;
    color: var(--text-secondary);
}

.utility-button {
    min-height: 34px;
    padding: 0 10px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.02);
    color: var(--text-secondary);
    font-family: var(--mono-font);
    font-size: 0.76rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}

.primary-button:hover,
.secondary-button:hover,
.ghost-button:hover,
.utility-button:hover,
.chat-send:hover {
    transform: translateY(-1px);
    border-color: var(--border-strong);
    box-shadow: var(--home-shadow);
}

.primary-button:hover {
    border-color: rgba(77, 163, 255, 0.75);
}

.action-stack {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.rail-note {
    margin: var(--space-4) 0 0;
    color: var(--text-tertiary);
    font-size: 0.88rem;
}

.rail-note--top {
    margin-top: 0;
    margin-bottom: var(--space-4);
}

.rail-link {
    display: inline-flex;
    margin-top: var(--space-3);
    color: var(--accent-link);
    font-size: 0.9rem;
    text-decoration: none;
}

.rail-link:hover {
    text-decoration: underline;
}

.badge {
    display: inline-flex;
    align-items: center;
    min-height: 28px;
    padding: 0 10px;
    border-radius: var(--radius-pill);
    border: 1px solid rgba(77, 163, 255, 0.35);
    background: rgba(77, 163, 255, 0.07);
    color: var(--accent-soft);
    font-family: var(--mono-font);
    font-size: 0.75rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.system-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.system-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-3);
    padding: 12px 0;
    border-bottom: 1px solid rgba(61, 58, 57, 0.65);
    color: var(--text-secondary);
    font-size: 0.92rem;
}

.system-row:last-child {
    border-bottom: 0;
    padding-bottom: 0;
}

.system-row strong {
    color: var(--text-primary);
    font-family: var(--mono-font);
    font-size: 0.86rem;
}

.history-section {
    display: flex;
    flex-direction: column;
    gap: var(--space-4);
}

.history-list {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: var(--space-3);
}

.history-empty {
    grid-column: 1 / -1;
    padding: var(--space-5);
    border: 1px dashed rgba(61, 58, 57, 0.92);
    border-radius: var(--radius-md);
    color: var(--text-tertiary);
    text-align: center;
}

.history-item {
    display: flex;
    flex-direction: column;
    gap: 8px;
    width: 100%;
    padding: var(--space-4);
    border-radius: var(--radius-md);
    border: 1px solid var(--border-default);
    background: rgba(255, 255, 255, 0.015);
    color: inherit;
    text-align: left;
    cursor: pointer;
    transition: transform 160ms ease, border-color 160ms ease, background 160ms ease;
}

.history-item:hover {
    transform: translateY(-1px);
    border-color: rgba(77, 163, 255, 0.5);
    background: rgba(77, 163, 255, 0.06);
}

.history-item__source,
.history-item__result {
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    line-clamp: 2;
}

.history-item__source {
    color: var(--text-secondary);
    font-size: 0.92rem;
}

.history-item__result {
    color: rgba(208, 255, 232, 0.94);
    font-size: 0.96rem;
}

.history-item__meta {
    color: var(--text-tertiary);
    font-family: var(--mono-font);
    font-size: 0.72rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.extension-hero {
    align-items: stretch;
}

.download-grid,
.extension-install-grid {
    display: grid;
    gap: var(--space-3);
}

.download-grid {
    grid-template-columns: 1fr;
}

.extension-install-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.download-card {
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-height: 128px;
    padding: var(--space-4);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-md);
    background: var(--home-panel);
    color: inherit;
    text-decoration: none;
    transition: transform 160ms ease, border-color 160ms ease, background 160ms ease;
}

.download-card:hover {
    transform: translateY(-1px);
    border-color: rgba(77, 163, 255, 0.55);
    background: rgba(77, 163, 255, 0.055);
}

.download-card span,
.download-card small {
    color: var(--text-secondary);
}

.download-card strong {
    color: var(--accent-soft);
    font-family: var(--display-font);
    font-size: 1.35rem;
    font-weight: 600;
}

.install-steps {
    margin: 0;
    padding-left: 1.4rem;
    color: var(--text-secondary);
}

.install-steps li + li {
    margin-top: 10px;
}

.install-steps code {
    padding: 2px 6px;
    border: 1px solid var(--border-default);
    border-radius: var(--radius-xs);
    background: rgba(255, 255, 255, 0.035);
    color: var(--accent-soft);
    font-family: var(--mono-font);
    font-size: 0.86em;
}

.voice-status {
    min-height: 24px;
    margin-top: var(--space-4);
    color: var(--text-tertiary);
    font-size: 0.9rem;
}

.voice-status.is-live {
    color: var(--accent-soft);
}

.chat-drawer {
    position: fixed;
    right: 24px;
    bottom: 24px;
    width: min(420px, calc(100vw - 48px));
    max-height: 70vh;
    padding: var(--space-4);
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
    z-index: 40;
    box-shadow: var(--home-shadow-strong);
    transform: translateY(16px) scale(0.98);
    opacity: 0;
    pointer-events: none;
    transition: opacity 180ms ease, transform 180ms ease;
}

.chat-drawer.is-open {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0) scale(1);
}

.chat-drawer__header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: var(--space-3);
}

.chat-close {
    min-height: 34px;
}

.chat-messages {
    flex: 1;
    overflow: auto;
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding-right: 4px;
    min-height: 220px;
}

.chat-msg {
    max-width: 92%;
    padding: 10px 12px;
    border-radius: 14px;
    border: 1px solid var(--border-default);
    background: rgba(255, 255, 255, 0.02);
    color: var(--text-primary);
    font-size: 0.92rem;
    line-height: 1.6;
    word-break: break-word;
}

.chat-msg.user {
    align-self: flex-end;
    border-color: rgba(77, 163, 255, 0.45);
    background: rgba(77, 163, 255, 0.08);
}

.chat-msg.ai {
    align-self: flex-start;
}

.chat-typing {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    width: fit-content;
    padding: 10px 12px;
    border-radius: 14px;
    border: 1px solid var(--border-default);
    background: rgba(255, 255, 255, 0.02);
}

.chat-typing span {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--text-tertiary);
    animation: typingDot 1.2s ease-in-out infinite;
}

.chat-typing span:nth-child(2) {
    animation-delay: 120ms;
}

.chat-typing span:nth-child(3) {
    animation-delay: 240ms;
}

@keyframes typingDot {
    0%, 80%, 100% { transform: translateY(0); opacity: 0.55; }
    40% { transform: translateY(-4px); opacity: 1; }
}

.chat-input-row {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    gap: 10px;
    align-items: center;
}

.chat-input {
    width: 100%;
    min-height: 42px;
    padding: 0 12px;
}

.chat-send {
    min-width: 84px;
}

.overlay {
    position: fixed;
    inset: 0;
    z-index: 50;
    display: grid;
    place-items: center;
    padding: 24px;
    background: rgba(5, 5, 7, 0.92);
    backdrop-filter: blur(14px);
}

.overlay-shell {
    width: min(860px, 100%);
    padding: var(--space-5);
    box-shadow: var(--home-shadow-strong);
}

.overlay-header {
    margin-bottom: var(--space-5);
}

.overlay-close {
    position: absolute;
    top: 20px;
    right: 20px;
    min-height: 40px;
    padding: 0 14px;
    border-radius: var(--radius-pill);
    border: 1px solid var(--border-default);
    background: rgba(16, 16, 16, 0.88);
    color: var(--text-secondary);
}

.mic-ring {
    width: 148px;
    height: 148px;
    margin: 0 auto;
    display: grid;
    place-items: center;
    border-radius: 50%;
    border: 1px solid rgba(77, 163, 255, 0.35);
    background:
        radial-gradient(circle at 40% 30%, rgba(77, 163, 255, 0.18), transparent 56%),
        rgba(16, 16, 16, 0.9);
    color: var(--text-primary);
    font-family: var(--mono-font);
    font-size: 0.86rem;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.02);
}

.mic-ring.is-recording {
    border-color: rgba(251, 86, 91, 0.8);
    background:
        radial-gradient(circle at 40% 30%, rgba(251, 86, 91, 0.2), transparent 56%),
        rgba(16, 16, 16, 0.9);
    animation: ringPulse 1.3s ease-in-out infinite;
}

.mic-ring.is-processing {
    border-color: rgba(48, 108, 206, 0.75);
}

@keyframes ringPulse {
    0%, 100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(251, 86, 91, 0.16); }
    50% { transform: scale(1.03); box-shadow: 0 0 0 18px rgba(251, 86, 91, 0); }
}

.overlay-status {
    margin: var(--space-4) 0 0;
    color: var(--text-secondary);
    text-align: center;
}

.transcript {
    display: grid;
    gap: 10px;
    margin-top: var(--space-5);
    max-height: 260px;
    overflow: auto;
}

.bubble {
    padding: 12px 14px;
    border-radius: 14px;
    border: 1px solid var(--border-default);
    background: rgba(255, 255, 255, 0.02);
    color: var(--text-primary);
    line-height: 1.6;
}

.bubble.is-user {
    border-color: rgba(77, 163, 255, 0.45);
    background: rgba(77, 163, 255, 0.08);
}

.bubble.is-ai {
    color: rgba(208, 255, 232, 0.94);
}

.realtime-lang-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin-bottom: var(--space-4);
}

.lang-badge {
    min-height: 30px;
    padding: 0 10px;
    display: inline-flex;
    align-items: center;
    border-radius: var(--radius-pill);
    border: 1px solid var(--border-default);
    color: var(--text-secondary);
    background: rgba(255, 255, 255, 0.02);
    font-family: var(--mono-font);
    font-size: 0.76rem;
    letter-spacing: 0.08em;
}

.lang-badge--accent {
    border-color: rgba(77, 163, 255, 0.45);
    color: var(--accent-soft);
}

.lang-arrow {
    color: var(--text-tertiary);
}

.realtime-panels {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: var(--space-4);
}

.realtime-panel {
    min-height: 220px;
    padding: var(--space-4);
    border-radius: var(--radius-md);
    border: 1px solid var(--border-default);
    background: rgba(255, 255, 255, 0.02);
}

.realtime-label {
    display: block;
    margin-bottom: 8px;
    color: var(--text-tertiary);
    font-family: var(--mono-font);
    font-size: 0.74rem;
    letter-spacing: 0.18em;
    text-transform: uppercase;
}

.realtime-text {
    color: var(--text-primary);
    white-space: pre-wrap;
    line-height: 1.75;
}

.realtime-text--accent {
    color: rgba(208, 255, 232, 0.96);
}

.realtime-mic {
    display: block;
    min-width: 160px;
    margin: var(--space-5) auto 0;
}

.toast {
    position: fixed;
    right: 24px;
    bottom: 24px;
    z-index: 60;
    min-width: 220px;
    max-width: min(420px, calc(100vw - 48px));
    padding: 12px 14px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-default);
    background: rgba(16, 16, 16, 0.95);
    color: var(--text-primary);
    box-shadow: var(--home-shadow-strong);
    opacity: 0;
    transform: translateY(12px);
    pointer-events: none;
    transition: opacity 180ms ease, transform 180ms ease;
}

.toast.is-visible {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

.toast.is-success {
    border-color: rgba(77, 163, 255, 0.48);
}

.toast.is-error {
    border-color: rgba(251, 86, 91, 0.48);
}

@media (max-width: 1180px) {
    .hero,
    .workspace-grid {
        grid-template-columns: 1fr;
    }

    .workspace-main {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 900px) {
    .hero-metrics,
    .history-list,
    .realtime-panels,
    .select-stack,
    .extension-install-grid {
        grid-template-columns: 1fr;
    }

    .chat-drawer {
        right: 12px;
        bottom: 12px;
        width: calc(100vw - 24px);
    }
}

@media (max-width: 720px) {
    .shell-header__inner {
        flex-direction: column;
        align-items: stretch;
    }

    .header-status {
        justify-content: flex-start;
    }

    .status-chip {
        justify-content: center;
    }

    .overlay {
        padding: 12px;
    }

    .overlay-shell {
        padding: var(--space-4);
    }

    .realtime-panels {
        grid-template-columns: 1fr;
    }
}
