:root {
    --bg: #f8f1eb;
    --surface: rgba(255, 249, 245, 0.9);
    --surface-strong: #fff8f3;
    --text: #23160f;
    --muted: #755c4d;
    --border: rgba(70, 33, 14, 0.1);
    --primary: #e05a1f;
    --primary-dark: #a93014;
    --accent: #ffb347;
    --accent-deep: #6f2012;
    --shadow: 0 18px 45px rgba(77, 33, 14, 0.12);
    --radius: 24px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
[hidden] { display: none !important; }
body {
    margin: 0;
    color: var(--text);
    background:
        radial-gradient(circle at top left, rgba(224, 90, 31, 0.24), transparent 28%),
        radial-gradient(circle at top right, rgba(255, 179, 71, 0.2), transparent 24%),
        linear-gradient(180deg, #fff7f1 0%, #f7ede3 100%);
    font-family: "Segoe UI", "Helvetica Neue", sans-serif;
}

a { color: inherit; text-decoration: none; }
img, svg { display: block; max-width: 100%; }
main { min-height: calc(100vh - 170px); }
.container { width: min(1160px, calc(100% - 32px)); margin: 0 auto; }
.site-header {
    position: sticky;
    top: 0;
    z-index: 30;
    backdrop-filter: blur(16px);
    background: rgba(255, 247, 241, 0.82);
    border-bottom: 1px solid rgba(255, 255, 255, 0.55);
}
.nav-wrap {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    padding: 18px 0;
}
.brand {
    display: inline-flex;
    align-items: center;
    gap: 14px;
}
.brand-mark {
    width: 58px;
    height: 58px;
    display: grid;
    place-items: center;
    border-radius: 18px;
    background: linear-gradient(135deg, rgba(255,255,255,0.98) 0%, rgba(255,240,228,0.98) 100%);
    box-shadow: 0 12px 24px rgba(224, 90, 31, 0.18);
    overflow: hidden;
}
.brand-logo {
    width: 100%;
    height: 100%;
    object-fit: contain;
    padding: 4px;
}
.brand small, .eyebrow, .helper-text, .site-footer p, .site-nav a, .meta-badge, .note p, .upload-zone span, .progress-wrap small {
    color: var(--muted);
}
.site-nav {
    display: flex;
    align-items: center;
    gap: 18px;
    flex-wrap: wrap;
}
.nav-cta {
    padding: 10px 16px;
    background: linear-gradient(135deg, var(--accent-deep) 0%, #26120d 100%);
    color: #fff;
    border-radius: 999px;
}
.hero {
    padding: 64px 0 36px;
}
.hero-grid, .workspace-grid, .result-grid, .admin-grid, .footer-grid {
    display: grid;
    gap: 24px;
}
.hero-grid { grid-template-columns: 1.2fr .8fr; align-items: center; }
.hero h1, .tool-page h1, .simple-page h1, .auth-card h1, .admin-page h1, .result-page h1, .legal-page h1, .not-found h1 {
    margin: 10px 0 16px;
    line-height: 1;
    letter-spacing: -0.04em;
}
.hero h1 { font-size: clamp(2.7rem, 7vw, 5rem); max-width: 12ch; }
.hero p, .tool-page p, .simple-page p, .legal-page p { font-size: 1.05rem; line-height: 1.7; }
.hero-panel, .admin-stats {
    display: grid;
    gap: 18px;
}
.stat-card, .stat-panel {
    border-radius: var(--radius);
    padding: 22px;
    background: rgba(255, 255, 255, 0.72);
    border: 1px solid rgba(255,255,255,0.75);
    box-shadow: var(--shadow);
}
.stat-card strong, .stat-panel strong {
    display: block;
    font-size: 2rem;
    color: var(--primary);
}
.hero-actions, .form-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-top: 26px;
}
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 48px;
    padding: 0 18px;
    border: 0;
    border-radius: 16px;
    cursor: pointer;
    font-weight: 600;
}
.btn-primary {
    color: #fff;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    box-shadow: 0 18px 30px rgba(224, 90, 31, 0.28);
}
.btn-ghost {
    color: var(--text);
    background: rgba(255, 250, 246, 0.92);
    border: 1px solid var(--border);
}
.btn-danger {
    color: #fff;
    background: linear-gradient(135deg, var(--accent-deep) 0%, #3f180d 100%);
}
.section-head {
    display: flex;
    justify-content: space-between;
    align-items: end;
    gap: 18px;
    margin-bottom: 22px;
}
.tools-section, .result-page, .simple-page, .admin-page, .auth-page, .tool-page {
    padding-bottom: 48px;
}
.tools-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 18px;
}
.tool-card, .panel, .highlight-card {
    border-radius: var(--radius);
    background: var(--surface);
    border: 1px solid rgba(255,255,255,0.8);
    box-shadow: var(--shadow);
}
.tool-card {
    padding: 24px;
    transition: transform .22s ease, box-shadow .22s ease;
}
.tool-card:hover { transform: translateY(-4px); }
.tool-icon, .upload-icon {
    width: 56px;
    height: 56px;
    display: grid;
    place-items: center;
    border-radius: 18px;
    color: var(--primary);
    background: rgba(224, 90, 31, 0.1);
}
.tool-card h3 { margin: 18px 0 12px; }
.tool-card p { min-height: 70px; color: var(--muted); }
.tool-link { font-weight: 700; color: var(--primary); }
.highlights {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 18px;
    padding-bottom: 72px;
}
.highlight-card, .panel { padding: 24px; }
.tool-hero {
    display: flex;
    justify-content: space-between;
    gap: 20px;
    align-items: start;
    margin: 28px 0 24px;
}
.tool-meta {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}
.meta-badge {
    padding: 10px 14px;
    border-radius: 999px;
    background: rgba(255, 248, 241, 0.88);
    border: 1px solid var(--border);
}
.workspace-grid, .result-grid, .admin-grid { grid-template-columns: 1.4fr .8fr; }
.split-tool-layout {
    display: grid;
    grid-template-columns: 1.5fr .78fr;
    gap: 24px;
    align-items: start;
}
.split-tool-layout.is-preview-hidden {
    grid-template-columns: 1fr;
}
.split-tool-layout.is-preview-hidden .split-preview-panel {
    display: none;
}
.upload-zone {
    display: grid;
    place-items: center;
    gap: 10px;
    min-height: 240px;
    padding: 28px;
    border-radius: 24px;
    border: 2px dashed rgba(224, 90, 31, 0.24);
    background: linear-gradient(180deg, rgba(224,90,31,0.08), rgba(255,248,241,0.8));
    text-align: center;
    cursor: pointer;
}
.upload-zone.dragover { border-color: var(--primary); background: rgba(224,90,31,0.12); }
.upload-zone input { display: none; }
.form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
    margin-top: 22px;
}
.form-grid .full { grid-column: 1 / -1; }
label span, .steps li, .details-list dt { display: block; font-weight: 600; margin-bottom: 8px; }
input, select {
    width: 100%;
    min-height: 48px;
    padding: 0 14px;
    border-radius: 14px;
    border: 1px solid rgba(17, 24, 39, 0.1);
    background: rgba(255,251,248,0.96);
    font: inherit;
}
.file-list { display: grid; gap: 10px; margin-top: 18px; }
.file-pill {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 12px 14px;
    border-radius: 14px;
    background: rgba(255, 246, 240, 0.9);
}
.file-pill-name {
    flex: 1;
    min-width: 0;
    overflow-wrap: anywhere;
}
.file-pill-actions {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
}
.file-remove-btn {
    min-height: 36px;
    padding: 0 12px;
    border: 0;
    border-radius: 999px;
    background: rgba(224, 90, 31, 0.12);
    color: var(--primary);
    font: inherit;
    font-weight: 700;
    cursor: pointer;
}
.file-remove-btn:hover {
    background: rgba(224, 90, 31, 0.22);
}
.progress-wrap { margin-top: 18px; }
.editor-shell {
    margin-top: 22px;
    padding: 0;
    overflow: hidden;
}
.editor-topbar {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
    padding: 16px;
    background: rgba(255, 242, 232, 0.92);
    border-bottom: 1px solid rgba(70, 33, 14, 0.08);
}
.editor-toolbar,
.editor-export {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}
.editor-btn {
    min-height: 38px;
    padding: 0 12px;
    border: 1px solid rgba(70, 33, 14, 0.1);
    border-radius: 12px;
    background: rgba(255, 250, 246, 0.96);
    color: var(--text);
    font: inherit;
    cursor: pointer;
}
.editor-btn:hover {
    border-color: rgba(224, 90, 31, 0.28);
    background: rgba(255, 244, 236, 1);
}
.editor-btn.is-active {
    border-color: rgba(224, 90, 31, 0.42);
    background: rgba(255, 232, 214, 1);
}
.editor-help {
    padding: 14px 16px 0;
    color: var(--muted);
    font-size: .95rem;
}
.canvas-editor-layout {
    display: grid;
    grid-template-columns: 220px minmax(0, 1fr) 280px;
    min-height: 760px;
    background: linear-gradient(180deg, rgba(255,247,241,0.9), rgba(249,238,227,0.95));
}
.editor-sidebar,
.editor-inspector {
    display: flex;
    flex-direction: column;
    min-height: 100%;
    background: rgba(255, 252, 249, 0.9);
}
.editor-sidebar {
    border-right: 1px solid rgba(70, 33, 14, 0.08);
}
.editor-inspector {
    border-left: 1px solid rgba(70, 33, 14, 0.08);
}
.editor-sidebar-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 16px;
    border-bottom: 1px solid rgba(70, 33, 14, 0.08);
}
.editor-sidebar-head small {
    color: var(--muted);
}
.editor-thumb-list {
    padding: 16px 14px 18px;
    display: grid;
    gap: 14px;
    overflow: auto;
}
.editor-thumb-card {
    border: 1px solid rgba(70, 33, 14, 0.08);
    border-radius: 16px;
    padding: 10px;
    background: #fff;
    cursor: pointer;
    transition: transform .18s ease, border-color .18s ease, box-shadow .18s ease;
}
.editor-thumb-card:hover {
    transform: translateY(-1px);
    border-color: rgba(224, 90, 31, 0.32);
}
.editor-thumb-card.is-active {
    border-color: rgba(224, 90, 31, 0.5);
    box-shadow: 0 10px 24px rgba(120, 48, 20, 0.1);
    background: rgba(255, 245, 236, 1);
}
.editor-thumb-card canvas {
    width: 100%;
    height: auto;
    display: block;
    border-radius: 10px;
    background: #fff;
    box-shadow: 0 10px 24px rgba(77, 33, 14, 0.08);
}
.editor-thumb-card strong,
.editor-thumb-card small {
    display: block;
}
.editor-thumb-card strong {
    margin-top: 10px;
    font-size: .95rem;
}
.editor-thumb-card small {
    color: var(--muted);
    margin-top: 3px;
}
.editor-stage-panel {
    display: flex;
    flex-direction: column;
    min-width: 0;
}
.editor-stage-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    padding: 16px 20px;
    border-bottom: 1px solid rgba(70, 33, 14, 0.08);
}
.editor-stage-toolbar span {
    font-weight: 700;
    text-align: center;
    flex: 1;
}
.editor-nav-btn {
    min-height: 40px;
    padding: 0 14px;
    border: 1px solid rgba(70, 33, 14, 0.1);
    border-radius: 12px;
    background: rgba(255, 250, 246, 0.96);
    cursor: pointer;
    font: inherit;
    font-weight: 600;
}
.editor-nav-btn:disabled {
    opacity: .45;
    cursor: not-allowed;
}
.editor-canvas-area {
    flex: 1;
    padding: 22px;
    display: grid;
    place-items: center;
    overflow: auto;
}
.editor-canvas-stack {
    position: relative;
    width: fit-content;
    max-width: 100%;
    border-radius: 18px;
    overflow: hidden;
    background: #fff;
    box-shadow: 0 20px 42px rgba(77, 33, 14, 0.16);
}
.editor-main-canvas,
.editor-overlay-canvas {
    display: block;
    max-width: 100%;
    height: auto;
}
.editor-overlay-canvas {
    position: absolute;
    inset: 0;
    cursor: crosshair;
}
.editor-inspector-body {
    padding: 16px;
    display: grid;
    gap: 14px;
}
.editor-inspector-body label {
    display: grid;
    gap: 8px;
}
.editor-inspector-body textarea {
    min-height: 110px;
    resize: vertical;
}
.editor-inspector-actions {
    padding-top: 6px;
}
.progress-bar {
    height: 14px;
    border-radius: 999px;
    overflow: hidden;
    background: rgba(148, 163, 184, 0.2);
}
.progress-bar span {
    display: block;
    width: 0;
    height: 100%;
    background: linear-gradient(90deg, var(--accent) 0%, var(--primary) 55%, var(--accent-deep) 100%);
    transition: width .18s ease;
}
.side-panel .note {
    margin-top: 24px;
    padding: 18px;
    border-radius: 18px;
    background: rgba(224, 90, 31, 0.08);
}
.split-preview-panel {
    min-height: 520px;
    background: linear-gradient(180deg, #f8f6fb 0%, #f0ecf7 100%);
    border: 1px solid rgba(123, 97, 255, 0.08);
}
.split-preview-panel.has-file {
    min-height: auto;
}
.split-preview-empty {
    min-height: 420px;
    display: grid;
    place-items: center;
    text-align: center;
    gap: 12px;
    padding: 32px;
}
.split-preview-empty p {
    max-width: 34ch;
    color: var(--muted);
}
.split-preview-workspace {
    display: grid;
    gap: 20px;
    padding: 6px 6px 0;
}
.split-preview-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 18px;
}
.split-preview-head strong,
.split-preview-head small {
    display: block;
}
.split-preview-stage {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 22px;
    padding: 18px;
    border: 1px dashed rgba(117, 92, 77, 0.22);
    border-radius: 22px;
    background: rgba(255,255,255,0.56);
}
.split-range-card {
    width: 230px;
    padding: 18px;
    border-radius: 20px;
    background: rgba(255,255,255,0.88);
    box-shadow: 0 12px 24px rgba(51, 33, 20, 0.08);
    text-align: center;
    border: 1px solid transparent;
    cursor: pointer;
}
.split-range-card.is-active {
    border-color: rgba(224, 90, 31, 0.42);
    box-shadow: 0 0 0 3px rgba(224, 90, 31, 0.12), 0 12px 24px rgba(51, 33, 20, 0.08);
}
.split-range-card:focus-visible {
    outline: 2px solid rgba(224, 90, 31, 0.42);
    outline-offset: 2px;
}
.split-card-label {
    display: block;
    margin-bottom: 12px;
    color: var(--muted);
    font-weight: 600;
}
.split-page-canvas {
    width: 100%;
    height: auto;
    border-radius: 12px;
    box-shadow: 0 8px 18px rgba(51, 33, 20, 0.12);
    background: #fff;
}
.split-range-separator {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--accent-deep);
}
.split-thumb-strip {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
    gap: 12px;
    align-items: start;
}
.split-thumb-card {
    padding: 10px;
    border-radius: 16px;
    background: rgba(255,255,255,0.82);
    border: 1px solid rgba(70, 33, 14, 0.08);
    text-align: center;
    cursor: pointer;
    transition: transform .18s ease, border-color .18s ease, box-shadow .18s ease;
}
.split-thumb-card:hover {
    transform: translateY(-2px);
}
.split-thumb-card.is-selected {
    border-color: rgba(224, 90, 31, 0.42);
    box-shadow: 0 0 0 2px rgba(224, 90, 31, 0.16);
}
.split-thumb-card canvas {
    width: 100%;
    height: auto;
    border-radius: 10px;
    background: #fff;
}
.split-thumb-card strong {
    display: block;
    margin-top: 8px;
    font-size: .95rem;
}
.split-mode-block {
    margin-bottom: 6px;
}
.mode-toggle-group {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}
.mode-toggle {
    flex: 1;
    min-width: 160px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 52px;
    border-radius: 16px;
    border: 1px solid rgba(70, 33, 14, 0.1);
    background: rgba(255,250,246,0.96);
    cursor: pointer;
    font-weight: 700;
}
.mode-toggle input {
    display: none;
}
.mode-toggle.is-active,
.mode-toggle:has(input:checked) {
    border-color: rgba(224, 90, 31, 0.34);
    background: rgba(255, 238, 224, 0.95);
    color: var(--primary-dark);
}
.steps { margin: 0; padding-left: 18px; line-height: 1.8; }
.details-list div {
    display: flex;
    justify-content: space-between;
    gap: 18px;
    padding: 12px 0;
    border-bottom: 1px solid rgba(17,24,39,0.06);
}
.preview-frame {
    width: 100%;
    min-height: 520px;
    border: 0;
    border-radius: 16px;
    background: #fff;
}
.table-panel { overflow: auto; }
.data-table {
    width: 100%;
    border-collapse: collapse;
    min-width: 720px;
}
.data-table th, .data-table td {
    padding: 14px 12px;
    text-align: left;
    border-bottom: 1px solid rgba(17,24,39,0.06);
}
.auth-page {
    min-height: 70vh;
    display: grid;
    place-items: center;
}
.auth-card {
    width: min(520px, 100%);
    display: grid;
    gap: 16px;
}
.alert {
    padding: 14px 16px;
    border-radius: 16px;
    font-weight: 600;
}
.alert.success { background: rgba(22, 163, 74, 0.1); color: #166534; }
.alert.error { background: rgba(169, 48, 20, 0.12); color: #7d210f; }
.site-footer {
    padding: 24px 0 42px;
}
.footer-grid {
    grid-template-columns: 1fr auto;
    align-items: start;
}
.footer-grid a {
    display: block;
    margin-bottom: 8px;
    color: var(--muted);
}
.inline-form { margin-top: 12px; }
.not-found, .legal-page { margin: 48px auto 72px; }

@media (max-width: 1040px) {
    .tools-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .hero-grid, .workspace-grid, .result-grid, .admin-grid, .footer-grid, .split-tool-layout { grid-template-columns: 1fr; }
}

@media (max-width: 720px) {
    .site-nav { display: none; }
    .hero { padding-top: 34px; }
    .tools-grid, .highlights, .form-grid { grid-template-columns: 1fr; }
    .section-head, .tool-hero { flex-direction: column; align-items: start; }
    .tool-card p { min-height: 0; }
    .preview-frame { min-height: 360px; }
    .file-pill { align-items: start; flex-direction: column; }
    .file-pill-actions { width: 100%; justify-content: space-between; }
    .canvas-editor-layout { grid-template-columns: 1fr; min-height: auto; }
    .editor-sidebar { border-right: 0; border-bottom: 1px solid rgba(70, 33, 14, 0.08); }
    .editor-inspector { border-left: 0; border-top: 1px solid rgba(70, 33, 14, 0.08); }
    .editor-thumb-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .editor-stage-toolbar { padding: 14px; flex-wrap: wrap; }
    .editor-stage-toolbar span { order: -1; width: 100%; }
    .editor-canvas-area { padding: 14px; }
    .split-preview-panel { min-height: auto; }
    .split-preview-empty { min-height: 320px; }
    .split-preview-stage { flex-direction: column; }
    .split-range-card { width: 100%; }
}
