 :root {
    color-scheme: dark;
    --primary-font: 'Klee One', sans-serif;
    --secondary-font: 'Courier New', 'Courier', monospace;
    --page-bg: #000000;
    --page-text: #fafafa;
    --panel-bg: rgba(10, 10, 10, 0.8);
    --surface-bg: rgba(0, 0, 0, 0.4);
    --surface-bg-strong: rgba(10, 10, 10, 0.5);
    --surface-bg-soft: rgba(0, 0, 0, 0.3);
    --border-color: #1a1a1a;
    --border-strong: #333333;
    --muted-text: #666666;
    --muted-text-2: #555555;
    --soft-text: #333333;
    --brand-line: #444444;
    --button-bg: #fafafa;
    --button-text: #000000;
    --button-hover-bg: #ffffff;
    --button-active-bg: #d8d8d8;
    --button-disabled-bg: #1a1a1a;
    --button-disabled-text: #444444;
    --decor-grid: rgba(255, 255, 255, 0.03);
    --decor-dot: rgba(255, 255, 255, 0.08);
    --decor-fade: rgba(255, 255, 255, 0.05);
    --status-ready: #22c55e;
    --status-ready-border: rgba(34, 197, 94, 0.2);
    --status-ready-glow: rgba(34, 197, 94, 0.5);
    --accent-color: #22c55e;
    --footer-chip-bg: rgba(10, 10, 10, 0.8);
    --bg-gradient: radial-gradient(ellipse 80% 50% at 50% -20%, rgba(120, 120, 120, 0.15), transparent);
}

[data-theme="light"] {
    color-scheme: light;
    --page-bg: #f0f2f5;
    --page-text: #1a1a1a;
    --panel-bg: rgba(255, 255, 255, 0.7);
    --surface-bg: rgba(255, 255, 255, 0.4);
    --surface-bg-strong: rgba(255, 255, 255, 0.5);
    --surface-bg-soft: rgba(255, 255, 255, 0.9);
    --border-color: #d1d5db;
    --border-strong: #9ca3af;
    --muted-text: #6b7280;
    --muted-text-2: #7e776d;
    --soft-text: #9ca3af;
    --brand-line: #d1d5db;
    --button-bg: #1f1b17;
    --button-text: #f9f5ef;
    --button-hover-bg: #313131;
    --button-active-bg: #141414;
    --button-disabled-bg: #cecece;
    --button-disabled-text: #9ca3af;
    --decor-grid: rgba(0, 0, 0, 0.05);
    --decor-dot: rgba(0, 0, 0, 0.2);
    --decor-fade: rgba(0, 0, 0, 0.1);
    --status-ready: #1f8a4c;
    --status-ready-border: rgba(31, 138, 76, 0.16);
    --status-ready-glow: rgba(31, 138, 76, 0.28);
    --accent-color: #1f8a4c;
    --footer-chip-bg: rgba(255, 255, 255, 0.88);
    --accent: rgba(0, 0, 0, 0.3);
    --accent-strong: rgba(0, 0, 0, 0.5);
    --bg-gradient: radial-gradient(ellipse 80% 50% at 50% -20%, rgba(0, 0, 0, 0.2), transparent);
}

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

html {
    font-family: var(--primary-font);
    background-color: var(--page-bg);
    color: var(--page-text);
}

html[data-font="secondary"] {
    font-family: var(--secondary-font);
}

body {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    position: relative;
    overflow-x: hidden;
}

@view-transition {
    navigation: auto;
}

::view-transition-old(root),
::view-transition-new(root) {
    animation-duration: 320ms;
    animation-timing-function: cubic-bezier(0.22, 1, 0.36, 1);
}

::view-transition-old(furigana-shell),
::view-transition-new(furigana-shell) {
    animation-duration: 380ms;
    animation-timing-function: cubic-bezier(0.22, 1, 0.36, 1);
}

/* Grid de fondo estilo Vercel/Nothing */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-image: 
        linear-gradient(var(--decor-grid) 1px, transparent 1px),
        linear-gradient(90deg, var(--decor-grid) 1px, transparent 1px);
    background-size: 60px 60px;
    pointer-events: none;
    z-index: 0;
}

/* Puntos en intersecciones estilo Nothing */
body::after {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-image: radial-gradient(circle, var(--decor-dot) 1px, transparent 1px);
    background-size: 60px 60px;
    pointer-events: none;
    z-index: 0;
}

