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

:root {
    --bg-primary: linear-gradient(135deg, #e8eaf6 0%, #e3f2fd 30%, #f3e5f5 60%, #fce4ec 100%);
    --bg-card: rgba(255,255,255,0.72);
    --bg-card-hover: rgba(255,255,255,0.85);
    --bg-input: rgba(240,242,247,0.8);
    --border: rgba(200,210,230,0.6);
    --border-hover: rgba(160,175,200,0.7);
    --border-focus: rgba(59,130,246,0.5);
    --text-primary: #1e293b;
    --text-secondary: #475569;
    --text-muted: #94a3b8;
    --accent: #3b82f6;
    --accent-purple: #7c3aed;
    --accent-gradient: linear-gradient(135deg, #3b82f6, #6366f1);
    --glow-blue: rgba(59,130,246,0.2);
    --glow-purple: rgba(99,102,241,0.15);
    --danger: #ef4444;
    --success: #10b981;
    --sidebar-width: 220px;
    --shadow-sm: 0 2px 8px rgba(0,0,0,0.06);
    --shadow-md: 0 8px 24px rgba(0,0,0,0.1);
}

body {
    font-family: 'Inter', 'Noto Sans SC', -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
    background: linear-gradient(135deg, #e8eaf6 0%, #e3f2fd 30%, #f3e5f5 60%, #fce4ec 100%);
    background-attachment: fixed;
    color: var(--text-primary);
    min-height: 100vh;
    overflow: hidden;
    font-size: 15px;
    letter-spacing: 0.01em;
}

/* ===== Background Effects ===== */
.bg-grid {
    position: fixed;
    inset: 0;
    background-image:
        radial-gradient(ellipse 80% 50% at 50% -20%, rgba(59,130,246,0.12), transparent),
        radial-gradient(ellipse 60% 40% at 80% 100%, rgba(139,92,246,0.1), transparent),
        radial-gradient(ellipse 50% 50% at 10% 60%, rgba(236,72,153,0.06), transparent);
    z-index: 0;
    pointer-events: none;
}
.bg-orb { display: none; }

/* ===== Particles Canvas ===== */
.particles-canvas {
    position: fixed;
    inset: 0;
    z-index: 0;
    pointer-events: none;
}

/* ===== Sidebar ===== */
.sidebar {
    position: fixed;
    left: 0; top: 0; bottom: 0;
    width: var(--sidebar-width);
    background: rgba(255,255,255,0.75);
    backdrop-filter: blur(16px);
    border-right: 1px solid rgba(200,210,230,0.4);
    display: flex;
    flex-direction: column;
    z-index: 100;
    padding: 20px 12px;
    box-shadow: 2px 0 16px rgba(99,102,241,0.06);
    transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1), padding 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    overflow: hidden;
}
.sidebar.collapsed {
    width: 64px;
    padding: 20px 8px;
}
.sidebar.collapsed .logo-text,
.sidebar.collapsed .nav-item span,
.sidebar.collapsed .user-name,
.sidebar.collapsed .sidebar-bottom .nav-item span {
    opacity: 0;
    width: 0;
    overflow: hidden;
    white-space: nowrap;
    transition: opacity 0.2s;
}
.sidebar.collapsed .sidebar-logo {
    padding: 4px 8px 24px;
    justify-content: center;
}
.sidebar.collapsed .nav-item {
    justify-content: center;
    padding: 11px 0;
    gap: 0;
}
.sidebar.collapsed .user-info {
    justify-content: center;
    padding: 8px 0;
    gap: 0;
}
.sidebar.collapsed .logout-btn {
    display: none;
}

.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 4px 12px 24px;
}
.logo-icon {
    width: 40px; height: 40px;
    background: var(--accent-gradient);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    flex-shrink: 0;
}
.logo-text {
    font-size: 18px;
    font-weight: 700;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    letter-spacing: 0.03em;
}

.sidebar-nav {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 14px;
    border-radius: 10px;
    border: none;
    background: none;
    color: var(--text-secondary);
    font-size: 15px;
    cursor: pointer;
    transition: all 0.2s;
    width: 100%;
    text-align: left;
}
.nav-item:hover {
    background: rgba(99,102,241,0.08);
    color: var(--text-primary);
}
.nav-item.active {
    background: rgba(99,102,241,0.12);
    color: var(--accent);
    font-weight: 600;
}
.nav-item.active svg {
    stroke: var(--accent);
}
.nav-item svg {
    flex-shrink: 0;
}
.nav-item span {
    transition: opacity 0.2s;
}

.sidebar-bottom {
    border-top: 1px solid var(--border);
    padding-top: 12px;
    margin-top: 8px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 14px;
}
.user-avatar {
    width: 32px; height: 32px;
    border-radius: 8px;
    background: var(--accent-gradient);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 600;
    color: #fff;
    flex-shrink: 0;
}
.user-name {
    flex: 1;
    font-size: 13px;
    color: var(--text-secondary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.logout-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px;
    border-radius: 6px;
    transition: all 0.2s;
    display: flex;
}
.logout-btn:hover {
    color: var(--danger);
    background: rgba(239,68,68,0.08);
}

/* ===== Main Wrapper ===== */
.main-wrapper {
    margin-left: var(--sidebar-width);
    height: 100vh;
    display: flex;
    flex-direction: column;
    position: relative;
    z-index: 1;
    transition: margin-left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}
.main-wrapper.sidebar-collapsed {
    margin-left: 64px;
}

/* ===== Top Bar ===== */
.top-bar {
    padding: 16px 28px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid rgba(200,210,230,0.4);
    background: rgba(255,255,255,0.6);
    backdrop-filter: blur(12px);
    flex-shrink: 0;
}
.page-title {
    font-size: 20px;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: 0.02em;
}
.top-bar-left {
    display: flex;
    align-items: center;
    gap: 12px;
}
.sidebar-toggle {
    width: 36px;
    height: 36px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--bg-card);
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.25s;
    flex-shrink: 0;
}
.sidebar-toggle:hover {
    border-color: var(--accent);
    color: var(--accent);
    background: #eef2ff;
    box-shadow: 0 0 12px var(--glow-blue);
}
.config-status {
    font-size: 13px;
    padding: 5px 12px;
    border-radius: 20px;
    background: rgba(16,185,129,0.08);
    color: var(--success);
    border: 1px solid rgba(16,185,129,0.2);
}
.config-status.warning {
    background: rgba(245,158,11,0.08);
    color: #d97706;
    border-color: rgba(245,158,11,0.2);
}

/* ===== Main Content ===== */
.main-content {
    flex: 1;
    padding: 24px 28px;
    overflow-y: auto;
    overflow-x: hidden;
}
.main-content::-webkit-scrollbar { width: 6px; }
.main-content::-webkit-scrollbar-track { background: transparent; }
.main-content::-webkit-scrollbar-thumb { background: rgba(0,0,0,0.08); border-radius: 3px; }

.tab-panel { display: none; height: 100%; position: relative; }
.tab-panel.active { display: flex; flex-direction: column; }

/* ===== Glass Card ===== */
.glass-card {
    background: var(--bg-card);
    backdrop-filter: blur(12px);
    border: 1px solid rgba(255,255,255,0.5);
    border-radius: 16px;
    padding: 24px;
    box-shadow: var(--shadow-sm), inset 0 1px 0 rgba(255,255,255,0.6);
    transition: border-color 0.3s, box-shadow 0.3s;
}
.glass-card:hover {
    border-color: rgba(99,102,241,0.3);
    box-shadow: var(--shadow-md), inset 0 1px 0 rgba(255,255,255,0.6);
    background: var(--bg-card-hover);
}

.card-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 16px;
    color: var(--text-primary);
}
.card-header svg { color: var(--accent); stroke: var(--accent); }
.card-header h3 { font-size: 17px; font-weight: 700; letter-spacing: 0.02em; }
.card-desc { color: var(--text-muted); font-size: 14px; margin-bottom: 16px; }

