:root {
    --bg-base: #f4f4f5;
    --bg-panel: #ffffff;
    --bg-hover: #f1f5f9;

    --border-light: #e4e4e7;
    --border-highlight: #d4d4d8;

    --text-main: #18181b;
    --text-muted: #71717a;

    --accent: #0ea5e9;
    --accent-hover: #0284c7;
    --accent-glow: rgba(14, 165, 233, 0.15);

    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --radius-lg: 16px;
    --radius-md: 12px;
}

body.dark-theme {
    --bg-base: #09090b;
    --bg-panel: #18181b;
    --bg-hover: #27272a;

    --border-light: #27272a;
    --border-highlight: #3f3f46;

    --text-main: #f4f4f5;
    --text-muted: #a1a1aa;

    --accent: #38bdf8;
    --accent-hover: #7dd3fc;
    --accent-glow: rgba(56, 189, 248, 0.15);

    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.5);
    --shadow-md: 0 8px 16px -4px rgba(0, 0, 0, 0.4);
}

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

body {
    font-family: 'Inter', system-ui, sans-serif;
    background-color: var(--bg-base);
    color: var(--text-main);
    line-height: 1.5;
    transition: background-color 0.3s, color 0.3s;
    min-height: 100vh;
    display: flex;
    justify-content: center;
    padding: 2rem 1rem;
}

svg {
    display: block;
}

.w-4 {
    width: 1rem;
}

.h-4 {
    height: 1rem;
}

.w-5 {
    width: 1.25rem;
}

.h-5 {
    height: 1.25rem;
}

.w-6 {
    width: 1.5rem;
}

.h-6 {
    height: 1.5rem;
}

.hidden {
    display: none !important;
}

.text-muted {
    color: var(--text-muted);
}

.text-accent {
    color: var(--accent);
}

.text-sm {
    font-size: 0.875rem;
}

.text-left {
    text-align: left !important;
}