/* Gradiente radial sutil */
.bg-gradient {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--bg-gradient);
    pointer-events: none;
    z-index: 0;
}

main {
    width: 100%;
    max-width: none;
    display: flex;
    justify-content: center;
    position: relative;
    z-index: 1;
}

/* Container principal con borde */
.container {
    width: 700px;
    min-width: 700px;
    max-width: 100%;
    background: var(--panel-bg);
    backdrop-filter: blur(20px);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 2.5rem;
    position: relative;
    overflow: visible;
    box-sizing: border-box;
}

.furigana-app-shell {
    view-transition-name: furigana-shell;
}

/* Esquinas decorativas estilo Nothing */
.container::before,
.container::after {
    content: '';
    position: absolute;
    width: 12px;
    height: 12px;
    border: 1px solid var(--border-strong);
}

.container::before {
    top: -1px;
    left: -1px;
    border-right: none;
    border-bottom: none;
    border-top-left-radius: 4px;
}

.container::after {
    bottom: -1px;
    right: -1px;
    border-left: none;
    border-top: none;
    border-bottom-right-radius: 4px;
}

/* Esquinas adicionales */
.corner-tl, .corner-br {
    position: absolute;
    width: 12px;
    height: 12px;
    border: 1px solid var(--border-strong);
}

.corner-tl {
    top: -1px;
    right: -1px;
    border-left: none;
    border-bottom: none;
    border-top-right-radius: 4px;
}

.corner-br {
    bottom: -1px;
    left: -1px;
    border-right: none;
    border-top: none;
    border-bottom-left-radius: 4px;
}

.container-resize-handle {
    position: absolute;
    right: -1px;
    top: -1px;
    bottom: -1px;
    width: 18px;
    height: calc(100% + 2px);
    display: block;
    border: 0;
    padding: 0;
    background: transparent;
    cursor: ew-resize;
    z-index: 3;
    touch-action: none;
}

.container-resize-handle:hover {
    background: transparent !important;
}

.container-resize-handle::before {
    content: '';
    position: absolute;
    top: 50%;
    right: 3px;
    width: 4px;
    height: 46px;
    transform: translateY(-50%);
    border-radius: 999px;
    background: var(--border-strong);
    opacity: 0.45;
}

.container-resize-handle:active::before {
    background: var(--accent-color) !important;
    opacity: 0.75 !important;
    transition: background 0.2s ease, opacity 0.2s ease;
}

.container-resize-handle:hover::before {
    opacity: 0.45 !important;
    background: var(--border-strong) !important;
}

header {
    text-align: center;
    margin-bottom: 2rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid var(--border-color);
    position: relative;
}

/* Linea decorativa bajo header */
header::after {
    content: '';
    position: absolute;
    bottom: -1px;
    left: 50%;
    transform: translateX(-50%);
    width: 40px;
    height: 1px;
    background: var(--brand-line);
}

h1 {
    font-size: 2.25rem;
    font-weight: 600;
    letter-spacing: -0.02em;
    margin-bottom: 0.5rem;
}

.subtitle {
    color: var(--muted-text);
    font-size: 0.9rem;
    font-weight: 400;
    letter-spacing: 0.05em;
}

#status {
    text-align: center;
    font-size: 0.8rem;
    color: var(--muted-text);
    margin-bottom: 1.5rem;
    padding: 0.625rem 1rem;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    background: var(--surface-bg-soft);
    position: relative;
    overflow: hidden;
}

/* Indicador dot */
#status::before {
    content: '';
    display: inline-block;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--muted-text);
    margin-right: 0.5rem;
    vertical-align: middle;
}

#status.loading {
    color: var(--muted-text);
    border-color: var(--border-strong);
}

#status.loading::before {
    background: var(--muted-text);
    animation: blink 1.5s ease-in-out infinite;
}

#status.ready {
    color: var(--status-ready);
    border-color: var(--status-ready-border);
}

#status.ready::before {
    background: var(--status-ready);
    box-shadow: 0 0 8px var(--status-ready-glow);
}

/* Animación para ocultar el recuadro de estado */
#status.fade-out {
    opacity: 0;
    transform: translateY(-8px);
    max-height: 0;
    padding-top: 0;
    padding-bottom: 0;
    margin-bottom: 0;
    border: 0;
    transition: opacity 320ms ease, transform 320ms ease, max-height 320ms ease, padding 320ms ease, margin 320ms ease, border 320ms ease;
}

