:root {
    --bg: #f3f4f6;
    --panel-bg: #ffffff;
    --accent: #2563eb;
    --accent-dark: #1d4ed8;
    --text: #1f2937;
    --muted: #6b7280;
    --border: #e5e7eb;
    --pos-noun: #2563eb;
    --pos-verb: #ea580c;
    --pos-adjective: #9333ea;
    --pos-adverb: #059669;
    --pos-connector: #0ea5e9;
    --pos-other: #94a3b8;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: radial-gradient(circle at 10% 20%, rgba(219,234,254,0.8) 0%, rgba(243,244,246,1) 40%, rgba(248,250,252,1) 100%);
    color: var(--text);
    min-height: 100vh;
}

.site-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem 2rem;
}

.site-header .branding {
    display: flex;
    gap: 1.5rem;
    align-items: center;
}

.site-header .logo {
    font-weight: 700;
    font-size: 1.4rem;
    padding: 0.6rem 1.2rem;
    border-radius: 12px;
    background: #0f172a;
    color: #fff;
}

.site-header nav a {
    color: var(--accent-dark);
    text-decoration: none;
    font-weight: 600;
}

.workspace {
    display: grid;
    grid-template-columns: 1.2fr 1fr;
    gap: 1.5rem;
    padding: 0 2rem 2rem;
}

.panel {
    background: var(--panel-bg);
    border-radius: 18px;
    box-shadow: 0 20px 45px rgba(15, 23, 42, 0.12);
    padding: 1.5rem;
    position: relative;
}

.panel-header h2 {
    margin: 0 0 0.5rem;
}

.panel-header p {
    margin: 0;
    color: var(--muted);
}

#essayInput {
    width: 100%;
    min-height: 180px;
    border-radius: 14px;
    border: 1px solid var(--border);
    padding: 1rem;
    font-size: 1rem;
    resize: vertical;
    margin: 1.2rem 0;
    background: #f9fafb;
}

.controls {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
}

button.primary, .controls button {
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: 12px;
    padding: 0.75rem 1.5rem;
    font-size: 1rem;
    cursor: pointer;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

button.primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 10px 25px rgba(37, 99, 235, 0.25);
}

label.upload {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 0.6rem;
    background: rgba(37, 99, 235, 0.12);
    color: var(--accent-dark);
    padding: 0.75rem 1.25rem;
    border-radius: 12px;
    font-weight: 600;
    cursor: pointer;
}

label.upload input {
    display: none;
}

.status {
    color: var(--muted);
    font-size: 0.9rem;
    min-height: 1.2rem;
}

.original-wrapper {
    margin-top: 1.5rem;
    background: linear-gradient(145deg, rgba(236, 233, 254, 0.7), rgba(219, 234, 254, 0.4));
    padding: 1.2rem;
    border-radius: 16px;
}

.original-wrapper header {
    margin-bottom: 0.75rem;
}

.original-text {
    background: rgba(255, 255, 255, 0.85);
    border-radius: 12px;
    padding: 1rem;
    min-height: 140px;
    line-height: 1.7;
    font-size: 1.05rem;
    border: 1px dashed rgba(148, 163, 184, 0.5);
}

.word-token {
    cursor: pointer;
    padding: 0 0.15rem;
    border-radius: 6px;
    transition: background 0.15s ease, transform 0.15s ease;
}

.word-token:hover {
    transform: scale(1.05);
}