/* ===== Buttons ===== */
.btn {
    padding: 10px 20px;
    border: none;
    border-radius: 10px;
    font-size: 15px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.25s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}
.btn-primary {
    background: var(--accent-gradient);
    color: #fff;
}
.btn-primary:hover {
    box-shadow: 0 4px 16px var(--glow-blue);
    transform: translateY(-1px);
}
.btn-primary:active { transform: translateY(0); }
.btn-primary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}
.btn-ghost {
    background: #f0f4ff;
    color: var(--accent);
    border: 1px solid #dbe4ff;
}
.btn-ghost:hover {
    background: #e0e7ff;
    border-color: #c7d2fe;
}
.btn-block { width: 100%; }
.btn-send {
    width: 44px; height: 44px;
    padding: 0;
    border-radius: 12px;
    flex-shrink: 0;
}
.btn-circle {
    width: 44px; height: 44px;
    border-radius: 50%;
    border: 1px solid var(--border);
    background: #fff;
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.25s;
}
.btn-circle:hover {
    border-color: var(--accent);
    color: var(--accent);
    box-shadow: 0 0 12px var(--glow-blue);
}

/* ===== PLACEHOLDER_CHAT ===== */

/* ===== Chat (Spark) ===== */
.spark-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}
.spark-model-select {
    display: flex;
    align-items: center;
    gap: 8px;
}
.spark-model-select label {
    font-size: 13px;
    color: var(--text-muted);
}