@keyframes blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.3; }
}

.converter {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.input-section,
.output-section {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

label {
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 0.15em;
    color: var(--muted-text-2);
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* Linea decorativa en labels */
label::before {
    content: '';
    width: 8px;
    height: 1px;
    background: var(--border-strong);
}

textarea,
#output {
    width: 100%;
    min-height: 120px;
    padding: 1rem;
    font-size: 1.05rem;
    line-height: 1.8;
    background: var(--surface-bg);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--page-text);
    resize: vertical;
    transition: border-color 0.2s ease, background 0.2s ease;
}

textarea::placeholder {
    color: var(--soft-text);
}

textarea:focus {
    outline: none;
    border-color: var(--border-strong);
    background: var(--surface-bg-strong);
}

#input {
    min-height: 120px;
    padding: 1.25rem;
    font-size: 1.25rem;
    line-height: 1.8;
    background: var(--surface-bg-strong);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--page-text);
    white-space: pre-wrap; 
    outline: none;
    /* Esto permite que Yomitan escanee el texto plano sin saltos */
    user-select: text;
    -webkit-user-select: text;
}
#input:empty:before {
    content: attr(placeholder);
    color: var(--soft-text);
}

#input:focus {
    border-color: var(--border-strong);
    background: var(--surface-bg-strong);
}

/* Crucial para que Yomitan detecte las palabras dentro del editor */
#input .jp-word {
    display: inline;
    pointer-events: auto;
}

#output {
    width: 100%;
    min-height: 120px;
    padding: 1.25rem;
    font-size: 1.25rem;
    line-height: 1.8;
    background: var(--surface-bg-strong); /* Un poco más oscuro para que el gris resalte */
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--page-text);
    position: relative;
    white-space: pre-wrap; 
    cursor: text;
    /* Permitir selección es vital para el recuadro gris de Yomitan */
    user-select: text;
    -webkit-user-select: text;
}

.jp-word {
    display: inline-block; /* Cambiado a inline-block para definir mejor los límites */
    position: relative;
    vertical-align: bottom;
    /* Esto ayuda a que Yomitan identifique el bloque como una palabra entera */
    pointer-events: auto; 
}

/* El recuadro de selección de Yomitan suele inyectarse como un overlay.
   Asegurémonos de que el texto no tenga sombras que lo confundan. */
#output.has-content {
    color: var(--page-text);
}

/* Separador central */
.divider {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    padding: 0.5rem 0;
}

.divider::before,
.divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--border-color), transparent);
}

button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    align-self: center;
    padding: 0.75rem 1.75rem;
    font-size: 0.8rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    background: var(--button-bg);
    color: var(--button-text);
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.15s ease;
    position: relative;
}

button:hover:not(:disabled) {
    background: var(--button-hover-bg);
}

button:active:not(:disabled) {
    transform: scale(0.98);
}

#btn:active:not(:disabled),
#btn-copy:active:not(:disabled) {
    background: var(--button-active-bg);
}

button:disabled {
    background: var(--button-disabled-bg);
    color: var(--button-disabled-text);
    cursor: not-allowed;
}

button svg {
    transition: transform 0.2s ease;
}

button:hover:not(:disabled) svg {
    transform: translateX(2px);
}

footer {
    margin-top: 2rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: flex-end;
    position: relative;
    gap: 0.75rem;
    min-height: 2.2rem;
}

.footer-spacer {
    min-width: 1px;
    flex: 1;
}

.menu-toggle {
    width: 2.2rem;
    height: 2.2rem;
    padding: 0;
    font-size: 0;
    letter-spacing: 0;
    gap: 0;
    border-radius: 50%;
    background: var(--surface-bg-soft);
    color: var(--muted-text);
    border: 1px solid var(--border-color);
    position: absolute;
    left: 50%;
    top: calc(1.5rem + 1.1rem + 1px);
    transform: translate(-50%, -50%);
    z-index: 2;
    opacity: 0.92;
}

