:root {
    --bg: #f8fafc;
    --surface: #ffffff;
    --surface-soft: #f8fbff;
    --text: #0f172a;
    --muted: #64748b;
    --border: rgba(15, 23, 42, 0.08);
    --shadow: 0 4px 16px rgba(0, 0, 0, 0.06);
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --green: #22c55e;
    --red: #ef4444;
    --warning: #facc15;
    --change: rgba(250, 204, 21, 0.22);
    --add: rgba(34, 197, 94, 0.16);
    --delete: rgba(239, 68, 68, 0.16);
    --equal: rgba(148, 163, 184, 0.14);
    --radius-card: 16px;
    --radius-btn: 12px;
    --radius-input: 12px;
}

* {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    margin: 0;
    min-height: 100vh;
    background:
        radial-gradient(circle at top left, rgba(37, 99, 235, 0.08), transparent 30%),
        radial-gradient(circle at top right, rgba(34, 197, 94, 0.08), transparent 24%),
        linear-gradient(180deg, #ffffff 0%, #f8fafc 18%, #f8fafc 100%);
    color: var(--text);
    font-family: "Inter", "Segoe UI", sans-serif;
}

body.theme-dark {
    --bg: #0f172a;
    --surface: #111827;
    --surface-soft: #0b1220;
    --text: #e5e7eb;
    --muted: #94a3b8;
    --border: rgba(148, 163, 184, 0.16);
    --shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
    --primary: #60a5fa;
    --primary-hover: #3b82f6;
    --change: rgba(250, 204, 21, 0.18);
    --add: rgba(34, 197, 94, 0.14);
    --delete: rgba(239, 68, 68, 0.14);
    --equal: rgba(148, 163, 184, 0.12);
    background:
        radial-gradient(circle at top left, rgba(96, 165, 250, 0.14), transparent 30%),
        radial-gradient(circle at top right, rgba(34, 197, 94, 0.08), transparent 24%),
        linear-gradient(180deg, #0b1220 0%, #0f172a 22%, #0f172a 100%);
}

body.theme-dark .topbar {
    background: rgba(15, 23, 42, 0.92);
    border-bottom-color: rgba(148, 163, 184, 0.14);
}

body.theme-dark .brand-mark,
body.theme-dark .icon-chip,
body.theme-dark .ghost-btn,
body.theme-dark .editor-card,
body.theme-dark .sidebar-card,
body.theme-dark .result-card,
body.theme-dark .results-summary,
body.theme-dark .legend-bar,
body.theme-dark .tip-box,
body.theme-dark .empty-state,
body.theme-dark .footer-note {
    background: var(--surface);
}

body.theme-dark .hero h1,
body.theme-dark .sidebar-title,
body.theme-dark .card-title,
body.theme-dark .result-title,
body.theme-dark .empty-hero,
body.theme-dark .results-head h2,
body.theme-dark .summary-chip strong,
body.theme-dark .summary-chip span,
body.theme-dark .brand-title,
body.theme-dark .brand-subtitle,
body.theme-dark .tip-title,
body.theme-dark .tip-box p,
body.theme-dark .footer-note,
body.theme-dark .filter-list label,
body.theme-dark .card-subtitle,
body.theme-dark .editor-meta,
body.theme-dark .hero p,
body.theme-dark .results-head p,
body.theme-dark .legend-bar,
body.theme-dark .empty-sub,
body.theme-dark .stepper,
body.theme-dark .outline-action,
body.theme-dark .icon-action {
    color: var(--text);
}

body.theme-dark .editor,
body.theme-dark .summary-chip.gray,
body.theme-dark .results-summary > div,
body.theme-dark .icon-action,
body.theme-dark .mini-btn,
body.theme-dark .ghost-btn,
body.theme-dark .icon-chip {
    background: rgba(15, 23, 42, 0.7);
    border-color: var(--border);
    color: var(--text);
}

body.theme-dark .editor::placeholder {
    color: #94a3b8;
}

body.theme-dark .compare-btn {
    box-shadow: 0 16px 30px rgba(96, 165, 250, 0.22);
}

body.theme-dark .result-scroll {
    background: #0b1220;
    border-color: rgba(148, 163, 184, 0.12);
}

body.theme-dark .diff-row.equal {
    background: rgba(148, 163, 184, 0.06);
}

body.theme-dark .diff-row.added {
    background: #13382b;
}

body.theme-dark .diff-row.deleted {
    background: #3a1f27;
}

body.theme-dark .diff-row.changed {
    background: #443b19;
}

body.theme-dark .diff-line-number {
    color: #94a3b8;
}

body.theme-dark .diff-line-body {
    color: #e5e7eb;
}

body.theme-dark .inline-added,
body.theme-dark .inline-deleted {
    color: #0f172a;
}

body.theme-dark .inline-added {
    background: #86efac;
    color: #052e16;
}

body.theme-dark .inline-deleted {
    background: #fca5a5;
    color: #450a0a;
}

body.theme-dark .menu-divider {
    opacity: 0.45;
}

button,
input,
textarea {
    font: inherit;
}

.app-shell {
    width: 100%;
    min-height: 100vh;
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 20;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    padding: 14px 20px;
    background: rgba(255, 255, 255, 0.88);
    -webkit-backdrop-filter: blur(18px);
    backdrop-filter: blur(18px);
    border-bottom: 1px solid rgba(15, 23, 42, 0.07);
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
}

.brand-mark {
    width: 40px;
    height: 40px;
    display: grid;
    place-items: center;
    border-radius: 8px;
    background: var(--primary);
    color: #fff;
    font-size: 18px;
    box-shadow: 0 10px 22px rgba(37, 99, 235, 0.22);
}

.brand-mark img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
    margin: 0;
}

.brand-title {
    font-size: 18px;
    line-height: 1.1;
    font-weight: 800;
}

.brand-subtitle {
    margin-top: 2px;
    color: var(--muted);
    font-size: 12px;
    font-weight: 500;
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

.icon-chip,
.ghost-btn,
.mini-btn,
.outline-action,
.compare-btn {
    border: 0;
    border-radius: var(--radius-btn);
    transition: transform 180ms ease, background-color 180ms ease, color 180ms ease, box-shadow 180ms ease, border-color 180ms ease;
}

.icon-chip {
    width: 34px;
    height: 34px;
    display: grid;
    place-items: center;
    background: #fff;
    color: #111827;
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
}

.ghost-btn {
    padding: 8px 14px;
    background: #fff;
    color: #111827;
    border: 1px solid rgba(15, 23, 42, 0.08);
    box-shadow: 0 1px 0 rgba(255, 255, 255, 0.8), var(--shadow);
    font-weight: 600;
    font-size: 14px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
}

.ghost-btn:link,
.ghost-btn:visited,
.ghost-btn:hover,
.ghost-btn:focus,
.ghost-btn:active {
    text-decoration: none;
}

.main-wrap {
    width: min(1240px, calc(100% - 32px));
    margin: 0 auto;
    padding: 14px 0 20px;
}

.hero {
    padding: 24px 0 18px;
    text-align: center;
}

.hero h1 {
    margin: 0;
    font-size: clamp(30px, 3.2vw, 46px);
    line-height: 1.1;
    font-weight: 800;
    letter-spacing: -0.03em;
}

.hero p {
    margin: 8px 0 0;
    color: var(--muted);
    font-size: 16px;
}

.stepper {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 10px 24px;
    margin-top: 20px;
    color: #475569;
    font-size: 13px;
    font-weight: 600;
}

.stepper span {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.stepper .active {
    color: var(--primary);
}

.compare-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 282px;
    gap: 16px;
    align-items: start;
}

.compare-main {
    min-width: 0;
}

.editor-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 18px;
    align-items: start;
}

.editor-card,
.sidebar-card,
.result-card,
.empty-state,
.results-summary,
.legend-bar,
.tip-box {
    background: var(--surface);
    border: 1px solid rgba(15, 23, 42, 0.07);
    border-radius: var(--radius-card);
    box-shadow: var(--shadow);
}

.editor-card {
    padding: 18px;
    min-height: 300px;
}

.card-head,
.result-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
}

