/* ===== IELTS Speaking AI - Premium Voice UI ===== */

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

:root {
    --bg1: #0a0a14;
    --bg2: #0f0f1f;
    --bg3: #151528;
    --surface: rgba(255, 255, 255, 0.06);
    --surface-hover: rgba(255, 255, 255, 0.1);
    --border: rgba(255, 255, 255, 0.08);
    --border-hover: rgba(255, 255, 255, 0.15);
    --text: #f0f0f5;
    --text2: rgba(255, 255, 255, 0.6);
    --text3: rgba(255, 255, 255, 0.35);
    --accent: #7c3aed;
    --accent2: #6d28d9;
    --blue: #3b82f6;
    --cyan: #06b6d4;
    --green: #22c55e;
    --gold: #f59e0b;
    --red: #ef4444;
    --orb-idle: #7c3aed;
    --orb-listen: #3b82f6;
    --orb-think: #f59e0b;
    --orb-speak: #22c55e;
    --radius: 16px;
    --radius-sm: 10px;
}

html, body {
    height: 100%;
    background: var(--bg1);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    overflow: hidden;
    -webkit-font-smoothing: antialiased;
}

/* ===== Background ===== */

.bg {
    position: fixed;
    inset: 0;
    background: radial-gradient(ellipse at 50% 40%, rgba(124, 58, 237, 0.08) 0%, transparent 60%),
                radial-gradient(ellipse at 80% 80%, rgba(59, 130, 246, 0.05) 0%, transparent 50%),
                linear-gradient(180deg, var(--bg1) 0%, var(--bg2) 50%, var(--bg3) 100%);
    z-index: 0;
}

.bg-glow {
    position: fixed;
    width: 600px;
    height: 600px;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -60%);
    background: radial-gradient(circle, rgba(124, 58, 237, 0.06) 0%, transparent 70%);
    border-radius: 50%;
    z-index: 0;
    transition: background 0.8s ease;
}

.bg-glow.listening {
    background: radial-gradient(circle, rgba(59, 130, 246, 0.08) 0%, transparent 70%);
}
.bg-glow.thinking {
    background: radial-gradient(circle, rgba(245, 158, 11, 0.08) 0%, transparent 70%);
}
.bg-glow.speaking {
    background: radial-gradient(circle, rgba(34, 197, 94, 0.08) 0%, transparent 70%);
}

/* ===== App Layout ===== */

.app {
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    height: 100vh;
    max-width: 600px;
    margin: 0 auto;
    padding: 20px 24px;
}

/* ===== Top Bar ===== */

.top-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
    padding: 8px 0;
}

.logo {
    font-size: 15px;
    font-weight: 700;
    letter-spacing: -0.2px;
    color: var(--text2);
}

.logo span {
    color: var(--accent);
}

.top-right {
    display: flex;
    align-items: center;
    gap: 10px;
}

.status-badge {
    font-size: 12px;
    color: var(--text3);
    padding: 4px 12px;
    border-radius: 20px;
    background: var(--surface);
    border: 1px solid var(--border);
    transition: all 0.4s;
    white-space: nowrap;
}

.status-badge.idle     { color: var(--text3); border-color: var(--border); }
.status-badge.listening { color: var(--blue); border-color: rgba(59,130,246,0.3); background: rgba(59,130,246,0.08); }
.status-badge.thinking  { color: var(--gold); border-color: rgba(245,158,11,0.3); background: rgba(245,158,11,0.08); }
.status-badge.speaking  { color: var(--green); border-color: rgba(34,197,94,0.3); background: rgba(34,197,94,0.08); }

/* ===== Settings Button ===== */

.btn-gear {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text2);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.25s;
    flex-shrink: 0;
    backdrop-filter: blur(12px);
}

.btn-gear:hover {
    border-color: var(--accent);
    color: var(--text);
    background: var(--surface-hover);
    transform: rotate(30deg);
}

.btn-gear svg {
    width: 18px;
    height: 18px;
}

/* ===== Center Area ===== */

.center {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 32px;
    min-height: 0;
}