.menu-toggle:active:not(:disabled) {
    transform: translate(-50%, -50%) scale(0.98);
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Marca decorativa */
footer::before {
    content: '//';
    position: absolute;
    top: -0.5em;
    left: 50%;
    transform: translateX(-50%);
    background: var(--footer-chip-bg);
    padding: 0 0.5rem;
    color: var(--soft-text);
    font-size: 0.7rem;
    letter-spacing: 0.2em;
}

footer p {
    font-size: 0.7rem;
    color: var(--soft-text);
    letter-spacing: 0.1em;
    text-transform: uppercase;
}

.menu-toggle:hover:not(:disabled) {
    background: var(--surface-bg-strong);
    color: var(--page-text);
}

.menu-toggle svg {
    transition: transform 0.2s ease;
}

.menu-toggle .icon-open { display: none; }
.menu-toggle .icon-closed { display: inline-block; }
.menu-toggle[aria-expanded="true"] .icon-open { display: inline-block; }
.menu-toggle[aria-expanded="true"] .icon-closed { display: none; }

/* Morphing bars -> chevron animation */
.filter-morph {
    display: block;
    width: 18px;
    height: 18px;
}

.filter-morph .bar {
    stroke: currentColor;
    transition: transform 920ms cubic-bezier(0.18, 1, 0.32, 1), stroke-width 520ms ease;
    transform-origin: center;
    transform-box: fill-box;
}

/* Closed state: bars horizontal */
.filter-morph .bar1 { transform: translateY(0) rotate(0) scaleX(1); }
.filter-morph .bar2 { transform: translateY(0) rotate(0) scaleX(1); }
.filter-morph .bar3 { transform: translateY(0) rotate(0) scaleX(1); }

/* Open state: morph bars into chevron arms (no fading) */
.menu-toggle[aria-expanded="true"] .filter-morph .bar1 {
    /* top bar: move down and rotate to form left arm of chevron */
    transform: translate(0px,5px) rotate(45deg) scaleX(1);
}
.menu-toggle[aria-expanded="true"] .filter-morph .bar2 {
    /* middle bar disappears smoothly */
    transform: scaleX(0.02);
    opacity: 0;
}
.menu-toggle[aria-expanded="true"] .filter-morph .bar3 {
    /* bottom bar: move up and rotate to form right arm of chevron */
    transform: translate(0px,-5px) rotate(-45deg) scaleX(1);
}

/* Slight stagger so bars rearrange smoothly into the chevron */
.filter-morph .bar1 { transition-delay: 0ms; }
.filter-morph .bar2 { transition-delay: 30ms; }
.filter-morph .bar3 { transition-delay: 60ms; }

.translate-toggle {
    width: 2.2rem;
    height: 2.2rem;
    padding: 0;
    font-size: 0;
    letter-spacing: 0;
    gap: 0;
    border-radius: 50%;
    background: var(--surface-bg-soft);
    border: 1px solid var(--border-color);
    opacity: 0.92;
    transition: all 0.3s ease;
}

.translate-toggle:hover:not(:disabled) {
    background: var(--surface-bg-strong);
    color: var(--page-text);
    opacity: 1;
}

.translate-toggle:active:not(:disabled) {
    transform: scale(0.95);
}

.translate-icon {
    transition: transform 0.3s ease;
}

.translate-toggle:hover:not(:disabled) .translate-icon {
    transform: scale(1.08);
}

.font-toggle {
    width: 2.2rem;
    height: 2.2rem;
    padding: 0;
    font-size: 0;
    letter-spacing: 0;
    gap: 0;
    border-radius: 50%;
}

.font-icon {
    transition: transform 0.2s ease;
}

.font-toggle:hover:not(:disabled) .font-icon {
    transform: scale(1.08);
}

.theme-toggle {
    width: 2.2rem;
    height: 2.2rem;
    padding: 0;
    font-size: 0;
    letter-spacing: 0;
    gap: 0;
    border-radius: 50%;
}

.theme-icon {
    transition: transform 0.2s ease;
}

.theme-icon-moon {
    display: none;
}

[data-theme="light"] .theme-icon-sun {
    display: none;
}

[data-theme="light"] .theme-icon-moon {
    display: inline-block;
}

.theme-toggle:hover:not(:disabled) .theme-icon {
    transform: scale(1.08);
}

/* Bottom-right quick links (match main.css) */
.corner-links {
    position: fixed;
    right: 2rem;
    bottom: 2rem;
    z-index: 50;
    display: flex;
    align-items: center;
    gap: 0.2rem;
}

.corner-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 2.2rem;
    background: var(--panel-bg);
    backdrop-filter: blur(12px);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--page-text);
    text-decoration: none;
    font-size: 0.75rem;
    font-weight: 500;
    letter-spacing: 0.05em;
    transition: all 0.25s ease;
}

