:root {
    --tp-cyan: #00ced1;
    --tp-cyan-dark: #1db9c3;
    --tp-ink: #333333;
    --tp-muted: #666666;
    --tp-muted-2: #555555;
    --bg: #ffffff;
    --surface: #ffffff;
    --ink: #333333;
    --muted: #666666;
    --line: rgba(0, 0, 0, 0.1);
    --line-strong: rgba(0, 0, 0, 0.15);
    --primary: #00ced1;
    --primary-hover: #1db9c3;
    --primary-soft: rgba(0, 206, 209, 0.08);
    --primary-glow: rgba(0, 206, 209, 0.25);
    --danger: #c0392b;
    --success: #1db9c3;
    --shadow-sm: 0 2px 10px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 8px 24px rgba(0, 206, 209, 0.12);
    --radius: 12px;
    --topbar-h: 56px;
    --toolbar-h: 72px;
}

* {
    box-sizing: border-box;
}

html, body {
    margin: 0;
    min-height: 100%;
    font-family: 'Inter', "Segoe UI", system-ui, sans-serif;
    color: var(--ink);
    background: var(--bg);
}

button, input, select {
    font: inherit;
}

.hidden {
    display: none !important;
}

/* ── Brand TechPulse ── */
.brand {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
    color: inherit;
}

.brand-logo {
    height: 36px;
    width: auto;
    display: block;
}

.brand.compact .brand-logo {
    height: 30px;
}

.brand-copy {
    display: flex;
    flex-direction: column;
    line-height: 1.15;
}

.brand-app {
    font-size: 1rem;
    font-weight: 700;
    color: var(--tp-ink);
}

.brand.compact .brand-app {
    font-size: 0.92rem;
}

.brand-by {
    font-size: 0.72rem;
    color: var(--tp-muted);
    letter-spacing: 0.02em;
}

.brand-by strong {
    color: var(--tp-cyan);
    font-weight: 600;
    text-transform: lowercase;
}

/* ── Ad slots ── */
.page-layout {
    display: block;
    width: 100%;
}

.page-layout.has-ads {
    display: flex;
    align-items: flex-start;
    justify-content: center;
    gap: 20px;
}

.page-layout--editor {
    display: flex;
    flex: 1;
    min-height: 0;
    align-items: stretch;
}

.page-layout--editor.has-ads {
    justify-content: center;
    gap: 20px;
}

.ad-rail {
    display: none;
    width: 160px;
    flex-shrink: 0;
    padding: 16px 0;
    position: sticky;
    top: 16px;
    align-self: flex-start;
    min-height: 600px;
}

.ad-slot--bottom.ad-strip,
.ad-slot.ad-strip {
    width: 100%;
    display: flex;
    justify-content: center;
    padding: 12px 16px;
    background: #fff;
    border-top: 1px solid var(--line);
}

.ad-slot {
    overflow: hidden;
}

.ad-slot ins.adsbygoogle,
.ad-slot iframe {
    display: block;
    margin: 0 auto;
    max-width: 100%;
}

.ad-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 250px;
    padding: 16px;
    border: 2px dashed rgba(0, 206, 209, 0.45);
    border-radius: 12px;
    background: rgba(0, 206, 209, 0.05);
    color: var(--tp-muted);
    font-size: 0.78rem;
    text-align: center;
    line-height: 1.4;
}

.ad-slot--bottom .ad-placeholder {
    width: min(728px, 100%);
    min-height: 90px;
}

.ad-slot--side_left.ad-rail .ad-placeholder,
.ad-slot--side_right.ad-rail .ad-placeholder {
    min-height: 600px;
    width: 160px;
}

@media (min-width: 1280px) {
    .ad-rail {
        display: block;
    }
}

@media (max-width: 1279px) {
    .ad-slot--side_left.ad-rail,
    .ad-slot--side_right.ad-rail {
        display: none;
    }
}

/* ── Landing ── */
body.view-landing {
    background: #ffffff;
}

body.view-landing .page-layout--landing {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 16px;
}

body.view-landing .ad-slot.ad-strip {
    max-width: 1400px;
    margin: 0 auto;
    border-top: 0;
    background: transparent;
}

.landing {
    min-height: 100vh;
}

.top-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.25rem 2rem;
    max-width: 1200px;
    margin: 0 auto;
    border-bottom: 1px solid var(--line);
    box-shadow: var(--shadow-sm);
    background: #fff;
}

