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

:root {
    --bg: #0f1117;
    --surface: #1a1d27;
    --border: #2a2d3a;
    --accent: #4f8ef7;
    --accent-hover: #6ea3ff;
    --text: #e2e6f0;
    --text-muted: #8891a8;
    --danger: #f76f6f;
    --success: #4fcf8e;
    --radius: 10px;
}

body {
    background: var(--bg);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 16px;
    line-height: 1.7;
    min-height: 100vh;
}

/* ----- Header ----- */
header {
    position: sticky;
    top: 0;
    z-index: 100;
    background: rgba(15, 17, 23, 0.92);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border);
    padding: 0.75rem 2rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.header-name {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text);
    letter-spacing: 0.02em;
    text-decoration: none;
}
.header-name:hover { color: var(--text); }
.header-name span { color: var(--accent); }

.lang-selector select {
    appearance: none;
    background: var(--surface);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.4rem 2.2rem 0.4rem 0.9rem;
    font-size: 0.875rem;
    cursor: pointer;
    outline: none;
    transition: border-color 0.2s;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%238891a8' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.7rem center;
}
.lang-selector select:hover,
.lang-selector select:focus { border-color: var(--accent); }

/* ----- Main layout ----- */
main {
    max-width: 620px;
    margin: 0 auto;
    padding: 3rem 2rem 5rem;
}

/* ----- Intro heading ----- */
.intro {
    margin-bottom: 2.5rem;
}

.intro h1 {
    font-size: 1.75rem;
    font-weight: 700;
}

/* ----- Section card ----- */
.section {
    margin-bottom: 2rem;
    padding: 1.75rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

.section h2 {
    font-size: 0.85rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--accent);
    margin-bottom: 1.25rem;
}

/* ----- Form groups ----- */
.form-group { margin-bottom: 1.25rem; }
.form-group:last-child { margin-bottom: 0; }

label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-muted);
    margin-bottom: 0.4rem;
}

.form-input {
    width: 100%;
    background: var(--bg);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.55rem 0.85rem;
    font-size: 0.95rem;
    font-family: inherit;
    outline: none;
    transition: border-color 0.2s;
}
.form-input:focus { border-color: var(--accent); }
.form-input.is-valid { border-color: var(--success); }
.form-input.is-invalid { border-color: var(--danger); }
.form-input[readonly] { color: var(--text-muted); cursor: default; }
.form-input.mono { font-family: 'Courier New', Courier, monospace; font-size: 0.8rem; }

.form-feedback {
    font-size: 0.8rem;
    color: var(--danger);
    margin-top: 0.3rem;
}

/* ----- Input with status icon ----- */
.input-with-status { display: flex; }

.input-with-status .form-input {
    border-right: none;
    border-radius: var(--radius) 0 0 var(--radius);
    flex: 1;
    min-width: 0;
}

.status-badge {
    background: var(--bg);
    border: 1px solid var(--border);
    border-left: none;
    border-radius: 0 var(--radius) var(--radius) 0;
    padding: 0 0.85rem;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 2.5rem;
}

.status-ok { color: var(--success); font-weight: 600; }
.status-err { color: var(--danger); font-weight: 600; }

/* ----- Spinner ----- */
.spinner {
    width: 1rem;
    height: 1rem;
    border: 2px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ----- Color pickers ----- */
.color-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
    margin-bottom: 1.25rem;
}

.color-grid-2 {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
    margin-bottom: 1.25rem;
}

.color-grid .form-group,
.color-grid-2 .form-group { margin-bottom: 0; }

.color-input {
    display: block;
    width: 100%;
    height: 2.5rem;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.25rem;
    cursor: pointer;
    transition: border-color 0.2s;
}
.color-input:hover:not(:disabled) { border-color: var(--accent); }
.color-input:disabled { opacity: 0.35; cursor: not-allowed; }

/* ----- Toggle switch ----- */
.toggle {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    cursor: pointer;
    user-select: none;
    margin-bottom: 0.5rem;
}

.toggle input[type='checkbox'] {
    appearance: none;
    width: 2.25rem;
    height: 1.25rem;
    background: var(--border);
    border-radius: 999px;
    position: relative;
    cursor: pointer;
    flex-shrink: 0;
    transition: background 0.2s;
}
.toggle input[type='checkbox']::after {
    content: '';
    position: absolute;
    top: 3px;
    left: 3px;
    width: 0.8rem;
    height: 0.8rem;
    background: var(--text-muted);
    border-radius: 50%;
    transition: transform 0.2s, background 0.2s;
}
.toggle input[type='checkbox']:checked { background: var(--accent); }
.toggle input[type='checkbox']:checked::after {
    transform: translateX(1rem);
    background: #fff;
}

.toggle-text {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-muted);
}

/* ----- Buttons ----- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.55rem 1.25rem;
    border-radius: var(--radius);
    font-size: 0.95rem;
    font-family: inherit;
    font-weight: 500;
    border: 1px solid transparent;
    cursor: pointer;
    transition: background 0.2s, border-color 0.2s, color 0.2s;
    white-space: nowrap;
    text-decoration: none;
}

.btn-primary {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }

.btn-secondary {
    background: var(--surface);
    color: var(--text-muted);
    border-color: var(--border);
}
.btn-secondary:hover { border-color: var(--accent); color: var(--accent); }
.btn-secondary.copied {
    background: rgba(79, 207, 142, 0.12);
    border-color: var(--success);
    color: var(--success);
}

.btn-full { width: 100%; }
.btn-lg { padding: 0.75rem 2.5rem; font-size: 1.05rem; }

/* ----- Input + button (copy rows) ----- */
.input-group { display: flex; }

.input-group .form-input {
    border-right: none;
    border-radius: var(--radius) 0 0 var(--radius);
    flex: 1;
    min-width: 0;
}
.input-group .btn {
    border-radius: 0 var(--radius) var(--radius) 0;
}

/* ----- Result preview ----- */
.result-preview {
    text-align: center;
    margin-bottom: 1.5rem;
    padding: 1rem;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 8px;
}
.result-preview img { max-width: 100%; display: inline-block; }

/* ----- Landing page ----- */
.landing {
    text-align: center;
    padding: 5rem 2rem;
    max-width: 620px;
    margin: 0 auto;
}

.landing h1 {
    font-size: 2.5rem;
    font-weight: 700;
    margin-bottom: 1rem;
}

.landing .subtitle {
    color: var(--text-muted);
    font-size: 1.1rem;
    max-width: 480px;
    margin: 0 auto 2.5rem;
}

.landing .preview {
    margin: 3rem 0 2rem;
    padding: 1.5rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    display: inline-block;
}

.landing footer {
    color: var(--text-muted);
    font-size: 0.85rem;
    margin-top: 1rem;
}

/* ----- Utility ----- */
.d-none { display: none !important; }

/* ----- Responsive ----- */
@media (max-width: 600px) {
    header { padding: 0.75rem 1rem; }
    main { padding: 2rem 1rem 4rem; }
    .landing { padding: 3rem 1rem; }
    .landing h1 { font-size: 1.75rem; }
}