select {
    padding: 8px 12px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 14px;
    cursor: pointer;
    outline: none;
    transition: border-color 0.2s;
}
select:focus { border-color: var(--border-focus); }
select option { background: #fff; }

.chat-area {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 16px;
    background: var(--bg-input);
}
.chat-area::-webkit-scrollbar { width: 5px; }
.chat-area::-webkit-scrollbar-thumb { background: rgba(0,0,0,0.08); border-radius: 3px; }

.chat-welcome {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    min-height: 300px;
    color: var(--text-muted);
    text-align: center;
}
.welcome-icon {
    width: 80px; height: 80px;
    border-radius: 20px;
    background: #eef2ff;
    border: 1px solid #dbe4ff;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 20px;
    color: var(--accent);
}
.chat-welcome h3 {
    font-size: 18px;
    color: var(--text-secondary);
    margin-bottom: 8px;
}
.chat-welcome p {
    font-size: 14px;
    color: var(--text-muted);
}

.chat-message {
    margin-bottom: 20px;
    display: flex;
    gap: 12px;
}
.chat-message.user { flex-direction: row-reverse; }
.chat-avatar {
    width: 34px; height: 34px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 700;
    flex-shrink: 0;
}
.chat-message.user .chat-avatar {
    background: var(--accent-gradient);
    color: #fff;
}
.chat-message.assistant .chat-avatar {
    background: #f0ecff;
    color: var(--accent-purple);
    border: 1px solid #e0d8ff;
}
.chat-bubble {
    max-width: 75%;
    padding: 14px 18px;
    border-radius: 14px;
    font-size: 15px;
    line-height: 1.7;
    word-break: break-word;
}
.chat-message.user .chat-bubble {
    background: rgba(238,242,255,0.85);
    border: 1px solid rgba(199,210,254,0.6);
    color: var(--text-primary);
    border-top-right-radius: 4px;
}
.chat-message.assistant .chat-bubble {
    background: rgba(255,255,255,0.8);
    border: 1px solid rgba(200,210,230,0.5);
    color: var(--text-primary);
    border-top-left-radius: 4px;
}
.chat-bubble pre {
    background: #f8fafc;
    border: 1px solid var(--border);
    padding: 14px;
    border-radius: 8px;
    overflow-x: auto;
    margin: 10px 0;
}
.chat-bubble code {
    font-family: "Fira Code", "Consolas", monospace;
    font-size: 13px;
}
.chat-bubble p { margin: 6px 0; }
.chat-bubble p:first-child { margin-top: 0; }
.chat-bubble p:last-child { margin-bottom: 0; }

.usage-info {
    font-size: 12px;
    color: var(--text-muted);
    text-align: right;
    padding: 0 4px 8px;
}

.chat-input-area {
    display: flex;
    gap: 10px;
    align-items: flex-end;
}
.chat-input-area textarea {
    flex: 1;
    padding: 12px 16px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 12px;
    color: var(--text-primary);
    font-size: 15px;
    font-family: inherit;
    resize: none;
    line-height: 1.5;
    outline: none;
    transition: border-color 0.2s;
    max-height: 120px;
}
.chat-input-area textarea:focus {
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3px rgba(59,130,246,0.08);
}
.chat-input-area textarea::placeholder { color: var(--text-muted); }

/* ===== PLACEHOLDER_REST ===== */

/* ===== Panel Grid ===== */
.panel-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    height: 100%;
}

