:root {
    --bg: #0f1117;
    --surface: #1a1d27;
    --surface2: #242836;
    --border: #2e3345;
    --text: #e8eaef;
    --text-muted: #9aa3b5;
    --primary: #4f7cff;
    --primary-hover: #3d6aef;
    --danger: #ef4444;
    --radius: 12px;
    --shadow: 0 4px 24px rgba(0, 0, 0, 0.3);
    --cookie-bg: rgba(26, 29, 39, 0.97);
    --cookie-text: #e8eaef;
}

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

body {
    font-family: "Inter", system-ui, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

a {
    color: var(--primary);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

.container {
    width: 100%;
    max-width: 1100px;
    margin: 0 auto;
    padding: 0 20px;
}

.site-header {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-inner {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 14px 20px;
    flex-wrap: wrap;
}

.logo {
    font-weight: 700;
    font-size: 1.15rem;
    color: var(--text);
    text-decoration: none;
    white-space: nowrap;
}

.main-nav {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    flex: 1;
}

.main-nav a {
    color: var(--text-muted);
    font-size: 0.9rem;
    padding: 6px 10px;
    border-radius: 8px;
    text-decoration: none;
}

.main-nav a:hover {
    color: var(--text);
    background: var(--surface2);
    text-decoration: none;
}

.btn-nav {
    background: var(--primary) !important;
    color: #fff !important;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.lang-dropdown {
    display: flex;
    align-items: center;
    gap: 8px;
}

.lang-label {
    font-size: 0.85rem;
    color: var(--text-muted);
    white-space: nowrap;
}

.lang-menu {
    position: relative;
}

.lang-menu-toggle {
    list-style: none;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface2);
    color: var(--text);
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    white-space: nowrap;
    font-family: inherit;
}

.lang-menu-toggle::-webkit-details-marker {
    display: none;
}

.lang-menu-toggle::after {
    content: "▾";
    margin-left: 2px;
    font-size: 0.75rem;
    color: var(--text-muted);
}

.lang-menu[open] .lang-menu-toggle {
    border-color: var(--primary);
}

.lang-menu-list {
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    min-width: 180px;
    margin: 0;
    padding: 6px;
    list-style: none;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
    z-index: 200;
}

.lang-option {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border-radius: 8px;
    color: var(--text);
    text-decoration: none;
    font-size: 0.9rem;
}

.lang-option:hover,
.lang-option.active {
    background: var(--surface2);
    text-decoration: none;
}

.lang-option.active {
    color: var(--primary);
    font-weight: 600;
}

.lang-flag {
    font-size: 1.1rem;
    line-height: 1;
}

.account-menu {
    position: relative;
}

.account-dropdown {
    position: relative;
}

.account-menu-toggle {
    list-style: none;
    padding: 6px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface2);
    color: var(--text);
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    white-space: nowrap;
    font-family: inherit;
}

.account-menu-toggle::-webkit-details-marker {
    display: none;
}

.account-menu-toggle::after {
    content: "▾";
    margin-left: 6px;
    font-size: 0.75rem;
    color: var(--text-muted);
}

.account-menu-list {
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    min-width: 180px;
    margin: 0;
    padding: 6px;
    list-style: none;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
    z-index: 200;
}

.account-menu-list a,
.account-menu-list button {
    display: block;
    width: 100%;
    text-align: left;
    padding: 8px 10px;
    border: none;
    border-radius: 8px;
    background: transparent;
    color: var(--text);
    font-size: 0.9rem;
    font-family: inherit;
    cursor: pointer;
    text-decoration: none;
}

.account-menu-list a:hover,
.account-menu-list button:hover {
    background: var(--surface2);
}

.hero-price {
    margin: 0 0 20px;
    color: var(--text-muted);
    font-size: 0.95rem;
}

.dashboard-sub-warning {
    margin-top: 8px;
    color: #b45309;
}

.subscription-panel {
    max-width: 520px;
}

.subscription-price {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-bottom: 16px;
    font-size: 1.2rem;
}

.subscription-status-active {
    color: #15803d;
    font-weight: 600;
}

.subscription-status-inactive {
    color: var(--text-muted);
}

.subscription-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin: 16px 0;
}