.card-title,
.result-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 15px;
    font-weight: 800;
}

.card-subtitle {
    margin-top: 2px;
    color: var(--muted);
    font-size: 12px;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 999px;
    display: inline-block;
}

.status-dot.blue {
    background: var(--primary);
}

.status-dot.green {
    background: var(--green);
}

.mini-btn,
.outline-action {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 9px 12px;
    border: 1px solid rgba(15, 23, 42, 0.1);
    background: #fff;
    color: #111827;
    font-size: 13px;
    font-weight: 600;
}

.editor {
    width: 100%;
    min-height: 250px;
    resize: vertical;
    border: 1px solid rgba(148, 163, 184, 0.26);
    border-radius: var(--radius-input);
    padding: 16px 16px 14px;
    outline: none;
    color: #0f172a;
    background: #fff;
    font-size: 15px;
    line-height: 1.7;
    white-space: pre;
    word-break: normal;
    overflow-wrap: normal;
    overflow-x: auto;
    overflow-y: auto;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.85);
}

.richtext-page .editor.rich-editor {
    white-space: pre-wrap;
    word-break: break-word;
    overflow-wrap: anywhere;
    overflow-x: hidden;
    overflow-y: auto;
}

.richtext-page .rich-editor p,
.richtext-page .rich-editor ul,
.richtext-page .rich-editor ol {
    margin: 0 0 0.45em;
}