/* ===== Speech ===== */
.speech-record-area {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    margin: 24px 0;
}
.record-btn-wrap {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}
.record-btn {
    width: 72px; height: 72px;
    border-radius: 50%;
    border: 2px solid #c7d2fe;
    background: #eef2ff;
    color: var(--accent);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s;
    position: relative;
    z-index: 2;
}
.record-btn:hover {
    border-color: var(--accent);
    box-shadow: 0 0 20px var(--glow-blue);
    background: #dbeafe;
}
.record-btn.recording {
    border-color: var(--danger);
    background: #fef2f2;
    color: var(--danger);
}
.ripple-ring {
    position: absolute;
    width: 72px; height: 72px;
    border-radius: 50%;
    border: 2px solid rgba(239,68,68,0.3);
    opacity: 0;
    pointer-events: none;
    z-index: 1;
}
.record-btn-wrap.active .ripple-ring,
.record-btn-wrap:has(.recording) .ripple-ring {
    animation: ripple-expand 2s ease-out infinite;
    opacity: 1;
}
.ripple-ring.delay-1 { animation-delay: 0.5s; }
.ripple-ring.delay-2 { animation-delay: 1s; }
@keyframes ripple-expand {
    0% { transform: scale(1); opacity: 0.6; }
    100% { transform: scale(2.2); opacity: 0; }
}
.status-label {
    font-size: 13px;
    color: var(--text-muted);
}

/* ===== Waveform Canvas ===== */
.waveform-canvas {
    width: 100%;
    max-width: 400px;
    height: 60px;
    border-radius: 8px;
    background: var(--bg-input);
    border: 1px solid var(--border);
}

