:root {
    --primary: #6366f1;
    --primary-dark: #4f46e5;
    --secondary: #10b981;
    --accent: #f59e0b;
    --danger: #ef4444;
    --bg: #0f0f1a;
    --card: #1a1a2e;
    --border: #2d2d44;
    --text: #e2e8f0;
    --text-muted: #94a3b8;
    /* Tab bar (from design reference) */
    --tab-bar: #3d4d5e;
    --tab-active: #00c2a8;
    --tab-hover: #4a5d70;
    --tab-text: #ffffff;
}

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

body {
    font-family: 'Inter', sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 30px 20px;
}

.wrapper { width: 100%; max-width: 900px; }

header { text-align: center; margin-bottom: 24px; }
header img { max-height: 100px; }
header p { color: var(--text-muted); margin-top: 5px; font-size: 0.95rem; }

/* ===== Tab menu (connected bar like reference) ===== */
.tool-nav {
    display: flex;
    width: 100%;
    margin-bottom: 22px;
    background: var(--tab-bar);
    border-radius: 6px;
    overflow: hidden;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.25);
}

.tool-nav a {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 14px 12px;
    color: var(--tab-text);
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 600;
    background: var(--tab-bar);
    border: none;
    border-right: 1px solid rgba(255, 255, 255, 0.08);
    transition: background 0.2s ease;
    white-space: nowrap;
    text-align: center;
}

.tool-nav a:last-child { border-right: none; }

.tool-nav a:hover { background: var(--tab-hover); color: var(--tab-text); }

.tool-nav a.active {
    background: var(--tab-active);
    color: var(--tab-text);
}

.tool-nav a .badge-soon {
    font-size: 0.65rem;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: 4px;
    background: rgba(0, 0, 0, 0.25);
    letter-spacing: 0.02em;
}

.tool-nav a.active .badge-soon { background: rgba(255, 255, 255, 0.25); }

@media (max-width: 700px) {
    .tool-nav a {
        flex-direction: column;
        gap: 4px;
        padding: 12px 6px;
        font-size: 0.72rem;
    }
    .tool-nav a i { font-size: 1rem; }
}

/* Cards & shared UI */
.card {
    background: var(--card);
    border-radius: 16px;
    border: 1px solid var(--border);
    margin-bottom: 20px;
    overflow: hidden;
}

.card-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 10px;
}
.card-header i { color: var(--primary); }
.card-header h2 { font-size: 1rem; font-weight: 600; }
.card-body { padding: 20px; }

.upload-zone {
    border: 2px dashed var(--border);
    border-radius: 12px;
    padding: 40px 20px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s;
}
.upload-zone:hover, .upload-zone.dragover {
    border-color: var(--tab-active);
    background: rgba(0, 194, 168, 0.08);
}
.upload-zone i { font-size: 2.5rem; color: var(--tab-active); margin-bottom: 12px; }
.upload-zone p { color: var(--text-muted); font-size: 0.9rem; }

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

.form-group label {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 8px;
    font-size: 0.85rem;
    color: var(--text-muted);
}
.form-group label i { color: var(--tab-active); font-size: 0.8rem; }

select, input[type="number"] {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--bg);
    color: var(--text);
    font-size: 0.9rem;
}
select:focus, input:focus { outline: none; border-color: var(--tab-active); }

input[type="range"] {
    width: 100%;
    height: 6px;
    border-radius: 3px;
    background: var(--border);
    appearance: none;
    cursor: pointer;
}
input[type="range"]::-webkit-slider-thumb {
    appearance: none;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--tab-active);
    cursor: pointer;
}

.range-row { display: flex; align-items: center; gap: 10px; }
.range-value {
    min-width: 40px;
    text-align: center;
    font-weight: 600;
    color: var(--tab-active);
    font-size: 0.9rem;
}

.accordion-header {
    padding: 14px 20px;
    background: var(--bg);
    border-bottom: 1px solid var(--border);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.accordion-header:hover { background: rgba(0, 194, 168, 0.08); }
.accordion-header h3 {
    font-size: 0.9rem;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 8px;
}
.accordion-header i.fa-chevron-down { transition: transform 0.3s; }
.accordion-header.active i.fa-chevron-down { transform: rotate(180deg); }
.accordion-content { display: none; padding: 20px; background: rgba(0,0,0,0.2); }
.accordion-content.active { display: block; }

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 24px;
    border: none;
    border-radius: 10px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    width: 100%;
}
.btn-primary {
    background: linear-gradient(135deg, var(--tab-active), #00a892);
    color: white;
}
.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(0, 194, 168, 0.35);
}
.btn-primary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.progress-container { display: none; margin-top: 20px; }
.progress-container.active { display: block; }
.progress-bar { height: 8px; background: var(--border); border-radius: 4px; overflow: hidden; }
.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--tab-active), var(--secondary));
    border-radius: 4px;
    width: 0%;
    transition: width 0.3s;
}
.progress-text { text-align: center; margin-top: 10px; font-size: 0.85rem; color: var(--text-muted); }