.subscription-note {
    margin-top: 12px;
}

.main-content {
    flex: 1;
    padding: 32px 20px 48px;
}

.site-footer {
    background: var(--surface);
    border-top: 1px solid var(--border);
    padding: 20px 0;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.85rem;
}

.hero {
    text-align: center;
    padding: 60px 0 40px;
}

.hero h1 {
    font-size: 2.4rem;
    margin-bottom: 16px;
    line-height: 1.2;
}

.hero-sub {
    color: var(--text-muted);
    font-size: 1.1rem;
    max-width: 560px;
    margin: 0 auto 28px;
}

.hero .btn {
    margin: 4px 6px;
}

.hero-about {
    display: inline-flex;
}

.features {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 20px;
    margin-top: 20px;
}

.feature-card,
.dash-card,
.tool-card,
.auth-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 28px;
    box-shadow: var(--shadow);
}

.feature-card h3,
.dash-card h3 {
    margin-bottom: 8px;
}

.feature-card p,
.dash-card p {
    color: var(--text-muted);
    font-size: 0.95rem;
}

.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 20px;
}

.dash-card {
    display: block;
    color: var(--text);
    text-decoration: none;
    transition: transform 0.15s, border-color 0.15s;
}

.dash-card:hover {
    transform: translateY(-2px);
    border-color: var(--primary);
    text-decoration: none;
}

.page-header {
    margin-bottom: 24px;
}

.page-header h1 {
    font-size: 1.8rem;
    margin-bottom: 6px;
}

.hint {
    color: var(--text-muted);
    font-size: 0.95rem;
}

.auth-card {
    max-width: 420px;
    margin: 40px auto;
}

.auth-card h1 {
    margin-bottom: 24px;
    text-align: center;
}

.alert {
    padding: 12px 14px;
    border-radius: 8px;
    margin-bottom: 16px;
    font-size: 0.9rem;
}

.alert-error {
    background: rgba(239, 68, 68, 0.12);
    border: 1px solid rgba(239, 68, 68, 0.35);
    color: #fca5a5;
}

.alert-success {
    background: rgba(34, 197, 94, 0.12);
    border: 1px solid rgba(34, 197, 94, 0.35);
    color: #86efac;
}

.token-count {
    font-size: 2.4rem;
    font-weight: 700;
    color: var(--primary);
    margin: 8px 0;
}

code {
    background: var(--surface2);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.85rem;
}

.form {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.form label {
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-size: 0.9rem;
    color: var(--text-muted);
}

.form input,
.form select,
.form textarea {
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 10px 14px;
    color: var(--text);
    font-family: inherit;
    font-size: 0.95rem;
}

.form input:focus,
.form select:focus,
.form textarea:focus {
    outline: none;
    border-color: var(--primary);
}

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 12px;
}

.checkbox-label {
    flex-direction: row !important;
    align-items: center;
    gap: 10px !important;
    cursor: pointer;
    color: var(--text) !important;
    font-size: 0.95rem !important;
}

.checkbox-label input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--primary);
    cursor: pointer;
}

.form-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.form-footer {
    text-align: center;
    margin-top: 20px;
    color: var(--text-muted);
    font-size: 0.9rem;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 20px;
    border-radius: 8px;
    font-weight: 600;
    font-size: 0.95rem;
    cursor: pointer;
    border: none;
    font-family: inherit;
    text-decoration: none;
    transition: background 0.15s;
}

.btn-primary {
    background: var(--primary);
    color: #fff;
}

.btn-primary:hover {
    background: var(--primary-hover);
}

.btn-outline {
    background: transparent;
    color: var(--text);
    border: 1px solid var(--border);
}

.btn-outline:hover {
    border-color: var(--primary);
    color: var(--primary);
}

.btn-danger {
    background: var(--danger);
    color: #fff;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 0.85rem;
}

.btn-google {
    background: #fff;
    color: #333;
    border: 1px solid var(--border);
    width: 100%;
}