.nav-actions {
    display: flex;
    gap: 12px;
}

.nav-btn {
    padding: 9px 16px;
    border-radius: 8px;
    font-size: 0.92rem;
    cursor: pointer;
    background: transparent;
    text-decoration: none;
    display: inline-block;
    transition: color 0.2s ease;
}

.nav-btn.ghost {
    border: 0;
    color: var(--tp-muted);
}

.nav-btn.ghost:hover {
    color: var(--tp-cyan);
}

.nav-btn.outline {
    border: 1px solid var(--line-strong);
    color: var(--tp-ink);
    background: var(--surface);
}

.landing-main {
    max-width: 720px;
    margin: 0 auto;
    padding: 3rem 24px 5rem;
    text-align: center;
    position: relative;
}

.landing-main::before {
    content: '';
    position: absolute;
    inset: 0;
    background: radial-gradient(circle at 50% 20%, rgba(0, 206, 209, 0.06) 0%, transparent 65%);
    pointer-events: none;
}

.landing-main h1 {
    position: relative;
    z-index: 1;
    margin: 0;
    font-size: clamp(1.75rem, 4vw, 2.35rem);
    font-weight: 700;
    line-height: 1.2;
    color: var(--tp-ink);
}

.landing-sub {
    position: relative;
    z-index: 1;
    margin: 14px auto 36px;
    max-width: 480px;
    color: var(--tp-muted);
    font-size: 1.05rem;
    line-height: 1.5;
}

.upload-card {
    position: relative;
    z-index: 1;
    background: var(--surface);
    border-radius: 16px;
    box-shadow: var(--shadow-md);
    padding: 8px;
    border: 1px solid var(--line);
}

.file-input-hidden {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
    z-index: 5;
}

.dropzone {
    display: block;
    cursor: pointer;
    position: relative;
    overflow: hidden;
}

.dropzone > :not(.file-input-hidden) {
    position: relative;
    z-index: 1;
    pointer-events: none;
}

.dropzone {
    border: 2px dashed rgba(0, 206, 209, 0.35);
    border-radius: 14px;
    padding: 48px 32px 36px;
    text-align: center;
    transition: border-color 0.2s, background 0.2s, box-shadow 0.2s;
}

.dropzone:hover,
.dropzone.dragover {
    border-color: var(--primary);
    background: var(--primary-soft);
    box-shadow: 0 8px 20px var(--primary-glow);
}

.dropzone-icon {
    color: var(--tp-cyan);
    margin-bottom: 16px;
}

.dropzone strong {
    display: block;
    font-size: 1.1rem;
    margin-bottom: 18px;
    color: var(--tp-ink);
}

.btn-browse {
    display: inline-block;
    padding: 12px 28px;
    border: 0;
    border-radius: 8px;
    background: var(--primary);
    color: #fff;
    font-weight: 600;
    font-size: 0.95rem;
    cursor: pointer;
    transition: background 0.2s, transform 0.2s, box-shadow 0.2s;
}

.btn-browse:hover {
    background: var(--primary-hover);
    transform: translateY(-2px);
    box-shadow: 0 8px 20px var(--primary-glow);
}

.upload-hint {
    display: block;
    margin-top: 20px;
    font-size: 0.82rem;
    color: var(--tp-muted);
}

.status {
    min-height: 1.3rem;
    margin: 12px 16px 8px;
    font-size: 0.9rem;
    color: var(--tp-muted);
}

.status.error { color: var(--danger); }
.status.success { color: var(--success); }

.landing-faq {
    position: relative;
    z-index: 1;
    width: min(720px, 100%);
    margin: 2.5rem auto 0;
    text-align: left;
}

.landing-faq h2 {
    margin: 0 0 1rem;
    font-size: 1.25rem;
    color: var(--tp-ink);
}

.landing-faq details {
    margin-bottom: 0.75rem;
    padding: 0.9rem 1rem;
    background: rgba(255, 255, 255, 0.82);
    border: 1px solid var(--line);
    border-radius: 10px;
}

.landing-faq summary {
    cursor: pointer;
    font-weight: 600;
    color: var(--tp-ink);
}

.landing-faq p {
    margin: 0.75rem 0 0;
    color: var(--tp-muted);
    line-height: 1.55;
}

.landing-footer {
    position: relative;
    z-index: 1;
    margin-top: 2rem;
    font-size: 0.85rem;
    color: var(--tp-muted);
}