/* ===== Orb ===== */

.orb-wrap {
    position: relative;
    width: 200px;
    height: 200px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.orb {
    width: 160px;
    height: 160px;
    border-radius: 50%;
    position: relative;
    z-index: 2;
    background: radial-gradient(circle at 35% 30%, rgba(255,255,255,0.15), transparent 60%),
                radial-gradient(circle at 65% 70%, rgba(124,58,237,0.3), rgba(124,58,237,0.6) 50%, rgba(99,102,241,0.8));
    box-shadow: 0 0 60px rgba(124,58,237,0.2), 0 0 120px rgba(124,58,237,0.08), inset 0 0 40px rgba(124,58,237,0.05);
    transition: all 0.6s cubic-bezier(0.4, 0, 0.2, 1);
    animation: orbIdle 5s ease-in-out infinite;
}

/* Orb rings (for listening/speaking states) */
.orb-ring {
    position: absolute;
    inset: -20px;
    border-radius: 50%;
    border: 1.5px solid transparent;
    z-index: 1;
    opacity: 0;
    transition: opacity 0.5s;
}

.orb-ring.r1 { inset: -12px; }
.orb-ring.r2 { inset: 0; }
.orb-ring.r3 { inset: 12px; }

/* ===== Orb States ===== */

.orb-wrap.idle .orb {
    background: radial-gradient(circle at 35% 30%, rgba(255,255,255,0.12), transparent 60%),
                radial-gradient(circle at 65% 70%, rgba(124,58,237,0.25), rgba(124,58,237,0.55) 50%, rgba(99,102,241,0.7));
    box-shadow: 0 0 50px rgba(124,58,237,0.15), 0 0 100px rgba(124,58,237,0.05);
    animation: orbIdle 5s ease-in-out infinite;
}

.orb-wrap.idle .orb-ring {
    opacity: 0;
}

/* Listening */
.orb-wrap.listening .orb {
    background: radial-gradient(circle at 35% 30%, rgba(255,255,255,0.15), transparent 60%),
                radial-gradient(circle at 65% 70%, rgba(59,130,246,0.3), rgba(59,130,246,0.5) 50%, rgba(14,165,233,0.7));
    box-shadow: 0 0 60px rgba(59,130,246,0.25), 0 0 120px rgba(59,130,246,0.1);
    animation: orbListen 1.5s ease-in-out infinite;
}

.orb-wrap.listening .orb-ring {
    opacity: 1;
    animation: ringExpand 1.8s ease-out infinite;
}

.orb-wrap.listening .orb-ring.r1 { animation-delay: 0s; border-color: rgba(59,130,246,0.15); }
.orb-wrap.listening .orb-ring.r2 { animation-delay: 0.6s; border-color: rgba(59,130,246,0.1); }
.orb-wrap.listening .orb-ring.r3 { animation-delay: 1.2s; border-color: rgba(59,130,246,0.05); }

/* Thinking */
.orb-wrap.thinking .orb {
    background: radial-gradient(circle at 35% 30%, rgba(255,255,255,0.12), transparent 60%),
                radial-gradient(circle at 65% 70%, rgba(245,158,11,0.3), rgba(245,158,11,0.5) 50%, rgba(251,191,36,0.6));
    box-shadow: 0 0 60px rgba(245,158,11,0.2), 0 0 120px rgba(245,158,11,0.08);
    animation: orbThink 2s linear infinite;
}

.orb-wrap.thinking .orb-ring {
    opacity: 0;
}

/* Speaking */
.orb-wrap.speaking .orb {
    background: radial-gradient(circle at 35% 30%, rgba(255,255,255,0.15), transparent 60%),
                radial-gradient(circle at 65% 70%, rgba(34,197,94,0.3), rgba(34,197,94,0.5) 50%, rgba(16,185,129,0.7));
    box-shadow: 0 0 60px rgba(34,197,94,0.25), 0 0 120px rgba(34,197,94,0.1);
    animation: orbSpeak 0.8s ease-in-out infinite;
}

.orb-wrap.speaking .orb-ring {
    opacity: 1;
    animation: ringPulse 1.2s ease-out infinite;
}

.orb-wrap.speaking .orb-ring.r1 { animation-delay: 0s; border-color: rgba(34,197,94,0.2); }
.orb-wrap.speaking .orb-ring.r2 { animation-delay: 0.4s; border-color: rgba(34,197,94,0.12); }
.orb-wrap.speaking .orb-ring.r3 { animation-delay: 0.8s; border-color: rgba(34,197,94,0.06); }

/* ===== Orb Animations ===== */

@keyframes orbIdle {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.04); }
}