.preview-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-top: 20px;
}
@media (max-width: 600px) { .preview-grid { grid-template-columns: 1fr; } }

.preview-box {
    background: var(--bg);
    border-radius: 10px;
    padding: 12px;
    text-align: center;
}
.preview-box h4 { font-size: 0.8rem; color: var(--text-muted); margin-bottom: 10px; }
.preview-image {
    width: 100%;
    max-height: 250px;
    object-fit: contain;
    border-radius: 8px;
    background: #000;
}
/* Jangan tampilkan ikon broken untuk src kosong */
.preview-image:not([src]),
.preview-image[src=""],
.preview-image.is-empty {
    display: none !important;
}
.preview-box.is-pending {
    display: none !important;
}
.preview-box.is-failed {
    display: block;
}
.preview-box.is-failed .preview-placeholder {
    display: flex;
    color: var(--text-muted);
    text-align: center;
    padding: 16px 8px;
}
.preview-box .preview-placeholder {
    display: none;
    min-height: 140px;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    font-size: 0.85rem;
    flex-direction: column;
    gap: 12px;
}
.preview-box.is-loading .preview-placeholder {
    display: flex;
}
.preview-box.is-loading .preview-image {
    display: none !important;
}
.preview-loader {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}
.preview-spinner {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 3px solid rgba(255, 255, 255, 0.12);
    border-top-color: var(--tab-active, #00c2a8);
    border-right-color: var(--tab-active, #00c2a8);
    animation: preview-spin 0.75s linear infinite;
}
.preview-status {
    font-size: 0.85rem;
    color: var(--text-muted);
    animation: preview-pulse 1.4s ease-in-out infinite;
}
.preview-box.is-failed .preview-spinner {
    display: none;
}
.preview-box.is-failed .preview-status {
    animation: none;
    color: var(--text-muted);
}
@keyframes preview-spin {
    to { transform: rotate(360deg); }
}
@keyframes preview-pulse {
    0%, 100% { opacity: 0.55; }
    50% { opacity: 1; }
}

#resultCard { display: none; }
#resultCard.active { display: block; }

.stats-row { display: flex; gap: 15px; margin-bottom: 20px; flex-wrap: wrap; }
.stat-item {
    flex: 1;
    min-width: 80px;
    background: var(--bg);
    padding: 12px;
    border-radius: 10px;
    text-align: center;
}
.stat-item .value { font-size: 1.3rem; font-weight: 700; color: var(--tab-active); }
.stat-item .label { font-size: 0.75rem; color: var(--text-muted); margin-top: 4px; }

.download-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 14px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 10px;
    color: var(--text);
    text-decoration: none;
    transition: all 0.3s;
}
.download-btn:hover {
    border-color: var(--tab-active);
    background: rgba(0, 194, 168, 0.1);
}
.download-btn i { font-size: 1.2rem; color: var(--tab-active); }

.coming-soon { text-align: center; padding: 48px 24px; }
.coming-soon .icon-wrap {
    width: 72px; height: 72px;
    margin: 0 auto 18px;
    border-radius: 18px;
    display: flex; align-items: center; justify-content: center;
    background: rgba(0, 194, 168, 0.12);
    border: 1px solid var(--border);
}
.coming-soon .icon-wrap i { font-size: 1.8rem; color: var(--tab-active); }
.coming-soon h3 { font-size: 1.15rem; margin-bottom: 8px; }
.coming-soon p {
    color: var(--text-muted);
    font-size: 0.9rem;
    max-width: 420px;
    margin: 0 auto 18px;
    line-height: 1.5;
}
.feature-list {
    display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-top: 8px;
}
.feature-list span {
    font-size: 0.75rem;
    padding: 6px 10px;
    border-radius: 8px;
    background: var(--bg);
    border: 1px solid var(--border);
    color: var(--text-muted);
}

footer {
    margin-top: 30px;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.8rem;
}

/* OCR */
.ocr-textarea {
    width: 100%;
    min-height: 220px;
    padding: 14px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--bg);
    color: var(--text);
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 0.9rem;
    line-height: 1.5;
    resize: vertical;
}
.ocr-textarea:focus {
    outline: none;
    border-color: var(--tab-active);
}
.ocr-actions {
    display: flex;
    gap: 12px;
    margin-top: 14px;
    flex-wrap: wrap;
}
.btn-secondary {
    background: var(--bg);
    color: var(--text);
    border: 1px solid var(--border);
    width: auto;
    min-width: 120px;
    padding: 14px 20px;
}
.btn-secondary:hover {
    border-color: var(--tab-active);
    background: rgba(0, 194, 168, 0.1);
}