.corner-link:hover:not(:disabled) {
    transform: translateY(-2px);
    border-color: var(--border-strong);
    background: var(--surface-bg-strong);
}

.corner-link:active:not(:disabled) {
    transform: translateY(0);
}

.corner-link-long {
    padding: 0 1rem;
    min-width: 5.2rem;
}

.corner-link-square {
    width: 2.2rem;
    padding: 0;
    font-size: 1rem;
}

@media (max-width: 768px) {
    .corner-links {
        right: 1.5rem;
        bottom: 1.5rem;
    }

    .corner-link {
        height: 2.05rem;
        font-size: 0.7rem;
    }

    .corner-link-long {
        min-width: 4.8rem;
        padding: 0 0.8rem;
    }

    .corner-link-square {
        width: 2.05rem;
        font-size: 0.92rem;
    }
}

/* Hotspot to reveal corner links when hidden */
.corner-hotspot {
    position: fixed;
    right: 2rem;
    bottom: 2rem;
    width: 2.4rem;
    height: 2.4rem;
    z-index: 49;
    background: transparent;
    pointer-events: auto;
}

.corner-links-hidden {
    opacity: 0;
    transform: translateY(6px);
    pointer-events: none;
    transition: opacity 220ms ease, transform 220ms ease;
}

.corner-links {
    transition: opacity 220ms ease, transform 220ms ease;
}

.filters-menu {
    margin-top: 16px;
    padding: 14px;
    border: 1px solid var(--border-color);
    border-radius: 14px;
    background: var(--surface-bg-soft);
    backdrop-filter: blur(18px);
    overflow: hidden;
    max-height: 0;
    opacity: 0;
    transform: translateY(-8px) scaleY(0.985);
    pointer-events: none;
    transform-origin: top center;
    will-change: max-height, opacity, transform;
    transition:
        max-height 2000ms cubic-bezier(0.22, 1, 0.36, 1),
        opacity 1000ms ease,
        transform 2000ms cubic-bezier(0.22, 1, 0.36, 1);
}

.filters-menu.is-open {
    max-height: 340px;
    opacity: 1;
    transform: translateY(0) scaleY(1);
    pointer-events: auto;
}

.filters-menu.is-opening {
    transition:
    max-height 2000ms cubic-bezier(0.18, 1, 0.32, 1),
    opacity 1000ms ease,
    transform 2000ms cubic-bezier(0.18, 1, 0.32, 1);
}

.filters-menu.is-closing {
    margin-top: 0;
    padding: 0;
    max-height: 0;
    opacity: 0;
    transform: translateY(-8px) scaleY(0.985);
    pointer-events: none;
    transition:
        max-height 760ms cubic-bezier(0.22, 1, 0.36, 1),
        opacity 380ms ease,
        transform 760ms cubic-bezier(0.22, 1, 0.36, 1),
        padding 760ms cubic-bezier(0.22, 1, 0.36, 1),
        margin-top 760ms cubic-bezier(0.22, 1, 0.36, 1);
}

.filters-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.55rem;
}

.filter-type-group {
    margin-top: 0;
    padding-top: 0;
    border-top: 0 solid var(--border-color);
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.55rem;
    display: grid;
    overflow: hidden;
    max-height: 0;
    opacity: 0;
    transform: translateY(-8px) scaleY(0.985);
    pointer-events: none;
    transform-origin: top center;
    will-change: max-height, opacity, transform;
    transition:
        max-height 2000ms cubic-bezier(0.22, 1, 0.36, 1),
        opacity 1000ms ease,
        transform 2000ms cubic-bezier(0.22, 1, 0.36, 1);
}

.filter-type-group.is-open {
    max-height: 130px;
    opacity: 1;
    transform: translateY(0) scaleY(1);
    pointer-events: auto;
    margin-top: 1.1rem;
    padding-top: 0.95rem;
    border-top-width: 1px;
}

.filter-type-group.is-opening {
    transition:
        max-height 2000ms cubic-bezier(0.18, 1, 0.32, 1),
        opacity 1000ms ease,
        transform 2000ms cubic-bezier(0.18, 1, 0.32, 1);
}