.richtext-page .rich-editor p:last-child,
.richtext-page .rich-editor ul:last-child,
.richtext-page .rich-editor ol:last-child {
    margin-bottom: 0;
}

.richtext-page .rich-editor mark {
    background: #fde68a;
    border-radius: 4px;
    padding: 0 2px;
}

.richtext-page .rich-editor.is-empty::before {
    content: attr(data-placeholder);
    color: #94a3b8;
    pointer-events: none;
}

.rich-tools {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

.rich-tool-btn {
    width: 30px;
    height: 30px;
    border: 1px solid rgba(15, 23, 42, 0.12);
    border-radius: 8px;
    background: #fff;
    color: #334155;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
}

.rich-tool-btn:hover {
    border-color: rgba(37, 99, 235, 0.35);
    color: #1d4ed8;
}

body.theme-dark .rich-tool-btn {
    background: rgba(15, 23, 42, 0.7);
    border-color: rgba(148, 163, 184, 0.22);
    color: #dbeafe;
}

.editor::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

.editor::-webkit-scrollbar-thumb {
    background: rgba(148, 163, 184, 0.55);
    border-radius: 999px;
}

.editor::-webkit-scrollbar-track {
    background: transparent;
}

.editor::placeholder {
    color: #94a3b8;
}

.editor:focus {
    border-color: rgba(37, 99, 235, 0.5);
    box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.1);
}

.editor-meta {
    margin-top: 8px;
    color: #64748b;
    font-size: 12px;
    font-weight: 600;
}

.swap-fab {
    width: 40px;
    height: 40px;
    align-self: center;
    margin-top: 50px;
    border: 1px solid rgba(148, 163, 184, 0.28);
    border-radius: 999px;
    background: #fff;
    color: #475569;
    box-shadow: var(--shadow);
    display: grid;
    place-items: center;
}

.sidebar-card {
    padding: 14px;
}

.sidebar-title {
    margin-bottom: 10px;
    font-size: 15px;
    font-weight: 800;
    color: #0f172a;
}

.summary-panel {
    min-height: 244px;
}

.summary-grid {
    display: grid;
    gap: 10px;
}

.summary-chip {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 12px;
    border-radius: 12px;
    font-size: 14px;
    font-weight: 700;
}

.summary-chip span {
    font-weight: 600;
}

.summary-chip strong {
    font-size: 18px;
}

.summary-chip.blue {
    background: rgba(37, 99, 235, 0.1);
    color: #2563eb;
}

.summary-chip.green {
    background: rgba(34, 197, 94, 0.1);
    color: #16a34a;
}

.summary-chip.red {
    background: rgba(239, 68, 68, 0.1);
    color: #ef4444;
}

.summary-chip.gray {
    background: rgba(148, 163, 184, 0.14);
    color: #64748b;
}

.filter-list,
.action-stack {
    display: grid;
    gap: 8px;
}

.main-actions-wrap {
    margin-top: 10px;
    margin-bottom: 12px;
}

.main-actions {
    display: flex;
    align-items: stretch;
    justify-content: center;
    gap: 0;
    flex-wrap: wrap;
}