/* Compress */
.cmp-checks {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding-top: 4px;
}
.cmp-checks .chk {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.85rem;
    color: var(--text-muted);
    cursor: pointer;
}
.cmp-checks input { accent-color: var(--tab-active); width: 16px; height: 16px; }
.cmp-meta {
    margin-top: 8px;
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* BG Remover checkerboard */
.checkerboard {
    border-radius: 8px;
    overflow: hidden;
    background-color: #ccc;
    background-image:
        linear-gradient(45deg, #999 25%, transparent 25%),
        linear-gradient(-45deg, #999 25%, transparent 25%),
        linear-gradient(45deg, transparent 75%, #999 75%),
        linear-gradient(-45deg, transparent 75%, #999 75%);
    background-size: 16px 16px;
    background-position: 0 0, 0 8px, 8px -8px, -8px 0;
}
.checkerboard .preview-image {
    background: transparent;
    display: block;
}

/* Word2PDF direction tabs */
.direction-tabs {
    display: flex;
    gap: 0;
    background: var(--tab-bar);
    border-radius: 6px;
    overflow: hidden;
}
.direction-tabs .dir-tab {
    flex: 1;
    border: none;
    background: transparent;
    color: #fff;
    padding: 12px 10px;
    font-family: inherit;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}
.direction-tabs .dir-tab:hover { background: var(--tab-hover); }
.direction-tabs .dir-tab.active { background: var(--tab-active); }

@media (max-width: 800px) {
    .tool-nav a span { font-size: 0.68rem; }
    .tool-nav a { padding: 10px 4px; gap: 4px; }
}

/* Auth / quota */
.header-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
}
.header-brand { text-align: left; }
.header-brand img,
.header-brand .brand-logo { display: block; height: auto; max-height: none; }
.header-brand .brand-title {
    font-size: 1.75rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    color: var(--text);
    line-height: 1.2;
}
.header-brand .brand-tagline,
.header-brand p {
    color: var(--text-muted);
    margin-top: 5px;
    font-size: 0.9rem;
}
.header-brand .brand-logo + .brand-title { margin-top: 8px; }
.header-brand .brand-title + .brand-tagline { margin-top: 4px; }

.brand-home {
    display: inline-flex;
    line-height: 0;
    text-decoration: none;
}

.seo-intro {
    margin: 0 0 16px;
    padding: 14px 16px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border, rgba(255, 255, 255, 0.08));
}
.seo-intro h1 {
    margin: 0;
    font-size: 1.15rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    color: var(--text);
    line-height: 1.35;
}
.seo-intro p {
    margin: 6px 0 0;
    font-size: 0.88rem;
    line-height: 1.5;
    color: var(--text-muted, #8aa0b8);
}

.auth-box {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: flex-end;
}
/* Shared control size for header actions */
.auth-box .quota-pill,
.auth-box .btn-mini,
.auth-box .btn-google {
    box-sizing: border-box;
    height: 36px;
    min-height: 36px;
    padding: 0 14px;
    border-radius: 10px;
    font-size: 0.8125rem;
    font-weight: 600;
    line-height: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    text-decoration: none;
    white-space: nowrap;
    transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}
.quota-pill {
    background: rgba(0,194,168,0.1);
    border: 1px solid rgba(0,194,168,0.35);
    color: var(--tab-active);
}
.quota-pill i { font-size: 0.85rem; opacity: 0.95; }
.quota-pill.paid {
    background: rgba(245,158,11,0.12);
    border-color: rgba(245,158,11,0.4);
    color: #f59e0b;
}
.user-chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    height: 36px;
    padding: 0 6px 0 4px;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 10px;
    font-size: 0.8125rem;
    max-width: 280px;
}
.user-chip > span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 140px;
}
.user-chip .avatar { width: 28px; height: 28px; border-radius: 8px; flex-shrink: 0; }
.user-chip .btn-mini {
    height: 28px;
    min-height: 28px;
    padding: 0 10px;
    font-size: 0.75rem;
}
.btn-mini {
    background: var(--tab-active);
    border: 1px solid transparent;
    color: #042;
    font: inherit;
    cursor: pointer;
}
.btn-mini:hover { filter: brightness(1.05); }
.btn-mini.ghost {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-muted);
}
.btn-mini.ghost:hover {
    border-color: var(--tab-active);
    color: var(--text);
}
.btn-google {
    background: #fff;
    border: 1px solid #e5e7eb;
    color: #1f2937;
}
.btn-google:hover { background: #f8fafc; }
.btn-google i { color: #ea4335; font-size: 0.95rem; }
@media (max-width: 640px) {
    .auth-box { width: 100%; justify-content: flex-start; }
    .user-chip { max-width: 100%; }
    .user-chip > span { max-width: 120px; }
}

.modal-overlay {
    position: fixed; inset: 0;
    background: rgba(0,0,0,0.65);
    display: flex; align-items: center; justify-content: center;
    z-index: 1000;
    padding: 20px;
}
.modal-overlay[hidden] { display: none !important; }
.modal-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 28px;
    max-width: 420px;
    width: 100%;
    text-align: center;
}
.modal-card h3 { margin-bottom: 10px; }
.modal-card p { color: var(--text-muted); font-size: 0.95rem; line-height: 1.5; margin-bottom: 18px; }
.modal-actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.modal-close {
    margin-top: 14px;
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 0.85rem;
}

.pricing-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
    align-items: stretch;
}
.price-card {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 22px;
    position: relative;
    display: flex;
    flex-direction: column;
    height: 100%;
    min-height: 100%;
}
.price-card.featured { border-color: var(--tab-active); box-shadow: 0 0 0 1px rgba(0,194,168,0.3); }
.price-card .badge {
    position: absolute; top: 12px; right: 12px;
    background: var(--tab-active); color: #fff;
    font-size: 0.7rem; padding: 3px 8px; border-radius: 999px; font-weight: 700;
}
.price-card h3 { margin: 0; }
.price-card .price { font-size: 1.6rem; font-weight: 700; color: var(--tab-active); margin: 8px 0; }
.price-card .muted { min-height: 1.2em; }
.price-card ul {
    list-style: none;
    margin: 14px 0 0;
    padding: 0;
    color: var(--text-muted);
    font-size: 0.9rem;
    flex: 1 1 auto;
}
.price-card li { margin: 6px 0; }
.price-card li::before { content: "✓ "; color: var(--tab-active); }
.price-card > .btn,
.price-card > a.btn,
.price-card > button.btn {
    margin-top: 18px;
    align-self: stretch;
    text-align: center;
    justify-content: center;
}
.alert { padding: 12px; border-radius: 10px; margin-bottom: 14px; font-size: 0.9rem; }
.alert.error { background: rgba(239,68,68,0.15); border: 1px solid rgba(239,68,68,0.4); }
.alert.ok { background: rgba(16,185,129,0.15); border: 1px solid rgba(16,185,129,0.4); }
.muted { color: var(--text-muted); }

/* Footer legal links */
footer .footer-links {
    margin-top: 8px;
    display: flex;
    gap: 10px;
    justify-content: center;
    flex-wrap: wrap;
    font-size: 0.8rem;
}
footer .footer-links a {
    color: var(--text-muted);
    text-decoration: none;
}
footer .footer-links a:hover {
    color: var(--tab-active);
}

/* Legal pages */
.legal-body {
    line-height: 1.65;
    color: var(--text);
    font-size: 0.95rem;
}
.legal-body h3 {
    margin: 22px 0 8px;
    font-size: 1.05rem;
    color: var(--tab-active);
}
.legal-body p, .legal-body ul {
    color: var(--text-muted);
    margin-bottom: 10px;
}
.legal-body ul {
    padding-left: 1.2rem;
}
.legal-body li { margin: 6px 0; }
.legal-updated {
    font-size: 0.8rem !important;
    margin-bottom: 18px !important;
}
.legal-nav {
    margin-top: 28px !important;
}
.legal-nav a {
    color: var(--tab-active);
    text-decoration: none;
    font-weight: 600;
}
.legal-nav a:hover { text-decoration: underline; }
.pricing-grid-3 {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}
@media (max-width: 900px) {
  .pricing-grid-3 { grid-template-columns: 1fr; }
}
.gateway-pick select {
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 8px;
  padding: 8px 12px;
  font: inherit;
  min-width: 200px;
}