/* ===== Sub-Tabs ===== */
.sub-tabs {
    display: flex;
    gap: 4px;
    padding: 4px;
    background: var(--bg-input);
    border-radius: 12px;
    margin-bottom: 20px;
    border: 1px solid var(--border);
    flex-shrink: 0;
}
.sub-tab {
    flex: 1;
    padding: 10px 16px;
    border: none;
    border-radius: 10px;
    background: none;
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s;
    white-space: nowrap;
}
.sub-tab:hover {
    color: var(--text-primary);
    background: rgba(59,130,246,0.06);
}
.sub-tab.active {
    background: var(--accent-gradient);
    color: #fff;
    box-shadow: 0 2px 8px var(--glow-blue);
}
.sub-panel {
    display: none;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    animation: subtab-fade 0.3s ease;
}
.sub-panel.active {
    display: flex;
}
@keyframes subtab-fade {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ===== PLACEHOLDER_CONTROLS ===== */

/* ===== Control Row ===== */
.control-row {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 12px;
    align-items: flex-end;
}
.control-item {
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.control-item label {
    font-size: 12px;
    color: var(--text-muted);
}
.control-item label span {
    color: var(--accent);
    font-weight: 600;
}
.input-field {
    padding: 8px 12px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s;
    width: 160px;
}
.input-field:focus {
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3px rgba(59,130,246,0.08);
}
.input-field::placeholder { color: var(--text-muted); }
.checkbox-group {
    display: flex;
    flex-wrap: wrap;
    gap: 4px 16px;
}
.checkbox-label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 4px 0;
}
.checkbox-label input[type="checkbox"] {
    accent-color: var(--accent);
}
input[type="range"] {
    width: 120px;
    accent-color: var(--accent);
    background: transparent;
}

/* ===== TTS Controls ===== */
.tts-controls {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    margin-bottom: 16px;
}

/* ===== Input Area ===== */
.input-area {
    width: 100%;
    padding: 14px 16px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 10px;
    color: var(--text-primary);
    font-size: 15px;
    font-family: inherit;
    resize: vertical;
    outline: none;
    transition: border-color 0.2s;
    margin-bottom: 16px;
}
.input-area:focus {
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3px rgba(59,130,246,0.08);
}
.input-area::placeholder { color: var(--text-muted); }

/* ===== Result Box ===== */
.result-box {
    min-height: 100px;
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 16px;
    background: var(--bg-input);
    font-size: 15px;
    line-height: 1.8;
    white-space: pre-wrap;
    word-break: break-word;
    color: var(--text-primary);
}
.result-box:empty::before {
    content: attr(placeholder);
    color: var(--text-muted);
}
.result-box-large {
    min-height: 200px;
    flex: none;
}

/* ===== Progress Bar ===== */
.progress-wrap {
    margin: 16px 0;
}
.progress-bar {
    height: 6px;
    background: #e2e8f0;
    border-radius: 3px;
    overflow: hidden;
    margin-bottom: 8px;
}
.progress-fill {
    height: 100%;
    width: 0%;
    background: var(--accent-gradient);
    border-radius: 3px;
    transition: width 0.4s ease;
    position: relative;
}
.progress-fill::after {
    content: '';
    position: absolute;
    right: 0; top: 0; bottom: 0;
    width: 30px;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.5));
    animation: progress-shimmer 1.5s infinite;
}
@keyframes progress-shimmer {
    0% { opacity: 0; }
    50% { opacity: 1; }
    100% { opacity: 0; }
}
.progress-text {
    font-size: 12px;
    color: var(--text-muted);
}

/* ===== PLACEHOLDER_FINAL ===== */

/* ===== Score Dashboard ===== */
.score-dashboard {
    display: flex;
    align-items: center;
    gap: 24px;
    padding: 20px;
    margin: 16px 0;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 12px;
    flex-wrap: wrap;
    justify-content: center;
}
.score-gauge-wrap { flex-shrink: 0; }
.score-gauge { width: 120px; height: 120px; }
.gauge-bg { fill: none; stroke: #e2e8f0; stroke-width: 8; }
.gauge-fill {
    fill: none;
    stroke: var(--accent);
    stroke-width: 8;
    stroke-linecap: round;
    stroke-dasharray: 326.73;
    stroke-dashoffset: 326.73;
    transform: rotate(-90deg);
    transform-origin: center;
    transition: stroke-dashoffset 1.2s cubic-bezier(0.4, 0, 0.2, 1);
}
.gauge-text {
    fill: var(--text-primary);
    font-size: 28px;
    font-weight: 700;
    text-anchor: middle;
    dominant-baseline: middle;
}
.gauge-label {
    fill: var(--text-muted);
    font-size: 11px;
    text-anchor: middle;
}
.score-details { display: flex; flex-wrap: wrap; gap: 12px; }
.score-item { display: flex; flex-direction: column; align-items: center; gap: 4px; min-width: 60px; }
.score-item .score-val { font-size: 20px; font-weight: 600; color: var(--accent); }
.score-item .score-name { font-size: 11px; color: var(--text-muted); }

/* ===== OCR ===== */
.dropzone {
    border: 2px dashed #c7d2fe;
    border-radius: 14px;
    padding: 48px 24px;
    text-align: center;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.3s;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    background: #fafbff;
}
.dropzone:hover, .dropzone.dragover {
    border-color: var(--accent);
    background: #eef2ff;
    color: var(--accent);
}
.dropzone svg { stroke: currentColor; }
.dropzone p { font-size: 14px; margin: 0; }
.dropzone span { font-size: 12px; opacity: 0.6; }

.image-preview {
    max-width: 100%;
    max-height: 250px;
    border-radius: 10px;
    margin: 12px 0;
    border: 1px solid var(--border);
    cursor: pointer;
}

/* ===== Translate ===== */
.translate-layout {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    gap: 16px;
    align-items: start;
}
.translate-side select { width: 100%; margin-bottom: 12px; }
.translate-side textarea { margin-bottom: 0; }
.translate-actions {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    padding-top: 44px;
}

/* ===== Modal ===== */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.3);
    backdrop-filter: blur(4px);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fade-in 0.2s;
}
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
.modal {
    width: 480px;
    max-width: 90vw;
    animation: slide-up 0.3s;
}
@keyframes slide-up {
    from { transform: translateY(20px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}
.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}
.modal-header h3 { font-size: 18px; color: var(--text-primary); }
.modal-close {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 24px;
    cursor: pointer;
    padding: 0 4px;
    line-height: 1;
}
.modal-close:hover { color: var(--text-primary); }
.modal-desc {
    color: var(--text-secondary);
    font-size: 13px;
    margin-bottom: 20px;
    line-height: 1.6;
}
.modal-body .form-group { margin-bottom: 16px; }
.modal-body .form-group label {
    display: block;
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 6px;
    font-weight: 500;
}
.modal-body .form-group input {
    width: 100%;
    padding: 10px 14px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s;
}
.modal-body .form-group input:focus {
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3px rgba(59,130,246,0.08);
}
.modal-body .form-group input::placeholder { color: var(--text-muted); }
.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 24px;
}

