/* === Reset & Base === */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* === Accessibility === */
.skip-link {
    position: absolute;
    top: -100px;
    left: 16px;
    background: var(--accent);
    color: #fff;
    padding: 8px 16px;
    border-radius: 4px;
    font-size: 0.85rem;
    font-weight: 600;
    z-index: 999;
    text-decoration: none;
}
.skip-link:focus {
    top: 8px;
}
*:focus-visible {
    outline: 2px solid var(--green);
    outline-offset: 2px;
}

:root {
    --bg:        #1a1a2e;
    --surface:   #16213e;
    --surface2:  #0f3460;
    --accent:    #e94560;
    --accent2:   #533483;
    --text:      #eee;
    --text-dim:  #8892b0;
    --green:     #64ffda;
    --yellow:    #ffd369;
    --radius:    8px;
    --mono:      "SF Mono", "Fira Code", "Cascadia Code", Menlo, monospace;
}

/* === Light Theme === */
[data-theme="light"] {
    --bg:        #f5f5f7;
    --surface:   #ffffff;
    --surface2:  #e5e5ea;
    --accent:    #0071e3;
    --accent2:   #7c3aed;
    --text:      #1d1d1f;
    --text-dim:  #6e6e73;
    --green:     #059669;
    --yellow:    #b45309;
}
[data-theme="light"] .radio-pill:checked + label {
    background: rgba(0, 113, 227, 0.1);
    color: #0071e3;
}
[data-theme="light"] .op-btn.active {
    background: rgba(0, 113, 227, 0.06);
}
@media (prefers-color-scheme: light) {
    :root:not([data-theme="dark"]) {
        --bg:        #f5f5f7;
        --surface:   #ffffff;
        --surface2:  #e5e5ea;
        --accent:    #0071e3;
        --accent2:   #7c3aed;
        --text:      #1d1d1f;
        --text-dim:  #6e6e73;
        --green:     #059669;
        --yellow:    #b45309;
    }
    :root:not([data-theme="dark"]) .radio-pill:checked + label {
        background: rgba(0, 113, 227, 0.1);
        color: #0071e3;
    }
    :root:not([data-theme="dark"]) .op-btn.active {
        background: rgba(0, 113, 227, 0.06);
    }
}

/* === Theme Toggle === */
.theme-toggle {
    margin-left: auto;
    background: none;
    border: 1px solid transparent;
    border-radius: 6px;
    color: var(--text-dim);
    font-size: 1.1rem;
    cursor: pointer;
    padding: 4px 8px;
    line-height: 1;
    transition: color 0.15s, background 0.15s;
}
.theme-toggle:hover {
    color: var(--yellow);
    background: rgba(128, 128, 128, 0.1);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    display: flex;
    justify-content: center;
}

/* === Site Nav === */
.site-nav {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 44px;
    background: var(--surface);
    border-bottom: 1px solid var(--surface2);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 200;
}
.site-nav-inner {
    width: 100%;
    max-width: 760px;
    padding: 0 20px;
    display: flex;
    align-items: center;
    gap: 24px;
}
.nav-brand {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--text);
    text-decoration: none;
    letter-spacing: -0.02em;
    flex-shrink: 0;
    padding: 4px 10px;
    border-radius: 6px;
    transition: background 0.15s, color 0.15s;
}
.nav-brand:hover {
    color: var(--green);
    background: rgba(100, 255, 218, 0.08);
}
.nav-links {
    display: flex;
    gap: 6px;
    list-style: none;
}
.nav-links a {
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--text-dim);
    text-decoration: none;
    padding: 4px 10px;
    border-radius: 6px;
    transition: color 0.15s, background 0.15s;
}
.nav-links a:hover {
    color: var(--text);
    background: var(--surface2);
}
.nav-links a.active {
    color: var(--green);
    background: rgba(100, 255, 218, 0.08);
}

.app {
    width: 100%;
    max-width: 760px;
    padding: 60px 20px 120px;
    display: flex;
    flex-direction: column;
    gap: 24px;
}

/* === Header === */
.header {
    text-align: center;
    padding: 20px 0 8px;
}
.header h1 {
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: -0.02em;
}
.version {
    font-size: 0.8rem;
    color: var(--text-dim);
    font-family: var(--mono);
}
.header-sub {
    font-size: 0.85rem;
    color: var(--text-dim);
    margin-top: 6px;
}
.header-sub a {
    color: var(--green);
    text-decoration: none;
}
.header-sub a:hover {
    text-decoration: underline;
}

/* === Operation Nav === */
.op-nav {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: center;
}
.op-btn {
    background: var(--surface);
    border: 2px solid transparent;
    border-radius: var(--radius);
    color: var(--text);
    padding: 12px 18px;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    transition: border-color 0.15s, background 0.15s;
    min-width: 80px;
}
.op-btn:hover {
    background: var(--surface2);
}
.op-btn.active {
    border-color: var(--accent);
    background: var(--surface2);
}
.op-icon {
    font-size: 1.3rem;
    font-weight: 700;
    line-height: 1;
}
.op-label {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* === Workspace === */
.workspace {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 24px;
    min-height: 200px;
}
.placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 160px;
    color: var(--text-dim);
    font-size: 0.95rem;
}