.filter-type-group.is-closing {
    margin-top: 0;
    padding-top: 0;
    border-top-width: 0;
    max-height: 0;
    opacity: 0;
    transform: translateY(-8px) scaleY(0.985);
    pointer-events: none;
    transition:
        max-height 760ms cubic-bezier(0.22, 1, 0.36, 1),
        opacity 380ms ease,
        transform 760ms cubic-bezier(0.22, 1, 0.36, 1),
        padding-top 760ms cubic-bezier(0.22, 1, 0.36, 1),
        margin-top 760ms cubic-bezier(0.22, 1, 0.36, 1),
        border-top-width 760ms cubic-bezier(0.22, 1, 0.36, 1);
}

.filter-type-group.is-ruby-only {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.filter-type-group.is-ruby-only .filter-type-chip[data-block-display="none"] {
    display: none;
}

.filter-type-chip {
    justify-self: stretch;
    min-height: 2.2rem;
    padding: 0.35rem;
    border-radius: 10px;
    background: linear-gradient(180deg, var(--surface-bg), var(--surface-bg-soft));
    border: 1px solid var(--border-color);
    color: var(--muted-text);
    opacity: 0.8;
    display: grid;
    place-items: center;
    font-size: 1rem;
    font-weight: 600;
    letter-spacing: 0.02em;
}

.filter-type-chip.is-active {
    color: var(--page-text);
    border-color: var(--border-strong);
    opacity: 1;
}

.filter-chip {
    justify-self: stretch;
    min-height: 2.25rem;
    padding: 0.35rem;
    border-radius: 10px;
    background: linear-gradient(180deg, var(--surface-bg), var(--surface-bg-soft));
    border: 1px solid var(--border-color);
    color: var(--muted-text);
    opacity: 0.72;
    display: grid;
    place-items: center;
}

.filter-chip svg {
    width: 1rem;
    height: 1rem;
}

.filter-chip.is-active {
    color: var(--page-text);
    border-color: var(--border-strong);
    opacity: 1;
}

#output ruby.jp-ruby {
    ruby-position: over;
    ruby-align: center;
}

#output ruby.jp-ruby rt {
    font-size: 0.72em;
    line-height: 1;
    color: var(--muted-text);
    letter-spacing: 0;
}

html[data-font="secondary"] #output ruby.jp-ruby rt {
    font-size: 0.62em;
    padding-bottom: 0.7em;
    padding-top: 0.8em;
}

/* Elementos decorativos flotantes */
.deco {
    position: fixed;
    pointer-events: none;
    z-index: 0;
}

.deco-circle {
    width: 200px;
    height: 200px;
    border: 1px solid var(--decor-grid);
    border-radius: 50%;
}

/* ==========================================
   LANGUAGE TOGGLE BUTTON
   ========================================== */

.language-toggle {
    position: fixed;
    top: 2rem;
    right: 2rem;
    z-index: 50;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background: var(--panel-bg);
    backdrop-filter: blur(12px);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--page-text);
    cursor: pointer;
    font-size: 0.75rem;
    font-weight: 500;
    letter-spacing: 0.05em;
    transition: all 0.25s ease;
}

.language-toggle:hover:not(:disabled) {
    transform: translateY(-2px);
    border-color: var(--border-strong);
    background: var(--surface-bg-strong);
}

.language-toggle:active:not(:disabled) {
    transform: translateY(0);
}

.language-toggle .lang-icon {
    display: inline-block;
    width: 16px;
    height: 16px;
    filter: invert(0);
    transition: transform 0.25s ease;
}

:root:not([data-theme="light"]) .language-toggle .lang-icon {
    filter: invert(1) brightness(2);
}

[data-theme="light"] .language-toggle .lang-icon {
    filter: none;
}

.language-toggle:hover:not(:disabled) .lang-icon {
    transform: rotate(20deg);
}

.language-toggle .lang-code {
    font-family: var(--secondary-font);
    letter-spacing: 0.1em;
}

/* Back button positioning adjustment */
.back-button {
    position: fixed;
    top: 2rem;
    left: 2rem;
}

/* Responsive */
@media (max-width: 768px) {
    footer {
        justify-content: flex-start;
    }

    .language-toggle {
        top: 1.5rem;
        right: 1.5rem;
        padding: 0.4rem 0.8rem;
        font-size: 0.7rem;
    }

    .language-toggle .lang-icon {
        width: 16px;
        height: 16px;
    }

    .back-button {
        top: 1.5rem;
        left: 1.5rem;
    }

    #btn-back {
        top: 1.5rem;
        left: 1.5rem;
    }
}