/* ===== Toast ===== */
.toast {
    position: fixed;
    top: 20px;
    right: 20px;
    padding: 12px 20px;
    background: #fff;
    border: 1px solid var(--border);
    box-shadow: var(--shadow-md);
    color: var(--text-primary);
    border-radius: 10px;
    font-size: 14px;
    z-index: 2000;
    opacity: 0;
    transform: translateY(-10px);
    transition: all 0.3s;
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast.error { border-color: rgba(239,68,68,0.3); color: var(--danger); }
.toast.success { border-color: rgba(16,185,129,0.3); color: var(--success); }

/* ===== Error Detail Card ===== */
.error-detail {
    background: rgba(239,68,68,0.04);
    border: 1px solid rgba(239,68,68,0.2);
    border-radius: 10px;
    padding: 16px;
    font-size: 14px;
    line-height: 1.6;
}
.error-detail .error-title {
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 4px;
    margin-top: 12px;
}
.error-detail .error-title:first-child {
    margin-top: 0;
}
.error-detail .error-reason {
    color: var(--danger);
}
.error-detail .error-solution {
    color: var(--text-primary);
}

/* ===== Copy Button ===== */
.copy-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: rgba(255,255,255,0.7);
    color: var(--text-muted);
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}
.copy-btn:hover {
    border-color: var(--accent);
    color: var(--accent);
    background: rgba(59,130,246,0.06);
}
.copy-btn.copied {
    border-color: var(--success);
    color: var(--success);
}
/* ===== OCR Layout View ===== */
.ocr-view-tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 12px;
    background: var(--bg-input);
    border-radius: 8px;
    padding: 3px;
    width: fit-content;
}
.ocr-view-tab {
    padding: 5px 16px;
    border: none;
    background: transparent;
    color: var(--text-muted);
    font-size: 13px;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
}
.ocr-view-tab.active {
    background: var(--accent);
    color: #fff;
}
.ocr-layout-wrap {
    border: 1px solid var(--border);
    border-radius: 10px;
    background: #fff;
    overflow: auto;
    min-height: 200px;
    max-height: 600px;
    padding: 12px;
}
.ocr-layout-container {
    position: relative;
    transform-origin: top left;
}
.ocr-layout-container .ocr-line {
    position: absolute;
    white-space: nowrap;
    color: #1a1a1a;
    line-height: 1;
}