@keyframes orbListen {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.08); }
}

@keyframes orbThink {
    0% { transform: rotate(0deg) scale(1); }
    50% { transform: rotate(180deg) scale(0.97); }
    100% { transform: rotate(360deg) scale(1); }
}

@keyframes orbSpeak {
    0%, 100% { transform: scale(1); }
    25% { transform: scale(1.06) translateY(-2px); }
    75% { transform: scale(0.97) translateY(1px); }
}

@keyframes ringExpand {
    0% { transform: scale(0.85); opacity: 0.6; }
    100% { transform: scale(1.3); opacity: 0; }
}

@keyframes ringPulse {
    0%, 100% { transform: scale(1); opacity: 0.5; }
    50% { transform: scale(1.15); opacity: 0; }
}

/* ===== Status Text ===== */

.status-text {
    font-size: 14px;
    color: var(--text2);
    text-align: center;
    transition: all 0.4s;
    min-height: 20px;
}

.status-text.idle      { color: var(--text3); }
.status-text.listening { color: var(--blue); }
.status-text.thinking  { color: var(--gold); }
.status-text.speaking  { color: var(--green); }


/* ===== Bottom Bar ===== */

.bottom-bar {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px 0 24px;
    flex-shrink: 0;
}

.btn-mic {
    width: 52px;
    height: 52px;
    border-radius: 50%;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text2);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s;
    backdrop-filter: blur(12px);
}

.btn-mic:hover {
    border-color: var(--accent);
    color: var(--text);
    background: var(--surface-hover);
    transform: scale(1.05);
}

.btn-mic:active {
    transform: scale(0.92);
}

.btn-mic.recording {
    border-color: var(--red);
    color: var(--red);
    background: rgba(239,68,68,0.1);
    animation: micPulse 1.5s ease-in-out infinite;
}

@keyframes micPulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(239,68,68,0.3); }
    50% { box-shadow: 0 0 0 14px rgba(239,68,68,0); }
}

.btn-mic svg {
    width: 22px;
    height: 22px;
}

/* ===== Cue Card Overlay ===== */

.cue-overlay {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 50;
    background: rgba(0,0,0,0.5);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.cue-overlay.open {
    display: flex;
}

.cue-card {
    background: var(--bg3);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 28px 32px;
    max-width: 480px;
    width: 100%;
    box-shadow: 0 24px 80px rgba(0,0,0,0.5);
    animation: fadeUp 0.35s ease;
}

.cue-card-label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: var(--accent);
    font-weight: 700;
    margin-bottom: 12px;
}

.cue-card-topic {
    font-size: 18px;
    font-weight: 600;
    line-height: 1.4;
    margin-bottom: 16px;
}

.cue-card ul {
    list-style: none;
    padding: 0;
}

.cue-card li {
    padding: 5px 0 5px 18px;
    position: relative;
    font-size: 14px;
    color: var(--text2);
    line-height: 1.5;
}

.cue-card li::before {
    content: '';
    position: absolute;
    left: 0;
    top: 12px;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--accent);
}

/* ===== Timer Overlay ===== */