/* Layout */
.app-container {
    width: 100%;
    max-width: 800px;
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

.app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 1.25rem;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.btn-icon {
    background: transparent;
    border: 1px solid transparent;
    color: var(--text-muted);
    padding: 0.5rem;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-icon:hover {
    color: var(--text-main);
    background: var(--bg-hover);
}

/* Glass Panels */
.glass-panel {
    background: var(--bg-panel);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    padding: 1.5rem;
}

/* Results Top Section */
.results-panel {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1.5rem;
    padding: 2rem;
}

@media (max-width: 768px) {
    .results-panel {
        flex-direction: column;
        align-items: stretch;
        text-align: center;
    }

    .result-divider {
        display: none;
    }
}

.result-box {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    flex: 1;
}

.result-box label {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.display-input {
    background: transparent;
    border: 1px solid transparent;
    color: var(--text-main);
    font-family: 'JetBrains Mono', monospace;
    font-size: 2.5rem;
    font-weight: 700;
    width: 100%;
    text-align: center;
    outline: none;
    transition: all 0.2s;
    border-radius: 8px;
    padding: 0;
}

.display-input:focus {
    border-bottom: 2px solid var(--accent);
}

.symbolic-output-wrapper {
    display: flex;
    align-items: baseline;
    justify-content: center;
}

.symbolic-prefix {
    font-family: 'JetBrains Mono', monospace;
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--text-muted);
}

@media (max-width: 768px) {

    .display-input,
    .symbolic-prefix {
        text-align: center;
    }

    .symbolic-output-wrapper {
        justify-content: center;
    }
}

.result-divider {
    width: 1px;
    height: 80px;
    background: var(--border-light);
}

/* Command Preview */
.format-box {
    flex: 1.5;
}

.command-preview {
    font-family: 'JetBrains Mono', monospace;
    background: var(--bg-hover);
    padding: 1.25rem;
    border-radius: var(--radius-md);
    font-size: 1rem;
    color: var(--accent);
    cursor: pointer;
    text-align: center;
    border: 1px solid var(--border-light);
    transition: all 0.2s;
    position: relative;
    overflow: hidden;
}

.command-preview:hover {
    border-color: var(--accent);
    box-shadow: 0 0 0 1px var(--accent-glow);
}

.copy-hint {
    position: absolute;
    inset: 0;
    background: rgba(14, 165, 233, 0.9);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.875rem;
    font-weight: 500;
    font-family: 'Inter', sans-serif;
    opacity: 0;
    transition: opacity 0.2s;
}

body.dark-theme .copy-hint {
    background: rgba(56, 189, 248, 0.9);
    color: #000;
}

.command-preview:hover .copy-hint {
    opacity: 1;
}

/* Presets */
.presets-wrapper {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

@media(max-width: 640px) {
    .presets-wrapper {
        flex-direction: column-reverse;
        gap: 1rem;
        align-items: stretch;
    }
}

.presets {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.preset-btn {
    background: var(--bg-panel);
    border: 1px solid var(--border-light);
    color: var(--text-muted);
    padding: 0.5rem 1rem;
    border-radius: 999px;
    font-family: 'JetBrains Mono', monospace;
    font-weight: 600;
    font-size: 0.875rem;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.preset-desc {
    font-family: 'Inter', sans-serif;
    font-weight: 400;
    font-size: 0.75rem;
    opacity: 0.7;
}

.preset-btn:hover {
    background: var(--bg-hover);
    color: var(--text-main);
}

.preset-btn.active {
    background: var(--accent);
    color: white;
    border-color: transparent;
}

body.dark-theme .preset-btn.active {
    color: #000;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    color: var(--text-muted);
    transition: color 0.2s;
}

.checkbox-label:hover {
    color: var(--text-main);
}

.checkbox-label input {
    display: none;
}

.custom-chk {
    width: 18px;
    height: 18px;
    border: 1px solid var(--border-highlight);
    border-radius: 4px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.custom-chk::after {
    content: "";
    width: 10px;
    height: 10px;
    background: var(--accent);
    border-radius: 2px;
    transform: scale(0);
    transition: transform 0.2s;
}

.checkbox-label input:checked+.custom-chk {
    border-color: var(--accent);
}

.checkbox-label input:checked+.custom-chk::after {
    transform: scale(1);
}

/* Matrix Panel */
.matrix-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1.5rem;
}

@media (max-width: 640px) {
    .matrix-grid {
        grid-template-columns: 1fr;
        gap: 2rem;
    }

    .matrix-column:not(:last-child) {
        border-bottom: 1px solid var(--border-light);
        padding-bottom: 1.5rem;
    }
}

.matrix-column {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.column-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}

.column-header h3 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-main);
}

.octal-digit {
    background: var(--bg-hover);
    padding: 0.125rem 0.5rem;
    border-radius: 4px;
    font-family: 'JetBrains Mono', monospace;
    font-weight: 700;
    color: var(--accent);
}

.perm-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    padding: 0.75rem;
    background: var(--bg-hover);
    border-radius: 8px;
    transition: background 0.2s;
}

.perm-row:hover {
    background: var(--bg-base);
}

.perm-desc {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-main);
}

.perm-row input {
    display: none;
}

.toggle-switch {
    width: 36px;
    height: 20px;
    background: var(--border-highlight);
    border-radius: 999px;
    position: relative;
    transition: background 0.2s;
}

.toggle-switch::after {
    content: "";
    position: absolute;
    top: 2px;
    left: 2px;
    width: 16px;
    height: 16px;
    background: white;
    border-radius: 50%;
    transition: transform 0.2s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

.perm-row input:checked+.toggle-switch {
    background: var(--accent);
}

.perm-row input:checked+.toggle-switch::after {
    transform: translateX(16px);
}


/* Toast */
.toast {
    position: fixed;
    bottom: 2rem;
    transform: translateY(100px);
    background: var(--text-main);
    color: var(--bg-base);
    padding: 0.75rem 1.5rem;
    border-radius: 999px;
    font-weight: 500;
    font-size: 0.875rem;
    opacity: 0;
    transition: all 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    z-index: 100;
    pointer-events: none;
    box-shadow: var(--shadow-md);
}

.toast.show {
    transform: translateY(0);
    opacity: 1;
}