@media (max-width: 480px) {
    footer {
        justify-content: flex-start;
    }

    /* Force identical, pixel-locked positions and sizes for top controls to avoid scaling differences */
    .language-toggle {
        top: 16px !important;
        right: 12px !important;
        padding: 8px 10px !important;
        gap: 6px !important;
        font-size: 12px !important;
    }

    .language-toggle .lang-code {
        display: none;
    }

    .language-toggle .lang-icon {
        width: 20px !important;
        height: 20px !important;
    }

    .back-button {
        top: 16px !important;
        left: 12px !important;
    }

    #btn-back {
        top: 16px !important;
        left: 12px !important;
    }

    /* keep language button square and prevent shrinking */
    .language-toggle {
        min-width: 36px !important;
        height: 36px !important;
        padding: 0 8px !important;
        box-sizing: border-box !important;
        align-items: center !important;
        justify-content: center !important;
    }

    #btn-back {
        width: 36px !important;
        height: 36px !important;
        padding: 0 !important;
    }

    /* enforce exact square for both controls */
    .language-toggle, #btn-back {
        width: 40px !important;
        height: 40px !important;
        padding: 0 !important;
        min-width: 40px !important;
        box-sizing: border-box !important;
        display: inline-flex !important;
        align-items: center !important;
        justify-content: center !important;
    }
}

.deco-circle-1 {
    top: 10%;
    right: 10%;
}

.deco-circle-2 {
    bottom: 15%;
    left: 5%;
    width: 150px;
    height: 150px;
}

.deco-line {
    width: 1px;
    height: 100px;
    background: linear-gradient(to bottom, transparent, var(--decor-fade), transparent);
}

.deco-line-1 {
    top: 20%;
    left: 15%;
}

.deco-line-2 {
    bottom: 25%;
    right: 20%;
    transform: rotate(45deg);
}

/* Puntos decorativos */
.deco-dots {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
}

.deco-dots span {
    width: 4px;
    height: 4px;
    background: var(--decor-fade);
    border-radius: 50%;
}

.deco-dots-1 {
    top: 30%;
    left: 8%;
}

.deco-dots-2 {
    bottom: 35%;
    right: 12%;
}
/* Back button navigation - positioned fixed on page */
#btn-back {
    position: fixed;
    top: 2rem;
    left: 2rem;
    width: 2.2rem;
    height: 2.2rem;
    padding: 0;
    font-size: 0;
    letter-spacing: 0;
    gap: 0;
    border-radius: 50%;
    background: var(--surface-bg-soft);
    color: var(--muted-text);
    border: 1px solid var(--border-color);
    opacity: 0.92;
    transition: all 0.2s ease;
    z-index: 10;
}

#btn-back:hover:not(:disabled) {
    background: var(--surface-bg-strong);
    color: var(--page-text);
    opacity: 1;
}

#btn-back:active:not(:disabled) {
    transform: scale(0.95);
}

#btn-back svg {
    transition: transform 0.2s ease;
    width: 16px;
    height: 16px;
}

#btn-back:hover:not(:disabled) svg {
    transform: translateX(-2px);
}

@media (max-width: 768px) {
    .translate-toggle {
        margin-left: 0;
    }
}
@media (max-width: 480px) {
    body {
        padding: 1rem;
    }

    .container {
        padding: 1.5rem;
    }

    footer {
        justify-content: flex-start;
    }

    .footer-spacer {
        display: block;
        min-width: 1px;
        flex: 1;
    }

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

    .filter-type-group {
        grid-template-columns: 1fr;
    }

    h1 {
        font-size: 1.75rem;
    }

    textarea,
    #output {
        min-height: 100px;
        font-size: 1rem;
    }


@media (max-width: 768px) {
    .container {
        width: calc(100vw - 4rem);
        min-width: 0;
        max-width: calc(100vw - 4rem);
    }

    #container-resize-handle {
        display: none;
    }
}

@media (max-width: 480px) {
    .container {
        width: calc(100vw - 2rem);
        max-width: calc(100vw - 2rem);
        padding: 1.25rem;
    }

    .container::before,
    .container::after,
    .corner-tl,
    .corner-br {
        width: 10px;
        height: 10px;
    }
}
    .deco {
        display: none;
    }
}
