:root {
    color-scheme: light;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
    background: #f5f7fb;
    color: #1f2937;
}

.navbar {
    background: #111827;
    color: #fff;
    padding: 0.9rem 1.2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.navbar-brand {
    font-weight: 600;
    letter-spacing: 0.2px;
}

.navbar-links {
    display: flex;
    gap: 1rem;
}

.navbar-links a {
    color: #e5e7eb;
    text-decoration: none;
    font-weight: 500;
}

.navbar-links a:hover {
    color: #fff;
}

.container {
    max-width: 980px;
    margin: 0 auto;
    padding: 1.25rem;
}

.hero {
    margin-top: 1rem;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    padding: 1.25rem;
}

.kicker {
    margin: 0;
    color: #2563eb;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-size: 0.78rem;
}

.hero h1 {
    margin: 0.4rem 0 0.6rem;
    font-size: clamp(1.55rem, 3.4vw, 2.2rem);
    line-height: 1.2;
}

.hero-sub {
    margin: 0;
    max-width: 760px;
    color: #4b5563;
}

.btn-row {
    margin-top: 1rem;
    display: flex;
    flex-wrap: wrap;
    gap: 0.65rem;
}

.grid {
    margin-top: 1rem;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 0.85rem;
}

.card {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    padding: 1rem;
}

.card h3 {
    margin: 0 0 0.45rem;
    font-size: 1rem;
}

.card p {
    margin: 0 0 0.75rem;
    color: #4b5563;
    font-size: 0.9rem;
}

.btn {
    display: inline-block;
    background: #2563eb;
    color: #fff;
    text-decoration: none;
    padding: 0.45rem 0.7rem;
    border-radius: 8px;
    font-size: 0.88rem;
    font-weight: 600;
}

.btn:hover {
    background: #1d4ed8;
}

.btn-secondary {
    background: #374151;
}

.btn-secondary:hover {
    background: #1f2937;
}

.btn-ghost {
    background: #e5e7eb;
    color: #1f2937;
}

.btn-ghost:hover {
    background: #d1d5db;
}

.info-grid {
    margin-top: 1rem;
    display: grid;
    gap: 0.85rem;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
}

.info-card {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    padding: 1rem;
}

.info-card h2 {
    margin: 0 0 0.55rem;
    font-size: 1.05rem;
}

.info-card p {
    margin: 0;
    color: #4b5563;
}

.text-link {
    margin-top: 0.75rem;
    display: inline-block;
    color: #1d4ed8;
    text-decoration: none;
    font-weight: 600;
}

.text-link:hover {
    text-decoration: underline;
}

.preview {
    margin-top: 1rem;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    padding: 1rem;
}

.preview-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    margin-bottom: 0.85rem;
}

.preview-header h2 {
    margin: 0;
    font-size: 1.05rem;
}

.preview-frame {
    width: 100%;
    min-height: 70vh;
    border: 1px solid #d1d5db;
    border-radius: 10px;
    background: #fff;
}

.empty {
    margin-top: 1rem;
    background: #fff;
    border: 1px dashed #9ca3af;
    border-radius: 12px;
    padding: 1rem;
    color: #374151;
}

.tool-panel {
    margin-top: 1rem;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    padding: 1rem;
}

.file-action-btn {
    width: 30px;
    height: 30px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    background: #f9fafb;
    color: #2563eb;
    text-decoration: none;
    transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease, transform 0.1s ease;
}

.file-action-btn:hover {
    background: #eff6ff;
    border-color: #93c5fd;
    color: #1d4ed8;
    transform: translateY(-1px);
}

.file-action-btn:focus-visible {
    outline: 2px solid #93c5fd;
    outline-offset: 2px;
}

.file-list {
    padding-left: 1.25rem;
}

.folder-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
}

.folder-row .file-name {
    flex: 1;
    min-width: 0;
}

.folder-link {
    color: #2563eb;
    text-decoration: none;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    width: 100%;
    border-radius: 8px;
    padding: 0.2rem 0.35rem;
    transition: background 0.15s ease, color 0.15s ease;
}

