*, *::before, *::after {
    box-sizing: border-box;
}

:root {
    color-scheme: light;
    --page: #f5f7fb;
    --panel: #ffffff;
    --ink: #111827;
    --muted: #64748b;
    --line: #dbe3ef;
    --field: #f8fafc;
    --primary: #0f766e;
    --primary-dark: #115e59;
    --accent: #9a3412;
    --accent-dark: #7c2d12;
    --code: #0f172a;
    --code-text: #e2e8f0;
    --success: #047857;
    --warning-bg: #fff7ed;
    --warning-line: #fed7aa;
    --warning-text: #9a3412;
}

.page-shell {
    width: min(1160px, calc(100% - 32px));
    margin: 0 auto;
    padding: 32px 0;
}

.tool-panel {
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel);
    box-shadow: 0 24px 70px rgba(15, 23, 42, 0.10);
}

.tool-hero {
    padding: 32px;
    background: #0f172a;
    color: #fff;
}

.tool-hero h1 {
    margin: 0;
    font-size: clamp(2rem, 4vw, 3.25rem);
    line-height: 1.05;
    letter-spacing: 0;
}

.tool-hero p {
    max-width: 780px;
    margin: 14px 0 0;
    color: #cbd5e1;
    font-size: 1.05rem;
}

.tool-grid {
    display: grid;
    grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr);
    gap: 28px;
    padding: 28px;
}

.section-title {
    margin: 0 0 18px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--line);
    color: var(--primary-dark);
    font-size: 1.25rem;
    line-height: 1.2;
}

.form-stack {
    display: grid;
    gap: 18px;
}

.guide-box {
    border: 1px solid #bfdbfe;
    border-radius: 8px;
    background: #eff6ff;
    color: #1e3a8a;
    padding: 16px;
}

.guide-box h2 {
    margin: 0 0 10px;
    font-size: 1rem;
    line-height: 1.25;
}

.guide-box ol {
    margin: 0;
    padding-left: 20px;
}

.guide-box li {
    margin: 6px 0;
    font-size: 0.92rem;
}

.field-group {
    display: grid;
    gap: 7px;
}

.field-row {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
}

.field-group label {
    color: #334155;
    font-size: 0.94rem;
    font-weight: 700;
}

.counter {
    flex: 0 0 auto;
    color: var(--muted);
    font-size: 0.82rem;
}

.counter.is-warning {
    color: #dc2626;
    font-weight: 700;
}

.field-group input,
.field-group textarea,
.field-group select {
    width: 100%;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    background: var(--field);
    color: var(--ink);
    font: inherit;
    padding: 11px 12px;
    outline: none;
    transition: border-color 150ms ease, box-shadow 150ms ease, background-color 150ms ease;
}

.field-group textarea {
    min-height: 104px;
    resize: vertical;
}

.field-group input:focus,
.field-group textarea:focus,
.field-group select:focus {
    border-color: var(--primary);
    background: #fff;
    box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.14);
}

.output-card {
    display: grid;
    gap: 16px;
}

.code-box {
    min-height: 430px;
    max-height: 560px;
    overflow: auto;
    border: 1px solid #1e293b;
    border-radius: 8px;
    background: var(--code);
    padding: 18px;
}

.code-box pre {
    margin: 0;
    white-space: pre-wrap;
    word-break: break-word;
    color: var(--code-text);
    font-family: Consolas, Monaco, "Courier New", monospace;
    font-size: 0.88rem;
    line-height: 1.55;
}

.meta-empty {
    color: #94a3b8;
}

.actions {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
}

#copyButton {
    appearance: none;
    border: 0;
    border-radius: 8px;
    background: var(--accent);
    color: #fff;
    cursor: pointer;
    font: inherit;
    font-weight: 800;
    padding: 12px 18px;
    transition: background-color 150ms ease, transform 150ms ease, opacity 150ms ease;
}

#copyButton:hover {
    background: var(--accent-dark);
}

#copyButton:active {
    transform: translateY(1px);
}

#copyButton:disabled {
    cursor: not-allowed;
    opacity: 0.58;
    transform: none;
}

.copy-message {
    min-height: 24px;
    color: var(--success);
    font-size: 0.92rem;
    font-weight: 700;
}

.note {
    border: 1px solid var(--warning-line);
    border-radius: 8px;
    background: var(--warning-bg);
    color: var(--warning-text);
    padding: 14px;
    font-size: 0.92rem;
}

.note strong {
    display: block;
    margin-bottom: 4px;
}

@media (max-width: 860px) {
    .page-shell {
        width: min(100% - 20px, 720px);
        padding: 16px 0;
    }

    .tool-hero,
    .tool-grid {
        padding: 22px;
    }

    .tool-grid {
        grid-template-columns: 1fr;
    }

    .code-box {
        min-height: 320px;
        max-height: 460px;
    }
}