.landing-footer a {
    color: var(--tp-cyan);
    font-weight: 600;
    text-decoration: none;
}

.landing-footer a:hover {
    color: var(--tp-cyan-dark);
}

/* ── Editor shell ── */
body.view-editor {
    overflow: hidden;
    height: 100vh;
}

.editor-app {
    display: flex;
    flex-direction: column;
    height: 100vh;
    background: #f5f7f8;
}

.editor-app .page-layout--editor {
    background: #f5f7f8;
}

.editor-app .ad-slot.ad-strip {
    flex-shrink: 0;
}

.editor-topbar {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    height: var(--topbar-h);
    padding: 0 16px;
    background: var(--surface);
    border-bottom: 1px solid var(--line);
    box-shadow: var(--shadow-sm);
    flex-shrink: 0;
}

.topbar-left { justify-self: start; }
.topbar-center { justify-self: center; min-width: 0; }
.topbar-right {
    justify-self: end;
    display: flex;
    align-items: center;
    gap: 6px;
}

.doc-title {
    font-size: 0.9rem;
    color: var(--tp-muted);
    max-width: 320px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.topbar-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface);
    color: var(--tp-ink);
    font-size: 0.85rem;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.topbar-btn:hover {
    background: var(--primary-soft);
    border-color: rgba(0, 206, 209, 0.35);
    color: var(--tp-cyan-dark);
}

.topbar-btn.icon-only {
    padding: 7px 9px;
}

.btn-done {
    padding: 8px 22px;
    border: 0;
    border-radius: 8px;
    background: var(--primary);
    color: #fff;
    font-weight: 700;
    font-size: 0.85rem;
    letter-spacing: 0.04em;
    cursor: pointer;
    transition: background 0.2s, transform 0.2s, box-shadow 0.2s;
}

.btn-done:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
    box-shadow: 0 8px 20px var(--primary-glow);
}

.btn-done:disabled {
    opacity: 0.6;
    cursor: wait;
    transform: none;
    box-shadow: none;
}

/* ── Toolbar ── */
.editor-toolbar {
    display: flex;
    align-items: center;
    gap: 4px;
    height: var(--toolbar-h);
    padding: 0 12px;
    background: var(--surface);
    border-bottom: 1px solid var(--line);
    overflow-x: auto;
    flex-shrink: 0;
}

.toolbar-group {
    display: flex;
    align-items: center;
    gap: 2px;
}

.toolbar-group.scrollable {
    flex: 1;
    overflow-x: auto;
}

.toolbar-divider {
    width: 1px;
    height: 36px;
    background: var(--line);
    margin: 0 8px;
    flex-shrink: 0;
}

.tool-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    min-width: 62px;
    padding: 8px 6px;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: var(--tp-muted);
    font-size: 0.68rem;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
    flex-shrink: 0;
}

.tool-btn:hover:not(:disabled) {
    background: var(--primary-soft);
    color: var(--tp-ink);
}

.tool-btn.active {
    color: var(--tp-cyan);
}

.tool-btn.active svg {
    stroke: var(--tp-cyan);
}

.tool-btn:disabled {
    opacity: 0.45;
    cursor: default;
}

.toolbar-hint {
    margin: 0 12px 0 auto;
    font-size: 0.82rem;
    color: var(--tp-muted);
    white-space: nowrap;
}

/* ── Editor body ── */
.editor-body {
    display: flex;
    flex: 1;
    min-height: 0;
}

.sidebar-left {
    width: 48px;
    background: var(--surface);
    border-right: 1px solid var(--line);
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 10px 0;
    gap: 4px;
    flex-shrink: 0;
}