.btn-google:hover {
    background: #f5f5f5;
}

.auth-divider {
    text-align: center;
    color: var(--text-muted);
    margin: 8px 0;
}

.section-label {
    margin: 20px 0 10px;
    font-size: 0.95rem;
    color: var(--text-muted);
}

.hidden {
    display: none;
}

.page-sub {
    color: var(--text-muted);
    margin-top: 8px;
    font-size: 0.95rem;
}

.doc-blocks {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 16px;
}

.doc-block {
    position: relative;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 12px 36px 12px 12px;
    background: var(--surface, #fff);
}

.doc-block-active {
    border-color: var(--primary);
    box-shadow: 0 0 0 1px var(--primary);
}

.doc-block-text textarea {
    width: 100%;
    min-height: 120px;
    border: none;
    resize: vertical;
    font-family: inherit;
    font-size: 0.95rem;
    line-height: 1.5;
    background: transparent;
    padding: 0;
}

.doc-block-text textarea:focus {
    outline: none;
}

.doc-block-image {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
}

.doc-block-image img {
    max-width: 100%;
    max-height: 240px;
    border-radius: 6px;
    object-fit: contain;
}

.doc-block-image-name {
    font-size: 0.85rem;
    color: var(--text-muted);
}

.doc-block-remove {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 28px;
    height: 28px;
    border: none;
    border-radius: 6px;
    background: transparent;
    color: var(--text-muted);
    font-size: 1.25rem;
    line-height: 1;
    cursor: pointer;
}

.doc-block-remove:hover {
    background: var(--border);
    color: var(--text);
}

.doc-blocks-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 20px;
}

.table-wrap {
    overflow-x: auto;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.data-table th,
.data-table td {
    padding: 12px 14px;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

.data-table th {
    color: var(--text-muted);
    font-weight: 500;
}

.history-panel {
    position: relative;
}

.history-bulk-bar {
    position: sticky;
    z-index: 99;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 12px;
    margin: -8px -8px 16px;
    padding: 10px 12px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.06);
}

.history-bulk-bar.hidden {
    display: none;
}

.history-selected-text {
    margin-right: auto;
    font-size: 0.9rem;
    color: var(--text-muted);
}

.history-selected-text strong {
    color: var(--text);
}

.history-bulk-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.history-table .col-check {
    width: 44px;
    text-align: center;
    vertical-align: middle;
}

.history-check {
    width: 18px;
    height: 18px;
    accent-color: var(--primary);
    cursor: pointer;
}

.history-row {
    cursor: pointer;
    transition: background 0.12s;
}

.history-row:hover,
.history-row.is-selected {
    background: var(--surface2);
}

.history-name {
    font-weight: 500;
}

.history-modal {
    position: fixed;
    inset: 0;
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.history-modal.hidden {
    display: none;
}

.history-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
}

.history-modal-card {
    position: relative;
    width: 100%;
    max-width: 420px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 24px;
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.18);
}

.history-modal-title {
    margin: 0 32px 20px 0;
    font-size: 1.05rem;
    word-break: break-word;
}

.history-modal-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.history-modal-close {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 32px;
    height: 32px;
    border: none;
    border-radius: 8px;
    background: transparent;
    color: var(--text-muted);
    font-size: 1.4rem;
    line-height: 1;
    cursor: pointer;
}

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

.page-loading {
    position: fixed;
    inset: 0;
    z-index: 400;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.page-loading.hidden {
    display: none;
}

.page-loading-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
}

.page-loading-box {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    padding: 28px 32px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.2);
    min-width: 220px;
}

.page-loading-spinner {
    width: 44px;
    height: 44px;
    border: 3px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: page-loading-spin 0.8s linear infinite;
}

@keyframes page-loading-spin {
    to {
        transform: rotate(360deg);
    }
}

#page-loading-text {
    margin: 0;
    color: var(--text);
    font-weight: 500;
}

body.page-is-loading {
    overflow: hidden;
}

.confirm-dialog {
    position: fixed;
    inset: 0;
    z-index: 350;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.confirm-dialog.hidden {
    display: none;
}

.confirm-dialog-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
}