.result-box-wrap {
    position: relative;
}
.result-box-wrap .copy-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    z-index: 2;
    opacity: 0;
    transition: opacity 0.2s, border-color 0.2s, color 0.2s;
}
.result-box-wrap:hover .copy-btn,
.result-box-wrap .copy-btn.copied {
    opacity: 1;
}
.history-item .copy-btn {
    float: right;
    margin-top: -2px;
}

/* ===== Loading ===== */
.loading {
    display: inline-block;
    width: 16px; height: 16px;
    border: 2px solid #e2e8f0;
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ===== Audio ===== */
audio {
    border-radius: 8px;
    width: 100%;
}

/* ===== Input Mode Tabs (mic / file toggle) ===== */
.input-mode-tabs {
    display: inline-flex;
    gap: 2px;
    padding: 3px;
    background: var(--bg-input);
    border-radius: 10px;
    border: 1px solid var(--border);
}
.mode-tab {
    padding: 6px 18px;
    border: none;
    border-radius: 8px;
    background: none;
    color: var(--text-secondary);
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.25s;
}
.mode-tab:hover {
    color: var(--text-primary);
    background: rgba(59,130,246,0.06);
}
.mode-tab.active {
    background: var(--accent);
    color: #fff;
    box-shadow: 0 1px 4px var(--glow-blue);
}

.dictation-dropzone {
    padding: 32px 24px;
}
.dictation-dropzone .file-progress {
    width: 100%;
    max-width: 300px;
    height: 4px;
    background: var(--border);
    border-radius: 2px;
    overflow: hidden;
    margin-top: 8px;
}
.dictation-dropzone .file-progress-fill {
    height: 100%;
    width: 0%;
    background: var(--accent-gradient);
    border-radius: 2px;
    transition: width 0.3s;
}

/* ===== Responsive ===== */
@media (max-width: 900px) {
    .panel-grid { grid-template-columns: 1fr; }
    .translate-layout { grid-template-columns: 1fr; }
    .translate-actions { flex-direction: row; padding-top: 0; }
}

/* ===== Admin Table ===== */
.admin-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}
.admin-table th,
.admin-table td {
    padding: 10px 12px;
    text-align: left;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}
.admin-table th {
    color: var(--text-muted);
    font-weight: 500;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.admin-table td {
    color: var(--text-primary);
}
.admin-table .perm-tag {
    display: inline-block;
    padding: 2px 8px;
    margin: 2px;
    border-radius: 4px;
    font-size: 11px;
    cursor: pointer;
    border: 1px solid var(--border);
    color: var(--text-muted);
    background: transparent;
    transition: all 0.2s;
}
.admin-table .perm-tag.active {
    background: rgba(59,130,246,0.15);
    color: var(--accent);
    border-color: var(--accent);
}
.admin-table .perm-tag:hover {
    border-color: var(--accent);
}
.admin-table .btn-delete-user {
    padding: 4px 12px;
    border: 1px solid var(--danger);
    border-radius: 6px;
    background: transparent;
    color: var(--danger);
    cursor: pointer;
    font-size: 12px;
    transition: all 0.2s;
}
.admin-table .btn-delete-user:hover {
    background: var(--danger);
    color: #fff;
}
.admin-table .role-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 500;
}
.admin-table .role-admin {
    background: rgba(139,92,246,0.15);
    color: #a78bfa;
}
.admin-table .role-user {
    background: rgba(59,130,246,0.1);
    color: #60a5fa;
}

/* ===== Top Bar Right ===== */
.top-bar-right {
    display: flex;
    align-items: center;
    gap: 10px;
}

/* ===== Log ID Tag (unified, in top bar) ===== */
.log-id-tag {
    font-size: 12px;
    font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
    font-weight: 500;
    color: var(--accent-purple);
    background: rgba(124,58,237,0.06);
    padding: 4px 10px;
    border-radius: 6px;
    border: 1px solid rgba(124,58,237,0.15);
    user-select: all;
    letter-spacing: 0.03em;
    white-space: nowrap;
    max-width: 320px;
    overflow: hidden;
    text-overflow: ellipsis;
    transition: opacity 0.3s;
}
.log-id-tag:empty {
    display: none;
}