.side-btn {
    width: 36px;
    height: 36px;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: var(--tp-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.side-btn.active {
    background: var(--primary-soft);
    color: var(--tp-cyan);
}

.side-btn:disabled {
    opacity: 0.4;
    cursor: default;
}

.workspace {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    position: relative;
}

.page-strip {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px 0;
}

.page-badge {
    font-size: 0.82rem;
    color: var(--tp-muted);
    font-weight: 600;
}

.page-count {
    font-size: 0.82rem;
    color: var(--tp-muted);
}

.canvas-wrap {
    flex: 1;
    overflow: auto;
    padding: 20px 24px 72px;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    background: #eef1f2;
}

.pdf-pages {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 24px;
    width: 100%;
    min-height: 200px;
}

.pdf-loading,
.pdf-error {
    margin: 80px auto;
    padding: 16px 24px;
    background: #fff;
    border-radius: 10px;
    color: var(--tp-muted);
    box-shadow: var(--shadow-sm);
}

.pdf-error {
    color: var(--danger);
    border: 1px solid rgba(192, 57, 43, 0.3);
}

.pdf-page {
    position: relative;
    background: #fff;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12);
    flex-shrink: 0;
}

.pdf-page canvas {
    display: block;
}

.text-layer {
    position: absolute;
    inset: 0;
    overflow: hidden;
    pointer-events: none;
}

.text-layer.editing {
    pointer-events: auto;
}

.text-edit {
    position: absolute;
    color: transparent;
    white-space: pre;
    line-height: 1;
    padding: 1px 3px;
    margin: 0;
    border: 1px solid transparent;
    border-radius: 2px;
    outline: none;
    cursor: text;
    background: transparent;
    caret-color: var(--tp-ink);
    box-sizing: content-box;
}

.text-layer.editing .text-edit:hover {
    color: var(--tp-ink);
    background: rgba(255, 255, 255, 0.92);
    border-color: rgba(0, 206, 209, 0.4);
}

.text-edit.modified {
    color: var(--tp-ink);
    background: #fff;
    z-index: 3;
}

.text-edit.active,
.text-layer.editing .text-edit:focus {
    color: var(--tp-ink);
    background: #fff;
    border-color: var(--primary);
    box-shadow: 0 0 0 2px var(--primary-glow);
    z-index: 5;
}

.text-edit.modified.active,
.text-edit.modified:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px var(--primary-glow);
}

.highlight-layer {
    position: absolute;
    inset: 0;
    z-index: 4;
    pointer-events: none;
}

.pdf-page.highlight-mode .highlight-layer {
    pointer-events: auto;
    cursor: crosshair;
}

.pdf-page.highlight-mode .text-layer {
    pointer-events: none;
}

.highlight-box {
    position: absolute;
    background: rgba(255, 235, 59, 0.48);
    border-radius: 2px;
    pointer-events: auto;
    mix-blend-mode: multiply;
}

.highlight-box.drawing-preview {
    background: rgba(255, 235, 59, 0.35);
    border: 1px dashed rgba(180, 140, 0, 0.55);
    pointer-events: none;
}

.tool-btn[data-tool="highlight"].active svg path:first-child {
    fill: #FFEB3B;
}

.zoom-bar {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 6px 10px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 10px;
    box-shadow: var(--shadow-sm);
}

.zoom-btn,
.zoom-fit {
    border: 0;
    background: transparent;
    color: var(--tp-ink);
    cursor: pointer;
    border-radius: 6px;
    padding: 4px 8px;
    font-size: 0.95rem;
}

.zoom-btn:hover,
.zoom-fit:hover {
    background: var(--primary-soft);
    color: var(--tp-cyan-dark);
}

.zoom-label {
    min-width: 48px;
    text-align: center;
    font-size: 0.85rem;
    color: var(--tp-muted);
}

.zoom-fit {
    margin-left: 4px;
    font-size: 0.82rem;
    color: var(--tp-cyan);
    font-weight: 600;
}

.editor-toast {
    position: absolute;
    bottom: 68px;
    left: 50%;
    transform: translateX(-50%);
    margin: 0;
    padding: 10px 18px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 10px;
    box-shadow: var(--shadow-sm);
    font-size: 0.88rem;
    color: var(--tp-muted);
    max-width: min(520px, 90%);
    text-align: center;
    z-index: 10;
}

.editor-toast.error {
    color: var(--danger);
    border-color: rgba(192, 57, 43, 0.3);
    background: rgba(192, 57, 43, 0.08);
}

.editor-toast.success {
    color: var(--tp-cyan-dark);
    border-color: rgba(0, 206, 209, 0.35);
    background: var(--primary-soft);
}

/* ── Responsive ── */
@media (max-width: 900px) {
    .doc-title {
        max-width: 140px;
    }

    .toolbar-hint {
        display: none;
    }

    .brand-copy {
        display: none;
    }

    .topbar-btn span,
    .topbar-btn:not(.icon-only) svg + * {
        display: none;
    }
}

@media (max-width: 600px) {
    .top-nav {
        padding: 14px 16px;
    }

    .nav-actions {
        display: none;
    }

    .editor-topbar {
        grid-template-columns: auto 1fr auto;
        gap: 8px;
    }
}