.timer-overlay {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 50;
    background: rgba(0,0,0,0.4);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.timer-overlay.open {
    display: flex;
}

.timer-box {
    text-align: center;
    animation: fadeUp 0.3s ease;
}

.timer-number {
    font-size: 96px;
    font-weight: 800;
    color: var(--text);
    font-variant-numeric: tabular-nums;
    letter-spacing: 4px;
    line-height: 1;
    text-shadow: 0 0 60px rgba(255,255,255,0.1);
}

.timer-label {
    font-size: 14px;
    color: var(--text3);
    margin-top: 12px;
    letter-spacing: 0.5px;
}

.timer-box.ended .timer-number {
    color: var(--green);
}

/* ===== Feedback Modal ===== */

.fb-overlay {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 100;
    background: rgba(0,0,0,0.6);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    align-items: center;
    justify-content: center;
    padding: 24px;
    overflow-y: auto;
}

.fb-overlay.open {
    display: flex;
}

.fb-modal {
    background: var(--bg3);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 32px;
    max-width: 500px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 32px 100px rgba(0,0,0,0.5);
    animation: fadeUp 0.35s ease;
}

.fb-modal::-webkit-scrollbar { width: 4px; }
.fb-modal::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

.fb-title {
    font-size: 20px;
    font-weight: 700;
    color: var(--accent);
    text-align: center;
    margin-bottom: 24px;
}

.fb-score-box {
    text-align: center;
    padding: 20px;
    margin-bottom: 20px;
    background: var(--surface);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
}

.fb-score-num {
    font-size: 48px;
    font-weight: 800;
    color: var(--accent);
    line-height: 1;
}

.fb-score-label {
    font-size: 13px;
    color: var(--text3);
    margin-top: 4px;
}

.fb-item {
    padding: 14px 0;
    border-bottom: 1px solid var(--border);
}
.fb-item:last-of-type {
    border-bottom: none;
}

.fb-item-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 4px;
}

.fb-item-name {
    font-size: 14px;
    font-weight: 600;
}

.fb-item-score {
    font-size: 15px;
    font-weight: 700;
    color: var(--accent);
}

.fb-item-comment {
    font-size: 13px;
    color: var(--text2);
    line-height: 1.5;
}

.fb-suggest {
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid var(--border);
}

.fb-suggest-title {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 8px;
}

.fb-suggest ul {
    list-style: none;
    padding: 0;
}

.fb-suggest li {
    font-size: 13px;
    color: var(--text2);
    padding: 4px 0 4px 18px;
    position: relative;
    line-height: 1.5;
}

.fb-suggest li::before {
    content: '→';
    position: absolute;
    left: 0;
    color: var(--accent);
}

.fb-close-btn {
    display: block;
    width: 100%;
    padding: 12px;
    margin-top: 20px;
    border: 1px solid var(--accent);
    border-radius: var(--radius-sm);
    background: var(--accent);
    color: #fff;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.25s;
}

.fb-close-btn:hover {
    background: var(--accent2);
    transform: translateY(-1px);
}

/* ===== Settings Modal ===== */

.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 200;
    background: rgba(0,0,0,0.6);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.modal-overlay.open {
    display: flex;
}

.modal {
    background: var(--bg3);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 28px 32px;
    max-width: 460px;
    width: 100%;
    max-height: 88vh;
    overflow-y: auto;
    box-shadow: 0 32px 100px rgba(0,0,0,0.5);
    animation: fadeUp 0.3s ease;
}

.modal::-webkit-scrollbar { width: 4px; }
.modal::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}

.modal-title {
    font-size: 17px;
    font-weight: 600;
}

.modal-close {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text2);
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.modal-close:hover {
    border-color: var(--text2);
    color: var(--text);
    background: var(--surface-hover);
}

.modal-section {
    margin-bottom: 22px;
}
.modal-section:last-child {
    margin-bottom: 0;
}

.modal-label {
    display: block;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--text3);
    font-weight: 700;
    margin-bottom: 10px;
}

/* ===== Select Options ===== */

.select-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.select-opt {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 12px 16px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.2s;
}

.select-opt:hover {
    border-color: var(--accent);
    background: var(--surface-hover);
}

.select-opt.active {
    border-color: var(--accent);
    background: rgba(124,58,237,0.1);
}

.select-opt-radio {
    width: 18px;
    height: 18px;
    min-width: 18px;
    border-radius: 50%;
    border: 2px solid var(--text3);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-top: 2px;
    transition: all 0.2s;
}