.confirm-dialog-card {
    position: relative;
    width: 100%;
    max-width: 400px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 24px;
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.18);
}

.confirm-dialog-message {
    margin: 0 0 20px;
    font-size: 1.05rem;
    line-height: 1.45;
}

.confirm-dialog-title {
    margin: 0 0 12px;
    font-size: 1.15rem;
}

.confirm-dialog-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    flex-wrap: wrap;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.actions-cell {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.empty-state {
    text-align: center;
    color: var(--text-muted);
    padding: 40px 0;
}

.toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    background: var(--surface2);
    border: 1px solid var(--border);
    color: var(--text);
    padding: 14px 20px;
    border-radius: 10px;
    box-shadow: var(--shadow);
    z-index: 10000;
    max-width: 360px;
    transition: opacity 0.3s;
}

.toast.hidden {
    opacity: 0;
    pointer-events: none;
}

.toast.success {
    border-color: #22c55e;
}

.toast.error {
    border-color: var(--danger);
}

.cookie-banner {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%) translateY(30px);
    opacity: 0;
    background: var(--cookie-bg);
    color: var(--cookie-text);
    padding: 18px 20px;
    border-radius: 14px;
    width: calc(100% - 40px);
    max-width: 420px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(12px);
    transition: all 0.35s ease;
    z-index: 9999;
    border: 1px solid var(--border);
}

.cookie-banner.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

.cookie-content {
    display: flex;
    flex-direction: column;
    gap: 10px;
    text-align: center;
}

.cookie-buttons button {
    padding: 10px 14px;
    border: none;
    border-radius: 10px;
    background: var(--primary);
    color: white;
    font-weight: bold;
    cursor: pointer;
}

@media (max-width: 768px) {
    .header-inner {
        flex-direction: column;
        align-items: flex-start;
    }

    .hero h1 {
        font-size: 1.8rem;
    }

    .about-list-cols {
        columns: 1;
    }
}

/* About page */
.about-page {
    max-width: 820px;
    margin: 0 auto;
}

.about-hero {
    margin-bottom: 40px;
    text-align: center;
}

.about-hero h1 {
    font-size: 2rem;
    margin-bottom: 12px;
}

.about-intro {
    color: var(--text-muted);
    font-size: 1.05rem;
}

.about-section {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 28px;
    margin-bottom: 24px;
    box-shadow: var(--shadow);
}

.about-section h2 {
    font-size: 1.3rem;
    margin-bottom: 12px;
    color: var(--text);
}

.about-sub {
    font-size: 1rem;
    margin: 20px 0 10px;
    color: var(--primary);
}

.about-list {
    margin: 12px 0 0 20px;
    color: var(--text-muted);
}

.about-list li {
    margin-bottom: 8px;
}

.about-list-cols {
    columns: 2;
    column-gap: 24px;
}

.about-list-cols li {
    break-inside: avoid;
}

.about-features-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 16px;
    margin-top: 20px;
}

.about-feature {
    background: var(--surface2);
    border-radius: 10px;
    padding: 16px;
}

.about-feature h3 {
    font-size: 0.95rem;
    margin-bottom: 6px;
}

.about-feature p {
    font-size: 0.85rem;
    color: var(--text-muted);
}

.about-cards-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 16px;
    margin-top: 12px;
}

.about-card {
    background: var(--surface2);
    border-radius: 10px;
    padding: 20px;
}

.about-card h3 {
    margin-bottom: 8px;
}

.about-card p {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-bottom: 12px;
}

.about-link {
    font-size: 0.9rem;
    font-weight: 600;
}

.about-note {
    margin: 16px 0;
    font-size: 0.9rem;
    color: var(--text-muted);
    font-style: italic;
}

.about-cta {
    margin-top: 8px;
}

.about-steps {
    margin: 12px 0 20px 24px;
    color: var(--text-muted);
}

.about-steps li {
    margin-bottom: 8px;
}

.about-limits {
    border-color: var(--border);
    opacity: 0.9;
}