.icon-action {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 10px 16px;
    border: 0;
    background: transparent;
    color: #334155;
    font-size: 14px;
    font-weight: 700;
    border-radius: 0;
}

.icon-action + .icon-action {
    border-left: 1px solid rgba(148, 163, 184, 0.35);
}

.icon-action i {
    font-size: 15px;
}

.menu-divider {
    width: 1px;
    align-self: stretch;
    background: rgba(148, 163, 184, 0.35);
}

.filter-list label {
    display: flex;
    align-items: center;
    gap: 8px;
    color: #334155;
    font-size: 13px;
    font-weight: 600;
}

.filter-list input {
    width: 14px;
    height: 14px;
    accent-color: var(--primary);
}

.outline-action {
    width: auto;
    flex: 1 1 170px;
    justify-content: flex-start;
    background: #fff;
}

.tip-box {
    margin-top: 12px;
    padding: 12px;
    background: linear-gradient(180deg, #eff6ff 0%, #ffffff 100%);
    border-color: rgba(37, 99, 235, 0.08);
}

.tip-title {
    display: flex;
    align-items: center;
    gap: 8px;
    color: #1d4ed8;
    font-weight: 800;
    font-size: 14px;
}

.tip-box p {
    margin: 8px 0 0;
    color: #64748b;
    font-size: 13px;
    line-height: 1.5;
}

.cta-row {
    display: flex;
    justify-content: center;
    margin: 14px 0 16px;
}

.compare-btn {
    min-width: 180px;
    padding: 12px 18px;
    background: var(--primary);
    color: #fff;
    font-size: 15px;
    font-weight: 700;
    box-shadow: 0 16px 30px rgba(37, 99, 235, 0.25);
}

.compare-btn:hover,
.compare-btn:focus-visible {
    background: var(--primary-hover);
    color: #fff;
    transform: translateY(-1px);
}

.results-shell {
    padding-bottom: 10px;
}

.results-head {
    display: flex;
    justify-content: space-between;
    align-items: end;
    gap: 16px;
    margin-bottom: 12px;
}

.results-head h2 {
    margin: 0;
    font-size: 20px;
    font-weight: 800;
}

.results-head p {
    margin: 4px 0 0;
    color: var(--muted);
    font-size: 13px;
}

.results-summary {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 10px;
    padding: 12px;
    margin-bottom: 12px;
}

.results-summary > div {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    padding: 12px 14px;
    border-radius: 12px;
    background: #f8fafc;
    color: #475569;
    font-size: 13px;
    font-weight: 700;
}

.results-summary strong {
    font-size: 18px;
    color: #0f172a;
}

.results-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 14px;
}

.result-card {
    padding: 14px;
}

.result-actions {
    display: flex;
    gap: 8px;
}

.result-scroll {
    height: 360px;
    overflow: auto;
    border: 1px solid rgba(15, 23, 42, 0.07);
    border-radius: 14px;
    background: #fff;
    scroll-behavior: smooth;
}

.diff-row {
    display: grid;
    grid-template-columns: 46px minmax(0, 1fr);
    gap: 0;
    align-items: start;
    min-height: 30px;
    border-bottom: 1px solid rgba(148, 163, 184, 0.1);
}

.diff-row:last-child {
    border-bottom: 0;
}

.diff-line-number {
    padding: 7px 8px 7px 0;
    color: #94a3b8;
    text-align: right;
    font-size: 12px;
    font-variant-numeric: tabular-nums;
    -webkit-user-select: none;
    user-select: none;
}

.diff-line-body {
    padding: 7px 10px;
    color: #0f172a;
    font-size: 13px;
    line-height: 1.55;
    white-space: pre-wrap;
    word-break: break-word;
}

.diff-row.equal {
    background: #fbfdff;
}

.diff-row.added {
    background: var(--add);
}

.diff-row.deleted {
    background: var(--delete);
}

.diff-row.changed {
    background: var(--change);
}

.inline-added {
    background: rgba(34, 197, 94, 0.2);
    border-radius: 5px;
    padding: 0 3px;
}

.inline-deleted {
    background: rgba(239, 68, 68, 0.2);
    border-radius: 5px;
    padding: 0 3px;
}

.inline-equal {
    color: inherit;
}