/* ===== Hover Micro-Interactions ===== */
.glass-card {
    transition: border-color 0.3s, box-shadow 0.3s, transform 0.3s;
}
.glass-card:hover {
    transform: translateY(-2px);
}
.btn-primary {
    position: relative;
    overflow: hidden;
}
.btn-primary::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(120deg, transparent 30%, rgba(255,255,255,0.2) 50%, transparent 70%);
    transform: translateX(-100%);
    transition: transform 0.6s;
}
.btn-primary:hover::after {
    transform: translateX(100%);
}
.nav-item {
    position: relative;
    overflow: hidden;
}
.nav-item::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%) scaleY(0);
    width: 3px;
    height: 60%;
    background: var(--accent-gradient);
    border-radius: 0 3px 3px 0;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}
.nav-item.active::before {
    transform: translateY(-50%) scaleY(1);
}
.record-btn {
    transition: all 0.3s, box-shadow 0.3s;
}
.record-btn:hover {
    transform: scale(1.05);
}
.sub-tab {
    position: relative;
    overflow: hidden;
}
.sub-tab::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 50%;
    width: 0;
    height: 2px;
    background: var(--accent);
    transition: width 0.3s, left 0.3s;
}
.sub-tab:hover::after {
    width: 80%;
    left: 10%;
}
.sub-tab.active::after {
    display: none;
}

/* ===== Fade-in Animation for Tab Panels ===== */
.tab-panel.active {
    animation: tab-enter 0.4s ease-out;
}
@keyframes tab-enter {
    from { opacity: 0; transform: translateY(12px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ===== Floating animation for logo ===== */
.logo-icon {
    animation: logo-float 3s ease-in-out infinite;
}
@keyframes logo-float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-3px); }
}

/* ===== History Panel ===== */
.history-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.3);
    backdrop-filter: blur(4px);
    z-index: 1000;
    display: flex;
    justify-content: flex-end;
}
.history-drawer {
    width: 520px;
    max-width: 90vw;
    height: 100vh;
    border-radius: 0;
    display: flex;
    flex-direction: column;
    animation: drawer-in 0.25s ease-out;
}
@keyframes drawer-in {
    from { transform: translateX(100%); }
    to { transform: translateX(0); }
}
.history-content {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
}
.history-item {
    padding: 12px;
    border-bottom: 1px solid var(--border);
    transition: background 0.15s;
}
.history-item:hover {
    background: rgba(59,130,246,0.04);
}
.history-time {
    font-size: 12px;
    color: var(--text-muted);
    margin-bottom: 4px;
}
.history-label {
    font-size: 13px;
    color: var(--accent);
    font-weight: 500;
    margin-bottom: 4px;
}
.history-text {
    font-size: 14px;
    color: var(--text-primary);
    line-height: 1.5;
    word-break: break-all;
}
.history-sid {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 4px;
    font-family: 'SF Mono', 'Consolas', monospace;
}
.history-pager {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 12px;
    border-top: 1px solid var(--border);
}
.btn-sm {
    font-size: 12px;
    padding: 4px 10px;
}

/* CBB Config Bar */
.cbb-config-bar {
    padding: 14px 16px;
    margin-bottom: 12px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 10px;
}
.cbb-config-bar input[readonly] {
    opacity: 0.6;
    cursor: default;
}
.cbb-formatted-view {
    padding: 14px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 13px;
    line-height: 1.7;
    min-height: 60px;
    overflow-x: auto;
}
.cbb-kv-list {
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.cbb-kv-row {
    display: flex;
    gap: 12px;
    padding: 3px 0;
    border-bottom: 1px solid rgba(0,0,0,0.04);
}
.cbb-kv-key {
    color: var(--text-muted);
    min-width: 140px;
    font-weight: 500;
    flex-shrink: 0;
}
.cbb-kv-val {
    color: var(--text-primary);
    word-break: break-all;
}
.cbb-kv-group {
    margin: 6px 0;
    padding-left: 12px;
    border-left: 2px solid var(--border);
}
