/* ── Reset & Base ── */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

:root {
    --color-bg: #0f0f1a;
    --color-surface: #1a1a2e;
    --color-primary: #6c63ff;
    --color-primary-hover: #574fd6;
    --color-text: #f0f0f5;
    --color-muted: #8888aa;
    --font: 'Inter', sans-serif;
    --radius: 16px;
}

html, body {
    height: 100%;
    font-family: var(--font);
    background-color: var(--color-bg);
    color: var(--color-text);
    -webkit-font-smoothing: antialiased;
}

/* ── Welcome Screen ── */
.welcome-screen {
    min-height: 100dvh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px 20px;
    background: radial-gradient(ellipse at 50% 0%, #2a1f6e 0%, var(--color-bg) 70%);
}

.welcome-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 16px;
    width: 100%;
    max-width: 360px;
}

/* ── Logo ── */
.logo-wrapper {
    width: 88px;
    height: 88px;
    border-radius: 24px;
    background: linear-gradient(135deg, #6c63ff, #a78bfa);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 40px;
    box-shadow: 0 8px 32px rgba(108, 99, 255, 0.4);
    margin-bottom: 8px;
}

/* ── Title ── */
.app-title {
    font-size: clamp(2rem, 8vw, 2.75rem);
    font-weight: 800;
    letter-spacing: -0.02em;
    background: linear-gradient(135deg, #fff 30%, #a78bfa);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    line-height: 1.1;
}

.app-subtitle {
    font-size: 1rem;
    color: var(--color-muted);
    font-weight: 400;
    margin-bottom: 16px;
}

/* ── Login Button ── */
.btn-login {
    display: block;
    width: 100%;
    padding: 16px 24px;
    border-radius: var(--radius);
    background: linear-gradient(135deg, #6c63ff, #a78bfa);
    color: #fff;
    font-size: 1.0625rem;
    font-weight: 700;
    text-decoration: none;
    text-align: center;
    letter-spacing: 0.01em;
    box-shadow: 0 4px 24px rgba(108, 99, 255, 0.45);
    transition: transform 0.15s ease, box-shadow 0.15s ease;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
}

.btn-login:hover,
.btn-login:focus {
    transform: translateY(-2px);
    box-shadow: 0 8px 32px rgba(108, 99, 255, 0.6);
    outline: none;
}

.btn-login:active {
    transform: translateY(0);
    box-shadow: 0 2px 12px rgba(108, 99, 255, 0.4);
}

.btn-login:disabled {
    opacity: 0.7;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.btn-login {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.btn-spinner {
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255,255,255,0.35);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
    flex-shrink: 0;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ── Desktop ── */
@media (min-width: 480px) {
    .welcome-content {
        gap: 20px;
    }

    .logo-wrapper {
        width: 100px;
        height: 100px;
        font-size: 48px;
    }
}

/* ── Inner pages ── */
.page-screen {
    min-height: 100dvh;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: 40px 20px;
    background: var(--color-bg);
}

.main-with-nav .page-screen {
    min-height: 100dvh;
}

/* ── Nav toggle button ── */
.nav-toggle {
    position: fixed;
    top: 16px;
    left: 16px;
    z-index: 200;
    width: 42px;
    height: 42px;
    border-radius: 12px;
    background: var(--color-surface);
    border: 1.5px solid rgba(255,255,255,0.08);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 5px;
    cursor: pointer;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}

.nav-toggle span {
    display: block;
    width: 18px;
    height: 2px;
    border-radius: 2px;
    background: var(--color-text);
}

/* ── Overlay ── */
.nav-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 110;
    backdrop-filter: blur(2px);
}

.nav-overlay--visible {
    display: block;
}

/* ── Sidenav ── */
.sidenav {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 240px;
    background: var(--color-surface);
    border-right: 1.5px solid rgba(255,255,255,0.06);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 24px 12px;
    z-index: 150;
    transform: translateX(-100%);
    transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.sidenav--open {
    transform: translateX(0);
}

.sidenav-top {
    display: flex;
    flex-direction: column;
    gap: 28px;
}

.sidenav-user {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 8px;
}

.sidenav-avatar {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background: linear-gradient(135deg, #6c63ff, #a78bfa);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.875rem;
    font-weight: 800;
    color: #fff;
    flex-shrink: 0;
}

.sidenav-username {
    font-size: 0.9375rem;
    font-weight: 700;
    color: var(--color-text);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.sidenav-links {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.sidenav-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: 12px;
    color: var(--color-muted);
    font-size: 0.9375rem;
    font-weight: 600;
    text-decoration: none;
    background: none;
    border: none;
    cursor: pointer;
    font-family: var(--font);
    width: 100%;
    text-align: left;
    transition: background 0.15s, color 0.15s;
    -webkit-tap-highlight-color: transparent;
}

.sidenav-link:hover {
    background: rgba(255,255,255,0.05);
    color: var(--color-text);
}

.sidenav-link--active {
    background: rgba(108, 99, 255, 0.15);
    color: #a78bfa;
}

.sidenav-link--signout {
    color: #f87171;
}

.sidenav-link--signout:hover {
    background: rgba(248, 113, 113, 0.1);
    color: #f87171;
}

.sidenav-icon {
    font-size: 1.1rem;
    flex-shrink: 0;
}

.main-with-nav {
    padding-top: 72px;
}

.main-with-nav .page-screen {
    min-height: calc(100dvh - 72px);
}

.page-content {
    width: 100%;
    max-width: 480px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.page-title {
    font-size: clamp(1.5rem, 6vw, 2rem);
    font-weight: 800;
    letter-spacing: -0.02em;
    color: var(--color-text);
}

.page-placeholder {
    color: var(--color-muted);
    font-size: 1rem;
    line-height: 1.6;
}

/* ── Word Form ── */
.word-form {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.input-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.input-label {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--color-muted);
    letter-spacing: 0.03em;
    text-transform: uppercase;
}

.input-field {
    width: 100%;
    padding: 15px 16px;
    border-radius: var(--radius);
    border: 1.5px solid rgba(255, 255, 255, 0.08);
    background: var(--color-surface);
    color: var(--color-text);
    font-family: var(--font);
    font-size: 1rem;
    outline: none;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.input-field::placeholder {
    color: var(--color-muted);
}

.input-field:focus {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(108, 99, 255, 0.2);
}

.input-field--error {
    border-color: #f87171;
    box-shadow: 0 0 0 3px rgba(248, 113, 113, 0.2);
}

.input-error {
    font-size: 0.8125rem;
    color: #f87171;
}

/* ── Success message ── */
.word-success {
    padding: 14px 16px;
    border-radius: var(--radius);
    background: rgba(52, 211, 153, 0.12);
    border: 1.5px solid rgba(52, 211, 153, 0.3);
    color: #34d399;
    font-size: 0.9375rem;
    font-weight: 600;
}

/* ── Translation card ── */
.translation-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 20px;
    border-radius: var(--radius);
    background: var(--color-surface);
    border: 1.5px solid rgba(108, 99, 255, 0.3);
}

.translation-word {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--color-text);
}

.translation-arrow {
    font-size: 1.25rem;
    color: var(--color-primary);
}

.translation-result {
    font-size: 1.125rem;
    font-weight: 600;
    color: #a78bfa;
}

/* ── Loading button ── */
.btn-login--loading {
    opacity: 0.7;
    cursor: not-allowed;
}

/* ── API Error ── */
.api-error {
    padding: 14px 16px;
    border-radius: var(--radius);
    background: rgba(248, 113, 113, 0.1);
    border: 1.5px solid rgba(248, 113, 113, 0.3);
    color: #f87171;
    font-size: 0.9375rem;
    font-weight: 600;
}

/* ── Analysis result ── */
.result-section {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.result-section-label {
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--color-muted);
}

.entries-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.entry-card {
    padding: 16px;
    border-radius: var(--radius);
    background: var(--color-surface);
    border: 1.5px solid rgba(255, 255, 255, 0.06);
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.entry-card--phrase {
    border-color: rgba(108, 99, 255, 0.35);
    background: rgba(108, 99, 255, 0.08);
}

.entry-form {
    font-size: 1.125rem;
    font-weight: 700;
    color: var(--color-text);
}

.entry-meta {
    display: flex;
    align-items: center;
    gap: 10px;
}

.entry-pos {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--color-muted);
    background: rgba(255,255,255,0.05);
    padding: 2px 8px;
    border-radius: 6px;
}

.entry-freq {
    font-size: 0.75rem;
    letter-spacing: 0.05em;
}

.entry-translation {
    font-size: 1rem;
    font-weight: 600;
    color: #a78bfa;
}

.entry-save-form {
    margin-top: 4px;
}

.btn-save {
    background: none;
    border: 1.5px solid rgba(108, 99, 255, 0.4);
    border-radius: 10px;
    color: var(--color-primary);
    font-family: var(--font);
    font-size: 0.8125rem;
    font-weight: 700;
    padding: 6px 14px;
    cursor: pointer;
    transition: background 0.15s ease, border-color 0.15s ease;
    -webkit-tap-highlight-color: transparent;
}

.btn-save:hover {
    background: rgba(108, 99, 255, 0.12);
    border-color: var(--color-primary);
}

.entry-saved {
    font-size: 0.8125rem;
    font-weight: 700;
    color: #34d399;
}

/* ── Dictionary ── */
.dict-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 4px;
}

.btn-copy {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 5px 12px;
    background: transparent;
    border: 1px solid var(--color-muted);
    border-radius: 8px;
    color: var(--color-muted);
    font-size: 0.8125rem;
    cursor: pointer;
    transition: border-color 0.15s, color 0.15s;
}

.btn-copy:hover {
    border-color: var(--color-primary);
    color: var(--color-primary);
}

.btn-copy--done {
    border-color: #4caf50;
    color: #4caf50;
}

.btn-copy-icon {
    font-size: 1rem;
    line-height: 1;
}

.dict-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.btn-clear {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    background: transparent;
    border: 1px solid var(--color-muted);
    border-radius: 8px;
    color: var(--color-muted);
    font-size: 0.9rem;
    cursor: pointer;
    transition: border-color 0.15s, color 0.15s;
}

.btn-clear:hover {
    border-color: #e53935;
    color: #e53935;
}

/* ── Confirm dialog ── */
.confirm-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.55);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 200;
}

.confirm-overlay[hidden] { display: none; }

.confirm-dialog {
    background: var(--color-surface, #1e1e2e);
    border: 1px solid var(--color-border, #333);
    border-radius: 14px;
    padding: 28px 24px 20px;
    max-width: 320px;
    width: 90%;
    text-align: center;
}

.confirm-text {
    margin: 0 0 20px;
    font-size: 1rem;
    color: var(--color-text);
}

.confirm-actions {
    display: flex;
    gap: 10px;
    justify-content: center;
}

.confirm-btn {
    flex: 1;
    padding: 9px 0;
    border-radius: 8px;
    border: none;
    font-size: 0.9375rem;
    cursor: pointer;
    transition: opacity 0.15s;
}

.confirm-btn:hover { opacity: 0.85; }

.confirm-btn--cancel {
    background: var(--color-surface-alt, #2a2a3e);
    color: var(--color-muted);
    border: 1px solid var(--color-border, #333);
}

.confirm-btn--danger {
    background: #e53935;
    color: #fff;
}

.dict-count {
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--color-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-bottom: 4px;
}

.dict-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.dict-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 16px;
    border-radius: var(--radius);
    background: var(--color-surface);
    border: 1.5px solid rgba(255,255,255,0.06);
}

.dict-label {
    font-size: 0.9375rem;
    font-weight: 500;
    color: var(--color-text);
    flex: 1;
    min-width: 0;
}

.dict-delete {
    flex-shrink: 0;
    width: 28px;
    height: 28px;
    border-radius: 8px;
    border: none;
    background: none;
    color: var(--color-muted);
    font-size: 1.125rem;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s, color 0.15s;
    -webkit-tap-highlight-color: transparent;
}

.dict-delete:hover {
    background: rgba(248, 113, 113, 0.12);
    color: #f87171;
}