.line-focus {
    outline: 2px solid rgba(37, 99, 235, 0.2);
    outline-offset: -2px;
}

.legend-bar {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 14px 18px;
    margin-top: 12px;
    padding: 12px 14px;
    color: #64748b;
    font-size: 13px;
    font-weight: 600;
}

.legend-bar span {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.swatch {
    width: 12px;
    height: 12px;
    border-radius: 4px;
    display: inline-block;
}

.swatch.add {
    background: rgba(34, 197, 94, 0.35);
}

.swatch.delete {
    background: rgba(239, 68, 68, 0.35);
}

.swatch.change {
    background: rgba(250, 204, 21, 0.5);
}

.swatch.equal {
    background: rgba(148, 163, 184, 0.35);
}

.empty-state {
    margin-top: 12px;
    padding: 18px 20px;
    text-align: center;
    color: #475569;
}

.empty-hero {
    font-size: 18px;
    font-weight: 800;
    color: #0f172a;
}

.empty-sub {
    margin-top: 6px;
    font-size: 13px;
}

.footer-note {
    width: min(1240px, calc(100% - 32px));
    margin: 0 auto 18px;
    padding: 12px 14px;
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.9);
    color: #475569;
    border: 1px solid rgba(15, 23, 42, 0.07);
    box-shadow: var(--shadow);
    font-size: 13px;
    font-weight: 600;
}

.loading-state {
    position: relative;
}

.loading-state::after {
    content: "Sedang mencari perbedaan...";
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    background: rgba(255, 255, 255, 0.72);
    -webkit-backdrop-filter: blur(2px);
    backdrop-filter: blur(2px);
    color: #2563eb;
    font-size: 14px;
    font-weight: 700;
    border-radius: 14px;
}

.is-hidden {
    display: none !important;
}

.btn-pressed {
    transform: translateY(1px);
}

.result-scroll::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

.result-scroll::-webkit-scrollbar-thumb {
    background: rgba(148, 163, 184, 0.55);
    border-radius: 999px;
}

.result-scroll::-webkit-scrollbar-track {
    background: transparent;
}

@media (hover: hover) {
    .ghost-btn:hover,
    .icon-chip:hover,
    .mini-btn:hover,
    .outline-action:hover {
        transform: translateY(-1px);
        box-shadow: 0 10px 22px rgba(0, 0, 0, 0.08);
    }

    .mini-btn:hover,
    .outline-action:hover {
        border-color: rgba(37, 99, 235, 0.18);
    }
}

@media (max-width: 1180px) {
    .compare-layout {
        grid-template-columns: minmax(0, 1fr);
    }

    .editor-grid {
        grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    }

    .summary-panel {
        grid-column: 1 / -1;
    }

    .sidebar-card {
        width: 100%;
    }

    .results-summary {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 820px) {
    .topbar {
        padding-inline: 14px;
    }

    .main-wrap,
    .footer-note {
        width: min(100%, calc(100% - 20px));
    }

    .editor-grid,
    .results-grid {
        grid-template-columns: minmax(0, 1fr);
    }

    .editor-grid > .editor-card:nth-of-type(1),
    .editor-grid > .editor-card:nth-of-type(2) {
        grid-column: auto;
        grid-row: auto;
    }

    .compare-layout {
        grid-template-columns: minmax(0, 1fr);
    }

    .results-head,
    .card-head,
    .result-head {
        align-items: start;
        flex-direction: column;
    }

    .result-actions {
        width: 100%;
    }

    .mini-btn {
        flex: 1;
    }

    .results-summary {
        grid-template-columns: minmax(0, 1fr);
    }

    .result-scroll {
        height: 320px;
    }
}

@media (max-width: 640px) {
    .topbar {
        flex-direction: column;
        align-items: stretch;
    }

    .topbar-actions {
        justify-content: flex-end;
        flex-wrap: wrap;
    }

    .hero {
        padding-top: 18px;
    }

    .hero h1 {
        font-size: 28px;
    }

    .stepper {
        gap: 8px 14px;
        font-size: 12px;
    }

    .editor-card,
    .sidebar-card,
    .result-card {
        padding: 12px;
    }

    .editor {
        min-height: 200px;
        font-size: 14px;
        line-height: 1.6;
    }
}