.folder-link:hover {
    background: #eff6ff;
    color: #1d4ed8;
}

.folder-link:focus-visible {
    outline: 2px solid #93c5fd;
    outline-offset: 2px;
}

.tools-shell {
    margin-top: 1rem;
    display: grid;
    gap: 0.85rem;
    grid-template-columns: minmax(210px, 260px) minmax(0, 1fr);
}

.tools-sidebar {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    padding: 1rem;
}

.tools-sidebar h2 {
    margin: 0 0 0.75rem;
    font-size: 1.05rem;
}

.tool-nav-btn {
    width: 100%;
    text-align: left;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    background: #fff;
    color: #1f2937;
    padding: 0.55rem 0.6rem;
    font: inherit;
    font-weight: 600;
    margin-bottom: 0.5rem;
    cursor: pointer;
}

.tool-nav-btn:hover:not(:disabled) {
    background: #f9fafb;
}

.tool-nav-btn-active {
    border-color: #2563eb;
    background: #eff6ff;
}

.tool-nav-btn:disabled {
    cursor: not-allowed;
    opacity: 0.7;
}

.module-title {
    margin: 0 0 0.5rem;
    font-size: 1.2rem;
}

.tool-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 0.85rem;
}

.tool-field {
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
}

.tool-field label {
    font-weight: 600;
}

.tool-input {
    border: 1px solid #d1d5db;
    border-radius: 8px;
    padding: 0.55rem 0.6rem;
    font: inherit;
    color: #1f2937;
    background: #fff;
}

.tool-help {
    margin: 0;
    color: #4b5563;
    font-size: 0.84rem;
}

.tool-status {
    margin-top: 0.85rem;
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    padding: 0.7rem 0.8rem;
    color: #1f2937;
}

.tool-status-error {
    color: #991b1b;
    border-color: #fecaca;
    background: #fef2f2;
}

.tool-preview-wrap {
    margin-top: 1rem;
}

.tool-preview-split {
    margin-top: 1rem;
    display: grid;
    gap: 0.85rem;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
}

.tool-preview-wrap h2 {
    margin: 0 0 0.65rem;
    font-size: 1.05rem;
}

.tool-preview-split h2 {
    margin: 0 0 0.65rem;
    font-size: 1.05rem;
}

.tool-preview-image {
    display: block;
    width: min(100%, 720px);
    max-height: 65vh;
    object-fit: contain;
    border: 1px solid #d1d5db;
    border-radius: 10px;
    background: #fff;
}

.tool-preview-canvas {
    display: block;
    width: min(100%, 720px);
    height: auto;
    max-height: 65vh;
    border: 1px solid #d1d5db;
    border-radius: 10px;
}

.checkerboard {
    background-color: #fff;
    background-image:
        linear-gradient(45deg, #e5e7eb 25%, transparent 25%),
        linear-gradient(-45deg, #e5e7eb 25%, transparent 25%),
        linear-gradient(45deg, transparent 75%, #e5e7eb 75%),
        linear-gradient(-45deg, transparent 75%, #e5e7eb 75%);
    background-size: 20px 20px;
    background-position: 0 0, 0 10px, 10px -10px, -10px 0;
}

.tool-meta {
    margin: 0.65rem 0 0;
    color: #4b5563;
    font-size: 0.9rem;
}

.editor-controls {
    margin-top: 1rem;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    padding: 0.85rem;
    background: #f9fafb;
}

.editor-controls .tool-grid + .tool-grid {
    margin-top: 0.75rem;
}

.tool-field-inline {
    flex-direction: row;
    align-items: center;
    justify-content: flex-start;
    gap: 0.5rem;
}

.tool-field-inline label {
    margin: 0;
}

#editorOutputCanvas {
    width: min(100%, 720px);
    height: auto;
    background: #fff;
}

.editor-crop-canvas {
    cursor: move;
    background: #fff;
}

.editor-crop-canvas-dragging {
    cursor: grabbing;
}

@media (max-width: 820px) {
    .tools-shell {
        grid-template-columns: 1fr;
    }
}