.word-token.pos-noun { background: rgba(37, 99, 235, 0.18); color: #1d4ed8; }
.word-token.pos-verb { background: rgba(234, 88, 12, 0.18); color: #b45309; }
.word-token.pos-adjective { background: rgba(147, 51, 234, 0.18); color: #7e22ce; }
.word-token.pos-adverb { background: rgba(5, 150, 105, 0.18); color: #047857; }
.word-token.pos-connector { background: rgba(14, 165, 233, 0.18); color: #0ea5e9; }
.word-token.pos-other { background: rgba(148, 163, 184, 0.18); color: #475569; }

.tab-bar {
    display: flex;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.tab {
    flex: 1;
    padding: 0.75rem 1rem;
    border-radius: 12px;
    border: 1px solid transparent;
    background: rgba(15, 23, 42, 0.06);
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s ease, border-color 0.15s ease;
}

.tab.active {
    background: rgba(37, 99, 235, 0.12);
    border-color: rgba(37, 99, 235, 0.3);
    color: var(--accent-dark);
}

.analysis-section {
    display: none;
}

.analysis-section.active {
    display: block;
}

.list .card {
    background: rgba(248, 250, 252, 0.75);
    border-radius: 14px;
    padding: 1rem;
    border: 1px solid rgba(148, 163, 184, 0.2);
    margin-bottom: 0.8rem;
}

.list .card h4 {
    margin: 0 0 0.5rem;
}

.badge {
    display: inline-block;
    padding: 0.2rem 0.6rem;
    border-radius: 999px;
    background: rgba(15, 23, 42, 0.08);
    font-size: 0.75rem;
    margin-right: 0.5rem;
}

.keyword-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 0.75rem;
}

.keyword-grid .keyword {
    background: rgba(219, 234, 254, 0.6);
    border: 1px solid rgba(148, 163, 184, 0.2);
    border-radius: 14px;
    padding: 0.75rem;
    cursor: pointer;
    transition: transform 0.15s ease;
}

.keyword-grid .keyword:hover {
    transform: translateY(-2px);
}

.feedback-grid {
    display: grid;
    gap: 1rem;
}

.feedback-card {
    background: rgba(248, 250, 252, 0.9);
    border-radius: 14px;
    padding: 1rem;
    border: 1px solid rgba(148, 163, 184, 0.25);
}

.word-inspector {
    position: fixed;
    top: 2.5rem;
    right: 2rem;
    width: min(360px, 90vw);
    max-height: 70vh;
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 25px 45px rgba(15, 23, 42, 0.18);
    padding: 1rem;
    display: none;
    flex-direction: column;
    gap: 0.5rem;
    z-index: 40;
    overflow-y: auto;
    overscroll-behavior: contain;
}

.word-inspector.active {
    display: flex;
}

.word-inspector header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

#closeWordInspector {
    border: none;
    background: transparent;
    font-size: 1.5rem;
    cursor: pointer;
}

.chat-widget {
    position: fixed;
    bottom: 1.5rem;
    right: 2rem;
    width: 360px;
    background: #0f172a;
    color: #f8fafc;
    border-radius: 20px;
    box-shadow: 0 30px 45px rgba(15, 23, 42, 0.35);
    display: flex;
    flex-direction: column;
    max-height: 70vh;
    overflow: visible;
    z-index: 30;
}

.chat-widget header {
    padding: 1rem 1.2rem;
}

.chat-history {
    flex: 1;
    padding: 1rem;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.message {
    padding: 0.75rem 1rem;
    border-radius: 14px;
    line-height: 1.5;
}

.message.user {
    background: rgba(59, 130, 246, 0.35);
    align-self: flex-end;
}

.message.assistant {
    background: rgba(15, 23, 42, 0.6);
    border: 1px solid rgba(148, 163, 184, 0.2);
    align-self: flex-start;
}

.chat-form {
    display: flex;
    gap: 0.5rem;
    padding: 1rem;
    background: rgba(15, 23, 42, 0.85);
}

.chat-form textarea {
    flex: 1;
    border-radius: 12px;
    border: none;
    padding: 0.75rem;
    resize: none;
    font-family: inherit;
    background: rgba(15, 23, 42, 0.65);
    color: #f8fafc;
}

.chat-form button {
    background: var(--accent);
    border: none;
    color: #fff;
    border-radius: 12px;
    padding: 0.75rem 1.25rem;
    cursor: pointer;
}

.loading {
    opacity: 0.6;
    pointer-events: none;
}

@media (max-width: 1100px) {
    .workspace {
        grid-template-columns: 1fr;
    }

    .chat-widget {
        position: static;
        width: 100%;
        margin-top: 2rem;
    }

    body {
        padding-bottom: 2rem;
    }
}

@media (max-width: 720px) {
    .workspace {
        padding: 0 1rem 2rem;
    }

    .site-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.75rem;
    }

    .word-inspector {
    position: fixed;
    top: 2.5rem;
    right: 2rem;
    width: min(360px, 90vw);
    max-height: 70vh;
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 25px 45px rgba(15, 23, 42, 0.18);
    padding: 1rem;
    display: none;
    flex-direction: column;
    gap: 0.5rem;
    z-index: 40;
    overflow-y: auto;
    overscroll-behavior: contain;
}
}
.pos-legend {
    list-style: none;
    display: flex;
    flex-wrap: wrap;
    gap: 0.6rem 1rem;
    margin: 0.75rem 0 0;
    padding: 0;
    color: var(--muted);
    font-size: 0.85rem;
}

.pos-legend li {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
}

.pos-legend li::before {
    content: '';
    width: 12px;
    height: 12px;
    border-radius: 6px;
    display: inline-block;
}

.pos-legend .legend-noun::before { background: var(--pos-noun); }
.pos-legend .legend-verb::before { background: var(--pos-verb); }
.pos-legend .legend-adjective::before { background: var(--pos-adjective); }
.pos-legend .legend-adverb::before { background: var(--pos-adverb); }
.pos-legend .legend-connector::before { background: var(--pos-connector); }
.pos-legend .legend-other::before { background: var(--pos-other); }

.issue-list {
    list-style: none;
    padding-left: 0;
    margin: 0.5rem 0 0;
    display: grid;
    gap: 0.5rem;
}

.issue-card {
    background: rgba(255, 255, 255, 0.8);
    border-radius: 10px;
    border: 1px solid rgba(148, 163, 184, 0.25);
    padding: 0.6rem 0.75rem;
}

.issue-card strong {
    display: block;
    font-size: 0.85rem;
    margin-bottom: 0.25rem;
    color: var(--accent-dark);
}

.issue-meta {
    font-size: 0.85rem;
    color: var(--muted);
}

.issue-example {
    margin-top: 0.25rem;
    font-size: 0.85rem;
    color: #0f172a;
}

.issue-example span {
    font-weight: 600;
    margin-right: 0.3rem;
}

.word-inspector section {
    margin-bottom: 0.75rem;
}

.word-inspector section:last-child {
    margin-bottom: 0;
}

.word-inspector h4 {
    margin: 0 0 0.35rem;
    font-size: 0.95rem;
}

.word-inspector ul {
    padding-left: 1rem;
    margin: 0.3rem 0;
}

.word-inspector .ipa-row {
    display: flex;
    gap: 0.75rem;
    font-size: 0.9rem;
    color: var(--muted);
}

.word-inspector .entry-card {
    background: rgba(241, 245, 249, 0.8);
    border-radius: 12px;
    padding: 0.75rem;
    border: 1px solid rgba(148, 163, 184, 0.3);
    margin-bottom: 0.75rem;
}

.word-inspector .entry-card:last-child {
    margin-bottom: 0;
}

.word-inspector .entry-card strong {
    display: inline-block;
    margin-bottom: 0.4rem;
}

.feedback-card ul {
    margin: 0.4rem 0 0;
    padding-left: 1rem;
}

.feedback-card li {
    margin-bottom: 0.35rem;
}

.feedback-card li:last-child {
    margin-bottom: 0;
}

.keyword .memory-tip {
    display: block;
    margin-top: 0.5rem;
    font-size: 0.85rem;
    color: var(--muted);
}
.pos-legend li {
    gap: 0.35rem;
}

.pos-legend li::before {
    display: none;
}

.pos-legend .legend-chip {
    display: inline-flex;
    width: 12px;
    height: 12px;
    border-radius: 6px;
    background: var(--pos-other);
}

.pos-legend .legend-noun .legend-chip { background: rgba(37, 99, 235, 0.9); }
.pos-legend .legend-verb .legend-chip { background: rgba(234, 88, 12, 0.9); }
.pos-legend .legend-adjective .legend-chip { background: rgba(147, 51, 234, 0.9); }
.pos-legend .legend-adverb .legend-chip { background: rgba(5, 150, 105, 0.9); }
.pos-legend .legend-connector .legend-chip { background: rgba(14, 165, 233, 0.9); }

.keyword {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    text-align: left;
    word-break: break-word;
    white-space: normal;
    line-height: 1.5;
}

.keyword strong {
    font-size: 1.05rem;
    margin-bottom: 0.25rem;
}

.keyword p {
    margin: 0.3rem 0 0;
}
.word-inspector {
    position: fixed;
    top: 2.5rem;
    right: 2rem;
    width: min(360px, 90vw);
    max-height: 70vh;
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 25px 45px rgba(15, 23, 42, 0.18);
    padding: 1rem;
    display: none;
    flex-direction: column;
    gap: 0.5rem;
    z-index: 40;
    overflow-y: auto;
    overscroll-behavior: contain;
}

.word-inspector .entry-card,
.word-inspector ul,
.word-inspector p,
.word-inspector li {
    max-width: 100%;
    word-wrap: break-word;
    overflow-wrap: anywhere;
}

.word-inspector .entry-card {
    white-space: normal;
}

.word-inspector .entry-card ul {
    list-style: disc;
    padding-left: 1.2rem;
}

.word-inspector .entry-card li {
    margin-bottom: 0.4rem;
}

.word-inspector .entry-card li:last-child {
    margin-bottom: 0;
}

.word-inspector .entry-card,
.word-inspector section,
.word-inspector p,
.word-inspector li {
    max-width: 100%;
    word-wrap: break-word;
    overflow-wrap: anywhere;
    white-space: normal;
}

.word-inspector .entry-card ul {
    list-style: disc;
    padding-left: 1.2rem;
    margin: 0.3rem 0;
}

.word-inspector .entry-card li {
    margin-bottom: 0.4rem;
}

.word-inspector .entry-card li:last-child {
    margin-bottom: 0;
}

.word-inspector .ipa-row {
    flex-wrap: wrap;
}

.chat-widget.collapsed {
    height: auto;
    width: auto;
    max-width: 320px;
    pointer-events: auto;
}

.chat-widget.collapsed header,
.chat-widget.collapsed .chat-history,
.chat-widget.collapsed .chat-form {
    display: none;
}

.chat-widget.collapsed .chat-toggle {
    display: flex;
}

.chat-widget .chat-toggle { position: absolute; top: -2.2rem; right: 0; display: inline-flex; align-items: center; gap: 0.35rem; background: #0f172a; color: #f8fafc; padding: 0.35rem 0.75rem; border-radius: 999px; border: none; font-size: 0.85rem; cursor: pointer; box-shadow: 0 12px 25px rgba(15, 23, 42, 0.25);}

.chat-widget.collapsed .chat-toggle .label-collapsed {
    display: inline;
}

.chat-widget .chat-toggle .label-expanded {
    display: inline;
}

.chat-widget.collapsed .chat-toggle .label-expanded {
    display: none;
}

.chat-widget .chat-toggle .label-collapsed {
    display: none;
}

.chat-widget.collapsed {
    box-shadow: none;
    background: transparent;
}

.chat-widget.collapsed .badge-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 18px;
    height: 18px;
    border-radius: 999px;
    background: var(--accent);
    color: #fff;
    font-size: 0.7rem;
    padding: 0 0.25rem;
}

body.chat-widget-collapsed .chat-widget {
    pointer-events: auto;
}

.chat-widget {
    position: fixed;
    bottom: 1.5rem;
    right: 2rem;
    width: 360px;
    background: #0f172a;
    color: #f8fafc;
    border-radius: 20px;
    box-shadow: 0 30px 45px rgba(15, 23, 42, 0.35);
    display: flex;
    flex-direction: column;
    max-height: 70vh;
    overflow: visible;
    z-index: 30;
}



.chat-widget .chat-toggle .badge-count {
    display: none;
    min-width: 18px;
    height: 18px;
    padding: 0 0.35rem;
    border-radius: 999px;
    background: var(--accent);
    color: #fff;
    font-size: 0.7rem;
    align-items: center;
    justify-content: center;
}

.chat-widget .chat-toggle .label-collapsed {
    display: none;
}

.chat-widget.collapsed {
    width: auto;
    max-width: 320px;
    background: transparent;
    box-shadow: none;
    pointer-events: none;
}

.chat-widget.collapsed .chat-toggle {
    pointer-events: auto;
}

.chat-widget.collapsed header,
.chat-widget.collapsed .chat-history,
.chat-widget.collapsed .chat-form {
    display: none;
}

.chat-widget.collapsed .chat-toggle .label-expanded {
    display: none;
}

.chat-widget.collapsed .chat-toggle .label-collapsed {
    display: inline;
}
.chat-widget.collapsed {
    padding: 0;
}



/* Chat widget overrides */
.chat-widget {
    overflow: visible !important;
}

.chat-widget .chat-toggle {
    position: absolute;
    top: -2.2rem;
    right: 0;
    display: inline-flex !important;
    align-items: center;
    gap: 0.35rem;
    background: #0f172a;
    color: #f8fafc;
    padding: 0.35rem 0.75rem;
    border-radius: 999px;
    border: none;
    font-size: 0.85rem;
    cursor: pointer;
    box-shadow: 0 12px 25px rgba(15, 23, 42, 0.25);
}

.chat-widget .chat-toggle .badge-count {
    display: none;
    min-width: 18px;
    height: 18px;
    padding: 0 0.35rem;
    border-radius: 999px;
    background: var(--accent);
    color: #fff;
    font-size: 0.7rem;
    align-items: center;
    justify-content: center;
}

.chat-widget .chat-toggle .label-collapsed {
    display: none;
}

.chat-widget.collapsed {
    width: auto !important;
    max-width: 320px;
    background: transparent !important;
    box-shadow: none !important;
    pointer-events: none;
    padding: 0 !important;
}

.chat-widget.collapsed .chat-toggle {
    pointer-events: auto;
}

.chat-widget.collapsed header,
.chat-widget.collapsed .chat-history,
.chat-widget.collapsed .chat-form {
    display: none !important;
}

.chat-widget.collapsed .chat-toggle .label-expanded {
    display: none !important;
}

.chat-widget.collapsed .chat-toggle .label-collapsed {
    display: inline !important;
}

.chat-widget.collapsed .chat-toggle .badge-count {
    display: inline-flex !important;
}
/* Chat widget behaviour */
.chat-widget {
    overflow: visible !important;
}

.chat-widget .chat-toggle {
    position: absolute;
    top: -2.4rem;
    right: 0;
    display: inline-flex !important;
    align-items: center;
    gap: 0.35rem;
    background: #0f172a;
    color: #f8fafc;
    padding: 0.35rem 0.75rem;
    border-radius: 999px;
    border: none;
    font-size: 0.85rem;
    cursor: pointer;
    box-shadow: 0 12px 25px rgba(15, 23, 42, 0.25);
    z-index: 2;
}

.chat-widget .chat-toggle .badge-count {
    display: none;
    min-width: 18px;
    height: 18px;
    padding: 0 0.35rem;
    border-radius: 999px;
    background: var(--accent);
    color: #fff;
    font-size: 0.7rem;
    align-items: center;
    justify-content: center;
}

.chat-widget .chat-toggle .label-collapsed {
    display: none;
}

.chat-widget.collapsed {
    width: auto !important;
    max-width: 320px;
    background: transparent !important;
    box-shadow: none !important;
    pointer-events: none;
    padding: 0 !important;
}

.chat-widget.collapsed .chat-toggle {
    pointer-events: auto;
}

.chat-widget.collapsed header,
.chat-widget.collapsed .chat-history,
.chat-widget.collapsed .chat-form {
    display: none !important;
}

.chat-widget.collapsed .chat-toggle .label-expanded {
    display: none !important;
}

.chat-widget.collapsed .chat-toggle .label-collapsed {
    display: inline !important;
}

.chat-widget.collapsed .chat-toggle .badge-count {
    display: inline-flex !important;
}


.site-header nav {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.user-chip {
    background: rgba(15, 23, 42, 0.12);
    color: #0f172a;
    padding: 0.35rem 0.85rem;
    border-radius: 999px;
    font-weight: 600;
    font-size: 0.95rem;
}

.panel-notice {
    background: #eff6ff;
    border: 1px solid #bfdbfe;
    border-radius: 12px;
    padding: 1rem;
    margin-bottom: 1rem;
}

.panel-notice p {
    margin: 0.25rem 0 0;
    color: #1e3a8a;
    font-size: 0.9rem;
}

.notice-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.75rem;
    margin-top: 0.75rem;
}

a.primary {
    display: inline-block;
    background: var(--accent);
    color: #fff;
    border-radius: 12px;
    padding: 0.55rem 1.4rem;
    text-decoration: none;
    font-weight: 600;
    box-shadow: 0 12px 30px rgba(37, 99, 235, 0.22);
    transition: transform 0.15s ease;
}

a.primary:hover {
    transform: translateY(-1px);
}

a.ghost {
    display: inline-block;
    padding: 0.5rem 1.2rem;
    border-radius: 12px;
    border: 1px solid var(--accent);
    color: var(--accent);
    text-decoration: none;
    font-weight: 600;
    transition: background 0.2s ease;
}

a.ghost:hover {
    background: rgba(37, 99, 235, 0.08);
}

label.upload.disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

label.upload.disabled input {
    pointer-events: none;
}

.chat-form textarea[disabled] {
    cursor: not-allowed;
    background: #f1f5f9;
}

.chat-form button[disabled] {
    cursor: not-allowed;
    opacity: 0.6;
}

.chat-widget[data-locked="true"] {
    opacity: 0.85;
}

.auth-page {
    min-height: 100vh;
    margin: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: radial-gradient(circle at 10% 20%, rgba(219,234,254,0.8) 0%, rgba(243,244,246,1) 40%, rgba(248,250,252,1) 100%);
}

.auth-container {
    width: 100%;
    max-width: 480px;
    padding: 2rem 1.25rem;
}

.auth-card {
    background: #fff;
    border-radius: 16px;
    padding: 2rem;
    box-shadow: 0 25px 60px rgba(15, 23, 42, 0.16);
}

.auth-card h1 {
    margin: 0 0 0.5rem;
}

.auth-subtitle {
    margin: 0 0 1.5rem;
    color: var(--muted);
}

.auth-alert {
    background: #fee2e2;
    color: #b91c1c;
    border-radius: 10px;
    padding: 0.75rem 1rem;
    margin-bottom: 1.25rem;
}

.auth-alert ul {
    margin: 0;
    padding-left: 1.2rem;
}

.auth-form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.auth-form label {
    display: flex;
    flex-direction: column;
    font-weight: 600;
    font-size: 0.95rem;
}

.auth-form input[type="text"],
.auth-form input[type="email"],
.auth-form input[type="password"],
.auth-form textarea {
    margin-top: 0.4rem;
    padding: 0.75rem;
    border-radius: 10px;
    border: 1px solid #cbd5e1;
    background: #f8fafc;
    font-size: 1rem;
    font-family: inherit;
}

.captcha-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.captcha-label {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: 600;
    font-size: 0.95rem;
}

.captcha-display {
    display: flex;
    justify-content: center;
    align-items: center;
    font-family: 'Courier New', Courier, monospace;
    font-size: 1.25rem;
    letter-spacing: 0.4rem;
    padding: 0.75rem 1rem;
    border-radius: 10px;
    background: #0f172a;
    color: #f8fafc;
}

.captcha-refresh {
    background: transparent;
    border: none;
    color: var(--accent);
    font-weight: 600;
    cursor: pointer;
}

.auth-card .primary,
.auth-card button.primary {
    width: 100%;
    text-align: center;
}

.auth-footer {
    margin-top: 1.5rem;
    display: flex;
    justify-content: center;
    gap: 0.5rem;
    font-size: 0.9rem;
}

.auth-footer a {
    color: var(--accent-dark);
    text-decoration: none;
    font-weight: 600;
}

.maintenance-page {
    min-height: 100vh;
    margin: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: radial-gradient(circle at 10% 20%, rgba(219,234,254,0.8) 0%, rgba(243,244,246,1) 40%, rgba(248,250,252,1) 100%);
}

.maintenance-container {
    padding: 2rem;
    width: 100%;
}

.maintenance-card {
    max-width: 460px;
    margin: 0 auto;
    background: #fff;
    border-radius: 16px;
    padding: 2.5rem 2rem;
    text-align: center;
    box-shadow: 0 30px 60px rgba(15, 23, 42, 0.18);
}

.maintenance-card p {
    color: var(--muted);
    line-height: 1.6;
}

.maintenance-card .primary {
    margin-top: 1.5rem;
}

button.ghost {
    background: transparent;
    border: 1px solid var(--accent);
    color: var(--accent);
    border-radius: 12px;
    padding: 0.5rem 1.2rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s ease;
}

button.ghost:hover {
    background: rgba(37, 99, 235, 0.08);
}

.history-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.history-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.history-card {
    background: rgba(248, 250, 252, 0.75);
    border-radius: 14px;
    padding: 1rem;
    border: 1px solid rgba(148, 163, 184, 0.2);
}

.history-meta {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
}

.history-duration {
    margin-left: 0.75rem;
    font-size: 0.85rem;
    color: var(--muted);
}

.history-actions {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.history-actions button {
    background: rgba(37, 99, 235, 0.12);
    color: var(--accent-dark);
    border: none;
    border-radius: 999px;
    padding: 0.35rem 0.8rem;
    font-size: 0.85rem;
    cursor: pointer;
}

.history-actions button:hover {
    background: rgba(37, 99, 235, 0.18);
}

.history-actions button[data-action="delete"] {
    background: rgba(220, 38, 38, 0.12);
    color: #b91c1c;
}

.history-actions button[data-action="delete"]:hover {
    background: rgba(220, 38, 38, 0.18);
}

.history-excerpt {
    margin: 0.75rem 0 0;
    line-height: 1.6;
    color: var(--text);
    opacity: 0.9;
    overflow-wrap: anywhere;
    white-space: normal;
}

.site-nav .nav-button {
    border: none;
    background: transparent;
    font: inherit;
    color: var(--accent-dark);
    font-weight: 600;
    cursor: pointer;
}

.site-nav .nav-button.history-toggle {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.35rem 0.85rem;
    border-radius: 999px;
    background: rgba(37, 99, 235, 0.12);
    border: 1px solid rgba(37, 99, 235, 0.22);
    transition: background 0.2s ease, transform 0.15s ease;
}

.site-nav .nav-button.history-toggle:hover {
    background: rgba(37, 99, 235, 0.18);
    transform: translateY(-1px);
}

.site-nav .nav-button.history-toggle .badge-count {
    display: none;
    min-width: 18px;
    height: 18px;
    padding: 0 0.35rem;
    border-radius: 999px;
    background: var(--accent);
    color: #fff;
    font-size: 0.7rem;
    align-items: center;
    justify-content: center;
}

.history-panel {
    position: fixed;
    top: 5.85rem;
    right: 2rem;
    width: min(420px, calc(100vw - 2.5rem));
    max-height: min(70vh, 640px);
    background: rgba(255, 255, 255, 0.98);
    border: 1px solid rgba(148, 163, 184, 0.35);
    border-radius: 18px;
    box-shadow: 0 24px 60px rgba(15, 23, 42, 0.18);
    padding: 1rem;
    overflow: hidden;
    opacity: 0;
    transform: translateY(-10px);
    pointer-events: none;
    transition: opacity 0.16s ease, transform 0.16s ease;
    z-index: 60;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.history-panel.open {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

.history-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.history-panel-header h3 {
    margin: 0;
    font-size: 1.05rem;
}

.history-panel-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.history-close {
    background: transparent;
    border: none;
    color: var(--muted);
    font-size: 1.6rem;
    line-height: 1;
    padding: 0.1rem 0.4rem;
    cursor: pointer;
}

.history-close:hover {
    color: var(--text);
}

.history-panel .history-list {
    overflow: auto;
    padding-right: 0.25rem;
}

@media (max-width: 640px) {
    .history-panel {
        right: 1rem;
        top: 5.25rem;
    }
}

.summary-workspace {
    display: grid;
    grid-template-columns: 1.2fr 1fr;
    gap: 1.5rem;
    padding: 0 2rem 2rem;
}

.summary-controls,
.practice-controls {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 1rem;
    margin: 1rem 0 1.5rem;
}

.summary-controls label,
.practice-controls label {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    font-weight: 600;
    font-size: 0.9rem;
}

.summary-countdown {
    color: var(--muted);
    font-size: 0.9rem;
    min-height: 1.2rem;
}

.summary-controls input,
.practice-controls input,
.practice-controls select {
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 0.5rem 0.75rem;
    font-size: 0.95rem;
    min-width: 200px;
    background: #f8fafc;
}

.summary-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 1rem;
}

.summary-card {
    background: rgba(248, 250, 252, 0.9);
    border-radius: 14px;
    padding: 1rem;
    border: 1px solid rgba(148, 163, 184, 0.2);
}

.summary-card h3 {
    margin-top: 0;
}

.summary-list {
    margin: 0.6rem 0 0;
    padding-left: 1.1rem;
}

.summary-list li {
    margin-bottom: 0.4rem;
}

.summary-list li:last-child {
    margin-bottom: 0;
}

.stats-list {
    display: grid;
    gap: 0.5rem;
}

.stat-row {
    display: grid;
    grid-template-columns: auto 1fr auto;
    gap: 0.6rem;
    align-items: center;
    font-size: 0.9rem;
}

.stat-label {
    font-weight: 600;
    text-transform: capitalize;
}

.stat-bar {
    background: rgba(148, 163, 184, 0.2);
    border-radius: 999px;
    height: 8px;
    overflow: hidden;
}

.stat-bar span {
    display: block;
    height: 100%;
    border-radius: inherit;
    background: rgba(37, 99, 235, 0.7);
}

.tag-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
}

.tag {
    display: inline-flex;
    align-items: center;
    padding: 0.2rem 0.7rem;
    border-radius: 999px;
    background: rgba(37, 99, 235, 0.12);
    color: var(--accent-dark);
    font-weight: 600;
    font-size: 0.8rem;
}

.practice-list {
    display: grid;
    gap: 1rem;
}

.practice-card {
    background: rgba(248, 250, 252, 0.9);
    border-radius: 14px;
    padding: 1rem;
    border: 1px solid rgba(148, 163, 184, 0.2);
    display: grid;
    gap: 0.6rem;
}

.practice-card header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
}

.practice-prompt {
    margin: 0;
    font-size: 1rem;
}

.practice-options {
    margin: 0;
    padding-left: 1.2rem;
}

.practice-options li {
    margin-bottom: 0.3rem;
}

.practice-answer {
    background: rgba(15, 23, 42, 0.04);
    border-radius: 12px;
    padding: 0.6rem 0.9rem;
}

.practice-answer summary {
    cursor: pointer;
    font-weight: 600;
}

.practice-explanation {
    margin: 0.5rem 0 0;
    color: var(--muted);
    font-size: 0.9rem;
}

.difficulty {
    background: rgba(15, 23, 42, 0.08);
    border-radius: 999px;
    padding: 0.15rem 0.6rem;
    font-size: 0.8rem;
}

.muted {
    color: var(--muted);
    font-size: 0.85rem;
}

@media (max-width: 900px) {
    .summary-workspace {
        padding: 0 1rem 2rem;
        grid-template-columns: 1fr;
    }

    .summary-controls input,
    .practice-controls input,
    .practice-controls select {
        min-width: 160px;
    }
}