.select-opt.active .select-opt-radio {
    border-color: var(--accent);
}

.select-opt.active .select-opt-radio::after {
    content: '';
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--accent);
}

.select-opt-body {
    flex: 1;
    min-width: 0;
}

.select-opt-title {
    font-size: 13px;
    font-weight: 600;
}

.select-opt-desc {
    font-size: 11px;
    color: var(--text2);
    margin-top: 2px;
    line-height: 1.4;
}

.select-opt-example {
    font-size: 11px;
    color: var(--text3);
    font-style: italic;
    margin-top: 3px;
}

/* ===== Toggle Switch ===== */

.toggle-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
}

.toggle-label {
    font-size: 13px;
    font-weight: 600;
}

.toggle {
    width: 44px;
    height: 24px;
    border-radius: 12px;
    background: var(--text3);
    cursor: pointer;
    position: relative;
    transition: all 0.25s;
    border: none;
    padding: 0;
}

.toggle.on {
    background: var(--accent);
}

.toggle::after {
    content: '';
    position: absolute;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #fff;
    top: 2px;
    left: 2px;
    transition: all 0.25s;
}

.toggle.on::after {
    left: 22px;
}

/* ===== New Chat Button ===== */

.btn-new {
    width: 100%;
    padding: 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--text2);
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s;
    margin-top: 16px;
}

.btn-new:hover {
    border-color: var(--red);
    color: var(--red);
    background: rgba(239,68,68,0.06);
}

/* ===== Debug Panel ===== */

.debug-panel {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 30;
    background: var(--bg3);
    border-top: 1px solid var(--border);
    padding: 16px 24px 24px;
    max-height: 35vh;
    overflow-y: auto;
    animation: slideUp 0.3s ease;
}

.debug-panel.open {
    display: block;
}

.debug-panel::-webkit-scrollbar { width: 4px; }
.debug-panel::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

.debug-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.debug-title {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text3);
    font-weight: 700;
}

.debug-clear {
    font-size: 11px;
    color: var(--red);
    cursor: pointer;
    border: none;
    background: none;
    padding: 2px 8px;
    border-radius: 4px;
}

.debug-clear:hover {
    background: rgba(239,68,68,0.1);
}

.debug-entry {
    padding: 8px 0;
    border-bottom: 1px solid var(--border);
    font-size: 12px;
    line-height: 1.5;
}
.debug-entry:last-child {
    border-bottom: none;
}

.debug-entry .role {
    font-weight: 600;
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 2px;
}

.debug-entry .role.user { color: var(--blue); }
.debug-entry .role.ai { color: var(--green); }
.debug-entry .role.system { color: var(--gold); }

.debug-entry .text {
    color: var(--text2);
    word-wrap: break-word;
}

/* ===== Animations ===== */

@keyframes fadeUp {
    from { opacity: 0; transform: translateY(12px) scale(0.98); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes slideUp {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
}

/* ===== Responsive ===== */

@media (max-width: 520px) {
    .app {
        padding: 14px 16px;
    }
    .orb {
        width: 130px;
        height: 130px;
    }
    .orb-wrap {
        width: 170px;
        height: 170px;
    }
    .orb-ring.r1 { inset: -8px; }
    .orb-ring.r2 { inset: 4px; }
    .orb-ring.r3 { inset: 16px; }
    .timer-number {
        font-size: 64px;
    }
    .fb-score-num {
        font-size: 40px;
    }
    .modal {
        padding: 20px 24px;
    }
    .fb-modal {
        padding: 24px;
    }
    .status-text {
        font-size: 13px;
    }
}

@media (max-width: 400px) {
    .orb {
        width: 110px;
        height: 110px;
    }
    .orb-wrap {
        width: 150px;
        height: 150px;
    }
    .cue-card {
        padding: 20px 24px;
    }
}

@media (min-height: 800px) {
    .orb {
        width: 190px;
        height: 190px;
    }
    .orb-wrap {
        width: 240px;
        height: 240px;
    }
}