/* === Form Elements === */
.form-section {
    margin-bottom: 20px;
}
.form-section:last-child {
    margin-bottom: 0;
}
.form-label {
    display: block;
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-dim);
    margin-bottom: 8px;
}

.radio-group {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}
.radio-pill {
    display: none;
}
.radio-pill + label {
    background: var(--bg);
    border: 1px solid transparent;
    border-radius: 20px;
    padding: 6px 14px;
    font-size: 0.85rem;
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s;
    white-space: nowrap;
}
.radio-pill + label:hover {
    border-color: var(--accent);
}
.radio-pill:checked + label {
    border-color: var(--accent);
    background: rgba(233, 69, 96, 0.15);
    color: #fff;
}

.text-input {
    width: 100%;
    background: var(--bg);
    border: 1px solid var(--surface2);
    border-radius: var(--radius);
    padding: 10px 14px;
    color: var(--text);
    font-size: 0.9rem;
    font-family: var(--mono);
    outline: none;
    transition: border-color 0.15s;
}
.text-input:focus {
    border-color: var(--accent);
}
.text-input:focus-visible {
    outline: none;
}
.text-input::placeholder {
    color: var(--text-dim);
    opacity: 0.6;
}

.checkbox-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 4px;
}
.checkbox-row input[type="checkbox"] {
    accent-color: var(--accent);
    width: 16px;
    height: 16px;
}
.checkbox-row label {
    font-size: 0.88rem;
    cursor: pointer;
}

.hint {
    font-size: 0.78rem;
    color: var(--text-dim);
    margin-top: 4px;
}

/* === Batch-specific === */
.batch-list {
    list-style: none;
    margin: 8px 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.batch-item {
    background: var(--bg);
    border-radius: var(--radius);
    padding: 8px 12px;
    font-family: var(--mono);
    font-size: 0.82rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.batch-item .remove-item {
    background: none;
    border: none;
    color: var(--accent);
    cursor: pointer;
    font-size: 1.1rem;
    padding: 0 4px;
    line-height: 1;
}
.batch-add-row {
    display: flex;
    gap: 8px;
    margin-top: 8px;
}
.batch-add-row .text-input {
    flex: 1;
}
.btn-small {
    background: var(--surface2);
    border: 1px solid var(--accent);
    border-radius: var(--radius);
    color: var(--text);
    padding: 8px 16px;
    cursor: pointer;
    font-size: 0.85rem;
    white-space: nowrap;
    transition: background 0.15s;
}
.btn-small:hover {
    background: rgba(233, 69, 96, 0.2);
}

/* === Output Bar === */
.output-bar {
    position: fixed;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 100%;
    max-width: 760px;
    background: var(--surface);
    border-top: 2px solid var(--accent);
    padding: 12px 20px 16px;
    z-index: 100;
}
.output-label {
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--green);
    margin-bottom: 6px;
}
.output-row {
    display: flex;
    gap: 10px;
    align-items: center;
}
.output-cmd {
    flex: 1;
    background: var(--bg);
    border-radius: var(--radius);
    padding: 10px 14px;
    font-family: var(--mono);
    font-size: 0.82rem;
    color: var(--yellow);
    overflow-x: auto;
    white-space: pre;
    line-height: 1.5;
    max-height: 200px;
    overflow-y: auto;
}
.copy-btn {
    background: var(--accent);
    border: none;
    border-radius: var(--radius);
    color: #fff;
    padding: 10px 20px;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.85rem;
    transition: opacity 0.15s;
    flex-shrink: 0;
}
.copy-btn:hover {
    opacity: 0.85;
}
.copy-toast {
    position: absolute;
    top: -30px;
    right: 20px;
    background: var(--green);
    color: var(--bg);
    font-size: 0.78rem;
    font-weight: 700;
    padding: 4px 12px;
    border-radius: 4px;
    opacity: 0;
    transition: opacity 0.2s;
    pointer-events: none;
}
.copy-toast.show {
    opacity: 1;
}

/* === Divider === */
.form-divider {
    border: none;
    border-top: 1px solid var(--surface2);
    margin: 16px 0;
}

/* === Site Footer === */
.site-footer {
    text-align: center;
    padding: 24px 16px;
    font-size: 0.78rem;
    color: var(--text-dim);
    line-height: 1.7;
    border-top: 1px solid var(--surface2);
    margin-top: 8px;
}
.site-footer a {
    color: var(--green);
    text-decoration: none;
}
.site-footer a:hover {
    text-decoration: underline;
}
.site-footer strong {
    color: var(--text);
    font-weight: 600;
}
.footer-copy {
    margin-top: 8px;
    font-size: 0.72rem;
    color: var(--text-dim);
    opacity: 0.7;
}

/* === Responsive === */
@media (max-width: 500px) {
    .app { padding: 56px 12px 130px; }
    .op-btn { min-width: 60px; padding: 10px 12px; }
    .op-label { font-size: 0.65rem; }
    .output-cmd { font-size: 0.75rem; }
}
