/*** FONTS ********************************************************/

@import url('https://fonts.googleapis.com/css2?family=Share+Tech&family=Share+Tech+Mono&display=swap');

@font-face {
    font-family: "PigPen";
    src: url("../font/pigpen.otf") format("opentype");
}


/*** THEME ********************************************************/

:root {
    /* Legacy variables for backward compatibility */
    --back: #0a0e27;
    --back-high: rgba(255, 255, 255, 0.05);
    
    --text:     #ffffff;
    --text-low: #b8c5d6;
    --text-inv: #000;
    
    --accent: #00d4aa;
    --accent-secondary: #ff6b6b;
    --success: #51cf66;
    --warning: #ffd93d;
    --error: #ff6b6b;
    
    --border:      rgba(255, 255, 255, 0.1);
    --border-dark: #1a2332;

    --char-text:  #000;
    --char-back:  #fff;
    --char-high:  #FFEB3B;
    --char-first: #00d4aac0;

    --cypher-back:  #FFAB91;
    --cypher-first: #FF5722c0;

    --key-back:    #A5D6A7;
    --stream-back: #66BB6A;
    --key-back-alt:    #80DEEA;
    --stream-back-alt: #26C6DA;

    --plain-bar:  #B3E5FC;
    --cypher-bar: #FF5722;

    --secret: #B71C1C;  
    --active: #FFEB3B;  
    --border-active: #F57F17; 
    
    /* Enhanced gradients */
    --gradient-primary: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --gradient-success: linear-gradient(135deg, #a8edea 0%, #fed6e3 100%);
    --gradient-warning: linear-gradient(135deg, #ffecd2 0%, #fcb69f 100%);
}


/*** OVERALL ********************************************************/

html {
    color: var(--text);
    background: var(--back);
    background-attachment: fixed;
    font-family: 'Share Tech Mono', monospace;
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2rem;
    min-height: 100vh;
    margin: 0;
    padding: 0;
    position: relative;
    width: 100%;
    background: linear-gradient(180deg, #0a0e27 0%, #141b2d 50%, #0a0e27 100%);
}

/* Ensure lesson pages in light mode always span full viewport width */
body.lesson.light-theme {
    width: 100%;
    max-width: 100%;
}

/* Page shell full-width */
.page-shell {
    width: 100%;
    margin: 0 0 3rem 0;
    padding: 0;
}

body.home main,
body.home header,
body.home #progress-overview,
body.home #mainnav {
    width: 100%;
}

body.home main {
    margin: 0 auto 3rem;
}

body.home section {
    margin: 0 auto 2.5rem;
}

body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: 
        radial-gradient(circle at 20% 30%, rgba(0, 212, 170, 0.08), transparent 50%),
        radial-gradient(circle at 80% 70%, rgba(102, 126, 234, 0.08), transparent 50%),
        radial-gradient(circle at 50% 50%, rgba(255, 107, 107, 0.05), transparent 50%);
    z-index: -1;
    pointer-events: none;
    animation: backgroundShift 20s ease-in-out infinite;
}

@keyframes backgroundShift {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.8;
    }
}

/*** HEADINGS and TEXT ********************************************************/

h1 {
    font-size: 2em;
}

h1 i {
    font-size: 0.6em;
}

h1 a { color: var(--accent); }
h1 a:active, h1 a:hover { color: var(--text); }

.sub-heading,
.instruction {
    display: block;
    font-family: 'Share Tech', sans-serif;
    font-size: 1rem;
    color: var(--text-low);
}

.sub-heading:hover,
.sub-heading:active,
.instruction:hover,
.instruction:active {
    color: var(--text);
}

.sub-heading em {
    color: var(--accent);
}

h2 {
    font-size: 1.5rem;
    color: var(--accent);
}

h3 {
    font-family: 'Share Tech', sans-serif;
}

#crypt-cyphertext h3 {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

#crypt-cyphertext h3 i {
    margin-right: 1.5rem;
}

.key     { color: var(--key-back); }
.key.alt { color: var(--key-back-alt); }
.cypher  { color: var(--cypher-back); }

.instruction {
    font-size: 0.9rem;
}


/*** MAIN ********************************************************/

main {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    justify-content: flex-start;
    gap: 2rem;
    max-width: 1000px;
    margin: 0 auto;
    scroll-margin-top: 70px; /* Account for sticky navbar */
}

body.home main {
    align-items: stretch;
    width: 100%;
}

@media (max-width: 768px) {
    body {
        padding: 0;
        gap: var(--spacing-lg);
    }
    header {
        padding: var(--spacing-lg) var(--spacing-md);
        flex-direction: column;
        align-items: center;
        text-align: center;
    }
    
    header h1 {
        font-size: clamp(1.5rem, 6vw, 2rem);
        flex: none;
    }
    
    header .sub-heading {
        font-size: clamp(0.85rem, 3vw, 0.95rem);
        flex: none;
        max-width: 100%;
    }
    
    .search-container {
        width: 100%;
        max-width: 100%;
        margin-top: var(--spacing-md);
    }
    
    main {
        gap: var(--spacing-lg);
    }
    
    section {
        padding: var(--spacing-md);
    }
    
    section h2 {
        font-size: clamp(1.1rem, 4vw, 1.3rem);
    }
    
    input,
    textarea {
        padding: var(--spacing-xs) var(--spacing-sm);
        font-size: 0.9rem;
    }
    
    .actions {
        gap: var(--spacing-xs);
    }
    
    .actions button {
        padding: var(--spacing-xs) var(--spacing-sm);
        font-size: 0.9rem;
    }
}

@media (max-width: 480px) {
    body {
        padding: 0;
    }
    header {
        padding: var(--spacing-md) var(--spacing-sm);
    }
    
    section {
        padding: var(--spacing-sm);
    }
}



/*** RESPONSIVE NAVBAR - Enhanced with scroll effects ***/

.top-navbar {
    position: sticky;
    top: 0;
    z-index: 1000;
    background: linear-gradient(135deg, rgba(10, 14, 39, 0.95), rgba(20, 27, 45, 0.95));
    backdrop-filter: blur(20px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    transition: all 0.3s ease;
}

/* Scroll effect - navbar becomes more opaque on scroll */
.top-navbar.scrolled {
    background: linear-gradient(135deg, rgba(10, 14, 39, 0.98), rgba(20, 27, 45, 0.98));
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.4);
    border-bottom-color: rgba(0, 212, 170, 0.2);
}

/* Shrink navbar on scroll */
.top-navbar.shrunk {
    height: 60px;
}

.top-navbar.shrunk .navbar-container {
    height: 60px;
}

.top-navbar.shrunk .navbar-brand a {
    font-size: 1.3rem;
}

.navbar-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 var(--spacing-lg);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--spacing-lg);
    height: 70px;
}

.navbar-main {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--spacing-xl);
    flex: 1;
}

.navbar-brand {
    flex-shrink: 0;
    margin-right: 0;
}

.navbar-brand a {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
    text-decoration: none;
    background: linear-gradient(135deg, var(--accent), var(--secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    transition: all 0.3s ease;
}

.navbar-brand a:hover {
    transform: scale(1.05);
}

/* Primary CTA button in navbar (currently unused, reserved for future) */
.nav-cta {
    display: none;
}

/* Auth button in navbar */
.auth-btn {
    margin-left: -20px;
    padding: 0.4rem 1rem;
    border-radius: var(--radius-full);
    border: 1px solid rgba(255, 255, 255, 0.2);
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-primary);
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.25s ease;
    white-space: nowrap;
}

.auth-btn:hover {
    background: rgba(0, 212, 170, 0.15);
    border-color: rgba(0, 212, 170, 0.6);
}

.auth-btn-logged-in {
    background: rgba(0, 212, 170, 0.15);
    border-color: rgba(0, 212, 170, 0.8);
}

/* Hamburger Menu Button */
.hamburger {
    display: none;
    flex-direction: column;
    justify-content: space-around;
    width: 30px;
    height: 30px;
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 0;
    z-index: 1001;
    position: relative;
}

.hamburger-line {
    width: 100%;
    height: 3px;
    background: var(--accent);
    border-radius: 2px;
    transition: all 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    transform-origin: center;
}

/* Hamburger Animation States */
.hamburger.active .hamburger-line:nth-child(1) {
    transform: translateY(10px) rotate(45deg);
}

.hamburger.active .hamburger-line:nth-child(2) {
    opacity: 0;
    transform: scaleX(0);
}

.hamburger.active .hamburger-line:nth-child(3) {
    transform: translateY(-10px) rotate(-45deg);
}

/* Navigation Menu */
.navbar-menu {
    display: flex;
    list-style: none;
    margin: 0;
    padding: 0;
    gap: var(--spacing-md);
    align-items: center;
    flex-direction: row;
    flex-wrap: nowrap;
    justify-content: center;
}

.navbar-menu li {
    margin: 0;
}

.nav-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: var(--spacing-xs) var(--spacing-md);
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.95rem;
    font-weight: 500;
    border-radius: var(--radius-sm);
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
    white-space: nowrap;
}

.nav-link::before {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 0;
    height: 2px;
    background: linear-gradient(90deg, var(--accent), var(--secondary));
    transition: width 0.3s ease;
}

.nav-link:hover {
    color: var(--text-primary);
    background: rgba(0, 212, 170, 0.1);
}

.nav-link:hover::before {
    width: 100%;
}

.nav-link.active {
    color: var(--accent);
    background: rgba(0, 212, 170, 0.15);
}

.nav-link.active::before {
    width: 100%;
}

.nav-link:active {
    transform: scale(0.95);
}

/* Mobile Styles */
@media (max-width: 768px) {
    .hamburger {
        display: flex;
    }
    
    .navbar-menu {
        position: fixed;
        top: 70px;
        left: 0;
        width: 100%;
        padding: var(--spacing-sm) var(--spacing-md);
        margin: 0;
        background: linear-gradient(135deg, rgba(10, 14, 39, 0.98), rgba(20, 27, 45, 0.98));
        backdrop-filter: blur(20px);
        display: flex;
        flex-direction: row;
        flex-wrap: nowrap;
        justify-content: flex-start;
        align-items: center;
        gap: var(--spacing-xs);
        transform: translateY(-100%);
        transition: transform 0.3s ease;
        box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
        overflow-x: auto;
        overflow-y: hidden;
        scrollbar-width: none; /* Firefox */
        -ms-overflow-style: none;  /* IE/Edge */
    }

    .navbar-menu::-webkit-scrollbar {
        display: none; /* Chrome/Safari */
    }
    
    .navbar-menu.active {
        transform: translateY(0);
    }
    
    .navbar-menu li {
        flex: 0 0 auto;
        opacity: 0;
        animation: slideInRight 0.4s ease forwards;
    }
    
    .navbar-menu.active li {
        animation-delay: calc(var(--i, 0) * 0.05s);
    }
    
    .navbar-menu li:nth-child(1) { --i: 0; }
    .navbar-menu li:nth-child(2) { --i: 1; }
    .navbar-menu li:nth-child(3) { --i: 2; }
    .navbar-menu li:nth-child(4) { --i: 3; }
    .navbar-menu li:nth-child(5) { --i: 4; }
    .navbar-menu li:nth-child(6) { --i: 5; }
    .navbar-menu li:nth-child(7) { --i: 6; }
    
    .nav-link {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        width: auto;
        padding: var(--spacing-xs) var(--spacing-md);
        font-size: 0.95rem;
        border-left: none;
        border-radius: var(--radius-full);
        white-space: nowrap;
    }
    
    .nav-link:hover,
    .nav-link.active {
        background: rgba(0, 212, 170, 0.15);
        padding-left: var(--spacing-md);
    }
    
    /* Không cần overlay toàn màn hình nữa vì menu dạng thanh ngang */
}

/* Prevent body scroll when menu is open on mobile */
body.menu-open {
    overflow: hidden;
}

/* Animation for menu items */
@keyframes slideInRight {
    from {
        opacity: 0;
        transform: translateX(-30px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/*** THEME TOGGLE BUTTON ********************************************************/

.theme-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 999px;
    border: none;
    cursor: pointer;
    background: linear-gradient(135deg, var(--accent), var(--secondary));
    color: #fff;
    box-shadow: 0 4px 15px rgba(0, 212, 170, 0.3);
    transition: all 0.25s ease;
}

.theme-toggle--navbar {
    width: 40px;
    height: 40px;
    margin-left: -30px;
    flex-shrink: 0;
}

.theme-toggle--floating {
    position: fixed !important;
    top: 1rem !important;
    right: 1rem !important;
    width: 48px;
    height: 48px;
    z-index: 10000 !important;
    font-size: 1.5rem;
    margin: 0 !important;
    padding: 0 !important;
}

/* Theme toggle can be placed in navbar on home page */

.theme-toggle:hover {
    transform: translateY(-1px) scale(1.03);
    box-shadow: 0 6px 18px rgba(0, 212, 170, 0.4);
}

.theme-toggle:active {
    transform: translateY(0) scale(0.98);
    box-shadow: 0 3px 10px rgba(0, 212, 170, 0.25);
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

/* Tablet adjustments */
@media (min-width: 769px) and (max-width: 1024px) {
    .navbar-menu {
        gap: var(--spacing-sm);
    }
    
    .nav-link {
        font-size: 0.9rem;
        padding: var(--spacing-xs) var(--spacing-sm);
    }
}

/*** HERO SECTION - Enhanced ***/
header {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: var(--spacing-md);
    text-align: center;
    padding: 3rem var(--spacing-md);
    margin-bottom: var(--spacing-lg);
    position: relative;
    flex-wrap: wrap;
    background: linear-gradient(180deg, rgba(0, 212, 170, 0.05) 0%, transparent 50%);
    border-bottom: 1px solid rgba(0, 212, 170, 0.1);
}

/* Hero decorative elements */
header::before {
    content: '';
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 200px;
    height: 200px;
    background: radial-gradient(circle, rgba(0, 212, 170, 0.15) 0%, transparent 70%);
    pointer-events: none;
}

header::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 2px;
    background: linear-gradient(90deg, transparent 0%, var(--accent) 50%, transparent 100%);
    border-radius: var(--radius-full);
}

.hero-layout {
    width: 100%;
    max-width: 1100px;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: var(--spacing-xl);
    position: relative;
    z-index: 1;
}

.hero-text {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--spacing-md);
}

.hero-actions {
    width: 100%;
    display: flex;
    justify-content: center;
}

header::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 4px;
    background: linear-gradient(90deg, transparent, var(--accent), transparent);
    border-radius: var(--radius-full);
}

header h1 {
    font-size: clamp(1.8rem, 4vw, 2.8rem);
    margin: 0;
    background: linear-gradient(135deg, var(--accent), var(--secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    font-weight: 700;
    letter-spacing: -0.02em;
}

header .sub-heading {
    font-size: clamp(0.85rem, 1.5vw, 1rem);
    color: var(--text-secondary);
    max-width: 700px;
    margin: 0 auto;
    line-height: 1.6;
}

/* Search container as command palette */
body.home .search-container {
    width: 100%;
    max-width: 480px;
}

@media (min-width: 900px) {
    header {
        text-align: left;
        align-items: center;
    }

    .hero-layout {
        flex-direction: row;
        align-items: center;
    }

    .hero-text {
        align-items: flex-start;
        max-width: 520px;
    }

    .hero-actions {
        justify-content: flex-end;
    }

    body.home .search-container {
        max-width: 420px;
    }
}


/*** NAV OPTIONS ********************************************************/

nav {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

/* Override for mainnav to ensure vertical module flow */
#mainnav {
    display: flex;
    flex-direction: column;
    gap: 2rem;
    width: 100%;
}

#mainnav > section.module {
    width: 100%;
}

nav ul {
    flex: 1;
    display: flex;
    gap: 1rem;
    align-items: stretch;
}

/* Override for lessons-list inside modules */
#mainnav .lessons-list {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

nav li {
    flex: 1;
}

nav a {
    display: block;
    padding: 0.3rem 0.5rem;
    background: var(--border);
    color: var(--text);
    text-decoration: none;
    border-radius: 0.3rem;
    font-size: 1.2rem;
    font-family: 'Share Tech', sans-serif;
}

nav a:hover,
nav a:active {
    background: var(--accent);
    /* color: var(--accent); */
}

nav .note {
    display: block;
    margin-top: 0.5rem;
    font-size: 0.8em;
}


/*** SECTIONS ********************************************************/

section {
    width: 100%;
    padding: var(--spacing-lg);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: var(--radius-md);
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.05), rgba(255, 255, 255, 0.02));
    backdrop-filter: blur(15px);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2), inset 0 1px 0 rgba(255, 255, 255, 0.05);
    transition: all var(--transition-base);
}

section:hover {
    border-color: rgba(0, 212, 170, 0.2);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

section h2 {
    margin-bottom: var(--spacing-md);
    font-size: clamp(1.3rem, 3vw, 1.6rem);
    color: var(--accent);
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
}

section .group {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-sm);
    align-items: stretch;
}

section .group:not(:last-of-type) {
    margin-bottom: 0.5rem;
}

body:is(.scheme-symmetric, .scheme-asymmetric) section .group:not(:last-of-type) {
    margin-bottom: 1rem;
}

section .group h3 {
    font-size: 1rem;
}

#crypt-mapping h3 {
    display: none;
}

#crypt-cyphertext {
    flex-direction: column-reverse;
}

#options img {
    flex: 1;
}

#transmission {
    display: none;
}

#transmission :is(.icon-right, .icon-left) { display: none; }
#transmission :is(.icon-up, .icon-down)    { display: inline; }

body:is(.scheme-symmetric, .scheme-asymmetric) #transmission {
    display: flex;
    flex-direction: row;
    justify-content: center;
    gap: 1rem;
    padding: 0;
    border: none;
    background: none;
    font-size: 4rem;
    color: var(--border);
    text-align: center;
}

body:is(.scheme-symmetric, .scheme-asymmetric) #transmission.sending {
    color: var(--char-high);
}

/*** MODERN LAYOUT FOR SYMMETRIC / ASYMMETRIC DEMOS *****************/

/* Base grid layout for symmetric demo (has charts section) */
body.scheme-symmetric main {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
    grid-template-areas:
        "userA transmission userB"
        "charts charts charts"
        "userE userE userE";
    gap: 1.5rem;
    width: 100%;
    max-width: 1400px;
    padding: 0 1.5rem 2rem;
    margin: 0 auto;
    align-items: start;
}

body.scheme-symmetric #user-A { grid-area: userA; }
body.scheme-symmetric #user-B { grid-area: userB; }
body.scheme-symmetric #user-E { grid-area: userE; }
body.scheme-symmetric #charts { grid-area: charts; }
body.scheme-symmetric #transmission { grid-area: transmission; }

/* Base layout for asymmetric demo (no charts section) */
body.scheme-asymmetric main {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
    grid-template-areas:
        "userA transmission userB"
        "userE userE userE";
    gap: 1.5rem;
    width: 100%;
    max-width: 1400px;
    padding: 0 1.5rem 2rem;
    margin: 0 auto;
    align-items: start;
}

body.scheme-asymmetric #user-A { grid-area: userA; }
body.scheme-asymmetric #user-B { grid-area: userB; }
body.scheme-asymmetric #user-E { grid-area: userE; }
body.scheme-asymmetric #transmission { grid-area: transmission; }

/* Symmetric / Asymmetric demo header + cards */
.symmetric-header {
    width: 100%;
    max-width: 1400px;
    padding: 1.75rem 1.5rem 0;
    margin: 0 auto;
}

.symmetric-header__content {
    display: flex;
    flex-direction: row;
    justify-content: space-between;
    gap: 2rem;
    align-items: flex-start;
}

.symmetric-header__title {
    max-width: 720px;
}

.symmetric-header__meta {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    align-items: flex-end;
}

.pill {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.35rem 0.85rem;
    border-radius: 999px;
    font-size: 0.8rem;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    background: rgba(10, 255, 191, 0.08);
    border: 1px solid rgba(0, 212, 170, 0.5);
    color: var(--accent);
}

.pill--live {
    background: rgba(0, 212, 170, 0.12);
}

.pill--concept {
    background: rgba(102, 126, 234, 0.1);
    border-color: rgba(102, 126, 234, 0.7);
    color: #a5b4fc;
}

.pill--analysis {
    background: rgba(255, 255, 255, 0.06);
    border-color: rgba(255, 255, 255, 0.25);
    color: var(--text);
}

.symmetric-card {
    position: relative;
    overflow: hidden;
}

.symmetric-card::before {
    content: '';
    position: absolute;
    inset: 0;
    pointer-events: none;
    background: radial-gradient(circle at top left, rgba(0, 212, 170, 0.12), transparent 55%);
    opacity: 0.7;
    mix-blend-mode: screen;
}

.symmetric-card--bob::before {
    background: radial-gradient(circle at top right, rgba(102, 126, 234, 0.18), transparent 55%);
}

.symmetric-card--eve::before {
    background: radial-gradient(circle at top, rgba(255, 107, 107, 0.2), transparent 60%);
}

.symmetric-card--charts::before {
    background: radial-gradient(circle at top, rgba(0, 212, 170, 0.18), transparent 65%);
}

.symmetric-card__header {
    position: relative;
    display: flex;
    gap: 0.75rem;
    align-items: flex-start;
    margin-bottom: 0.75rem;
}

.symmetric-card__header--inline {
    justify-content: space-between;
    align-items: center;
}

.symmetric-card__subtitle {
    margin: 0.25rem 0 0;
    font-size: 0.85rem;
    color: var(--text-low);
    max-width: 30rem;
}

.step-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.1rem 0.6rem;
    border-radius: 999px;
    font-size: 0.68rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    background: rgba(0, 212, 170, 0.18);
    border: 1px solid rgba(0, 212, 170, 0.7);
    color: var(--accent);
    margin-top: 0.15rem;
}

.step-badge--danger {
    background: rgba(255, 107, 107, 0.16);
    border-color: rgba(255, 107, 107, 0.8);
    color: #ff6b6b;
}

body:is(.scheme-symmetric, .scheme-asymmetric) section.user {
    border-radius: var(--radius-lg);
    border: 1px solid rgba(255, 255, 255, 0.10);
    background: rgba(10, 18, 32, 0.55);
    backdrop-filter: blur(14px);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.35);
    padding: 1rem;
}

body:is(.scheme-symmetric, .scheme-asymmetric) section.user h2 {
    margin-bottom: 0.75rem;
    font-size: 1.05rem;
    color: var(--text-primary);
}

body:is(.scheme-symmetric, .scheme-asymmetric) section.user .group {
    padding: 0.75rem;
    border-radius: var(--radius-md);
    border: 1px solid rgba(255, 255, 255, 0.08);
    background: rgba(255, 255, 255, 0.03);
}

body:is(.scheme-symmetric, .scheme-asymmetric) section.user .group h3 {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin: 0;
}

body:is(.scheme-symmetric, .scheme-asymmetric) section.user textarea {
    width: 100%;
    min-height: 3.25rem;
    resize: vertical;
}

body:is(.scheme-symmetric, .scheme-asymmetric) section.user textarea[disabled] {
    opacity: 0.85;
}

body:is(.scheme-symmetric, .scheme-asymmetric) section.user .actions {
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    justify-content: flex-end;
    align-items: center;
    gap: 0.5rem;
    width: 100%;
}

body:is(.scheme-symmetric, .scheme-asymmetric) section.user .actions button {
    min-width: 6.5rem;
    flex: 0 0 auto;
}

/* Accessibility: focus states cho keyboard navigation */
body:is(.scheme-symmetric, .scheme-asymmetric) section.user .actions button:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

body:is(.scheme-symmetric, .scheme-asymmetric) section.user textarea:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

@media (max-width: 640px) {
    body:is(.scheme-symmetric, .scheme-asymmetric) section.user .actions {
        flex-direction: row;
        flex-wrap: wrap;
        justify-content: center;
        align-items: stretch;
    }

    body:is(.scheme-symmetric, .scheme-asymmetric) section.user .actions button {
        flex: 1 1 calc(50% - 0.5rem);
        min-width: 0;
        text-align: center;
    }
}

/* Keep the transmission arrows centered and visually lighter */
body:is(.scheme-symmetric, .scheme-asymmetric) #transmission {
    align-self: center;
    justify-self: center;
    font-size: 3rem;
    opacity: 0.8;
}

/* Charts area: show in two columns on desktop (symmetric only) */
body.scheme-symmetric #charts {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.symmetric-transmission {
    display: flex;
    align-items: center;
    justify-content: center;
    padding-inline: 0.5rem;
}

/* Responsive: tablet (768px - 1024px) - 2 cột cho user cards */
@media (min-width: 769px) and (max-width: 1024px) {
    body:is(.scheme-symmetric, .scheme-asymmetric) main {
        grid-template-columns: 1fr 1fr;
        gap: 1.25rem;
    }

    body.scheme-symmetric main {
        grid-template-areas:
            "userA userB"
            "transmission transmission"
            "charts charts"
            "userE userE";
    }

    body.scheme-asymmetric main {
        grid-template-areas:
            "userA userB"
            "transmission transmission"
            "userE userE";
    }

    body:is(.scheme-symmetric, .scheme-asymmetric) #transmission {
        justify-self: center;
        font-size: 2.5rem;
    }
}

/* Responsive: stack everything on narrow screens */
@media (max-width: 768px) {
    body.scheme-symmetric main {
        grid-template-columns: 1fr;
        grid-template-areas:
            "userA"
            "transmission"
            "userB"
            "charts"
            "userE";
    }

    body.scheme-symmetric #charts {
        grid-template-columns: 1fr;
    }

    body.scheme-asymmetric main {
        grid-template-columns: 1fr;
        grid-template-areas:
            "userA"
            "transmission"
            "userB"
            "userE";
    }
}



/*** INPUTS ********************************************************/

input,
textarea {
    font-size: 1rem;
    font-family: var(--font-mono);
    padding: var(--spacing-sm) var(--spacing-md);
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: var(--radius-sm);
    text-transform: uppercase;
    color: var(--text-primary);
    transition: all var(--transition-base);
    backdrop-filter: blur(10px);
}

/* Auth forms + email fields should keep original casing */
.auth-form input,
input[type="email"] {
    text-transform: none;
}

input::placeholder,
textarea::placeholder {
    color: var(--text-muted);
    opacity: 0.6;
}

body:is(.scheme-symmetric, .scheme-asymmetric) :is(input, textarea) {
    text-transform: none;
}

input:focus,
textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(0, 212, 170, 0.15), 0 4px 12px rgba(0, 212, 170, 0.1);
    background: rgba(255, 255, 255, 0.08);
}

input[type="text"],
textarea {
    flex: 1;
}

input[type="number"] {
    width: 4rem;
    /* padding: 0.1rem 0.2rem; */
}

/* Inputs/Textareas: use darker translucent backgrounds across demos for better contrast */
.plaintext-text,
.cyphertext-text,
.key-value,
.key-text,
.key-stream {
    background: rgba(255, 255, 255, 0.06);
    border-color: rgba(255, 255, 255, 0.18);
    color: var(--text-primary);
}

/* Key (Shift) input – make it wider for readability */
input.key-value[type="number"] {
    min-width: 6rem;
    padding-inline: 0.75rem;
    text-align: center;
}

/* Slightly different tint for alt fields */
.key-value.alt,
.key-stream.alt {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.22);
}

textarea:is(.key-value, .key-stream) {
    min-height: 4rem;
    height: auto;
    word-break: break-all;
}

/* Tối ưu cho key-stream (private key dài trong asymmetric) */
textarea.key-stream {
    min-height: 5.5rem;
    font-size: 0.85rem;
    line-height: 1.4;
    font-family: 'Share Tech Mono', monospace;
}

textarea.cyphertext-text {
    min-height: 11rem;
    height: auto;
    word-break: break-all;
}

textarea.plaintext-text {
    min-height: 8rem;
    height: auto;
}

:is(input, textarea):is(.sending, .receiving),
:is(input, textarea).alt:is(.sending, .receiving) {
    background: var(--active);
    border-color: var(--border-active);
}

:is(.plaintext-text, .cyphertext-text, .key-value, .key-stream).using { 
    background: var(--active); 
    border-color: var(--border-active);
}

textarea:placeholder-shown,
textarea.alt:placeholder-shown {
    background: var(--back-high);
    color: var(--border);
    border-color: var(--border-dark);
}

.privatekey {
    position: relative;
}

.privatekey textarea,
.privatekey textarea.alt {
    border-color: var(--secret);
}

.privatekey::before {
    content: '\e800';
    position: absolute;
    top: 2.2rem;
    right: 0.3rem;
    font-family: "fontello";
    font-size: 3rem;
    display: block;
    width: 1em;
    text-align: center;
    line-height: 1em;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    color: var(--secret);
    /* text-shadow: 0 0.1rem 0rem #00000040; */
}


/*** ACTION BUTTONS ********************************************************/

.actions {
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    gap: var(--spacing-sm);
}

.actions button {
    min-width: 5rem;
    font-size: 1rem;
    font-family: var(--font-primary);
    font-weight: 600;
    background: linear-gradient(135deg, rgba(0, 212, 170, 0.2), rgba(102, 126, 234, 0.15));
    color: var(--text-primary);
    border: 1px solid rgba(0, 212, 170, 0.3);
    border-radius: var(--radius-sm);
    padding: var(--spacing-sm) var(--spacing-md);
    cursor: pointer;
    transition: all var(--transition-base);
    backdrop-filter: blur(10px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.actions button:hover,
.actions button:active {
    background: linear-gradient(135deg, var(--accent), var(--secondary));
    border-color: var(--accent);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 212, 170, 0.3);
}

/* Button states: disabled và loading */
.actions button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
    pointer-events: none;
}

.actions button.loading {
    position: relative;
    color: transparent;
    pointer-events: none;
}

.actions button.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 1rem;
    height: 1rem;
    margin: -0.5rem 0 0 -0.5rem;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: var(--text-primary);
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}


/*** CHARS ********************************************************/

.scheme-vignere #cyphertext-chars {
    flex: 1;
    flex-direction: column;
}

.row {
    flex: 1;
    display: flex;
    align-items: center;
}

.grid {
    flex: 1;
    display: flex;
    flex-wrap: nowrap;
    gap: 0.35rem;
    justify-content: center;
    min-width: max-content;
}

.grid span {
    /* Keep each cell the same width so 3 rows stay aligned */
    flex: 0 0 var(--crypt-cell, 2.2rem);
    display: block;
    text-align: center;
}

.char {
    font-size: 1.4rem;
    padding: 0.25rem 0;
    color: var(--char-text);
    background: var(--char-back);
    border: 1px solid var(--border);
}

#cyphertext-chars .char { background: var(--cypher-back); }
.scheme-vignere #cyphertext-chars .char { background: var(--char-back); }

#plaintext-chars .char.start { background: var(--char-back) linear-gradient( to right, var(--char-first) 0%, var(--char-back) 100% ); }
#cyphertext-chars .char.start { background: var(--cypher-back) linear-gradient( to right, var(--cypher-first) 0%, var(--cypher-back) 100% ); }
.scheme-vignere #cyphertext-chars .char.start { background: var(--char-back) linear-gradient( to right, var(--cypher-first) 0%, var(--char-back) 100% ); }

#mapping span > i {
    display: none;
}

#mapping span > i.active {
    display: block;
}


.scheme-vignere .row .char {
    font-size: 1rem;
    padding: 0;
}

.scheme-vignere #cyphertext-chars .row.highlight .char {
    background: var(--cypher-back);
    font-size: 1.4rem;
    padding: 0.2rem 0;
}

#plaintext-chars .char.highlight,
#cyphertext-chars .char.highlight,
.scheme-vignere #cyphertext-chars .row.highlight .char.highlight {
    background: var(--char-high);
}

.char.highlight,
.scheme-vignere .row.highlight .char.highlight,
.scheme-vignere .row.highlight .char:first-of-type {
    font-weight: bold;
}

.scheme-vignere #cyphertext-chars .row.highlight .char:first-of-type {
    background: var(--stream-back);
}

#mapping .highlight {
    color: var(--char-high);
}


.scheme-pigpen #plaintext-text {
    letter-spacing: 0.3rem;
}

/* Improve contrast for Pigpen inputs so text không trùng với nền trắng */
.scheme-pigpen .plaintext-text {
    background: rgba(255, 255, 255, 0.06);
    border-color: rgba(255, 255, 255, 0.18);
    color: var(--text-primary);
}

.scheme-pigpen #cyphertext-text,
.scheme-pigpen #cyphertext-chars {
    font-family: 'PigPen', monospace;
}

.scheme-pigpen .char {
    font-size: 1rem;
}



/*** CHARTS ********************************************************/

.chart {
    height: 5.5rem;
    flex: 1;
    padding: 0.5rem;
    border-radius: 0.3rem;
    background: var(--back-high);
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    gap: 0.3rem;
}

body:is(.scheme-symmetric, .scheme-asymmetric) .chart {
    height: 6.5rem;
}

.chart > div {
    display: flex;
    gap: 2px;
    align-items: flex-end;
}

.chart label,
.chart .bar {
    display: block;
    flex: 1;
}

.chart label {
    font-size: 0.6rem;
    text-align: center;
}

body:is(.scheme-symmetric, .scheme-asymmetric) .chart label {
    font-size: 0.5rem;
}

.chart .bar {
    background-color: var(--plain-bar);
    min-height: 2px;
}

#cyphertext-chart .bar {
    background-color: var(--cypher-bar);
}

/* Frequency Analysis card layout for symmetric/asymmetric demos */
body:is(.scheme-symmetric, .scheme-asymmetric) .freq-card {
    position: relative;
    padding: 2.5rem 2.5rem;
    border-radius: 1.5rem;
    background: radial-gradient(circle at top left,
                rgba(255, 255, 255, 0.06),
                rgba(255, 255, 255, 0.02));
}

body:is(.scheme-symmetric, .scheme-asymmetric) .freq-row {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 1.5rem;
    align-items: center;
    margin-top: 1.5rem;
}

body:is(.scheme-symmetric, .scheme-asymmetric) .freq-label {
    display: flex;
    flex-direction: column;
    justify-content: center;
    font-family: 'Share Tech', sans-serif;
    font-size: 1.1rem;
    font-weight: 700;
    text-align: right;
    line-height: 1.1;
    color: var(--text);
}

body:is(.scheme-symmetric, .scheme-asymmetric) .freq-label--cypher {
    color: var(--cypher-bar);
}

body:is(.scheme-symmetric, .scheme-asymmetric) .freq-group {
    margin: 0;
}

body:is(.scheme-symmetric, .scheme-asymmetric) .freq-group .chart {
    border-radius: 0.6rem;
    background: rgba(5, 10, 30, 0.9);
}

@media (max-width: 768px) {
    body:is(.scheme-symmetric, .scheme-asymmetric) .freq-row {
        grid-template-columns: 1fr;
        text-align: left;
    }

    body:is(.scheme-symmetric, .scheme-asymmetric) .freq-label {
        text-align: left;
        align-items: flex-start;
    }
}



/*** ICON TWEAKS ********************************************************/

[class^="icon-"]::before, 
[class*=" icon-"]::before {
    width: auto;
    margin-right: 0;
    line-height: 1.2em;
    margin-left: 0;
    font-size: 100%;
}


/*** AUTH MODAL ********************************************************/

.auth-modal.hidden {
    display: none;
}

.auth-modal {
    position: fixed;
    inset: 0;
    z-index: 1100;
    display: flex;
    align-items: center;
    justify-content: center;
}

.auth-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(8px);
}

.auth-dialog {
    position: relative;
    z-index: 1;
    width: 100%;
    max-width: 420px;
    background: linear-gradient(135deg, rgba(10, 14, 39, 0.98), rgba(20, 27, 45, 0.98));
    border-radius: var(--radius-lg);
    border: 1px solid rgba(255, 255, 255, 0.15);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
    padding: var(--spacing-lg);
    display: flex;
    flex-direction: column;
    gap: var(--spacing-md);
}

.auth-close {
    position: absolute;
    top: 0.75rem;
    right: 1rem;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 1.3rem;
    cursor: pointer;
}

.auth-tabs {
    display: flex;
    gap: var(--spacing-sm);
    margin-bottom: var(--spacing-sm);
}

.auth-tab {
    flex: 1;
    padding: 0.5rem 0.8rem;
    border-radius: var(--radius-full);
    border: 1px solid rgba(255, 255, 255, 0.15);
    background: transparent;
    color: var(--text-secondary);
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.25s ease;
}

.auth-tab.active {
    background: rgba(0, 212, 170, 0.18);
    border-color: rgba(0, 212, 170, 0.8);
    color: var(--text-primary);
}

.auth-body {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-md);
}

.auth-form.hidden,
.auth-profile.hidden,
.auth-tabs.hidden {
    display: none;
}

.auth-form label {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    font-size: 0.85rem;
    margin-bottom: 0.5rem;
}

.auth-form input {
    padding: 0.45rem 0.75rem;
    border-radius: var(--radius-sm);
    border: 1px solid rgba(255, 255, 255, 0.2);
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-primary);
    font-family: var(--font-mono);
    font-size: 0.9rem;
}

.auth-password-field .auth-password-wrapper {
    display: flex;
    align-items: center;
    gap: 0.35rem;
}

.auth-password-wrapper input {
    flex: 1;
}

.auth-toggle-password {
    border: 1px solid rgba(255, 255, 255, 0.2);
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-secondary);
    border-radius: var(--radius-full);
    width: 2.1rem;
    height: 2.1rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.auth-toggle-password:hover {
    background: rgba(0, 212, 170, 0.15);
    color: var(--text-primary);
}

.auth-submit {
    margin-top: 0.5rem;
    width: 100%;
    padding: 0.5rem 0.75rem;
    border-radius: var(--radius-md);
    border: none;
    background: linear-gradient(135deg, var(--accent), var(--secondary));
    color: var(--text-inv);
    font-weight: 600;
    font-size: 0.9rem;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    box-shadow: 0 4px 14px rgba(0, 212, 170, 0.3);
}

.auth-submit:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 18px rgba(0, 212, 170, 0.4);
}

.auth-hint {
    margin-top: 0.5rem;
    font-size: 0.75rem;
    color: var(--text-low);
}

.auth-hint a,
.auth-forgot-link {
    color: rgba(0, 212, 170, 0.9);
    text-decoration: none;
    transition: color 0.2s ease;
}

.auth-hint a:hover,
.auth-forgot-link:hover {
    color: rgba(0, 212, 170, 1);
    text-decoration: underline;
}

.auth-form h3 {
    margin: 0 0 1rem 0;
    font-size: 1.1rem;
    color: var(--text-primary);
}

.auth-resend-otp {
    margin-top: 0.5rem;
    padding: 0.4rem 0.8rem;
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: var(--text-secondary);
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.auth-resend-otp:hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-primary);
    border-color: rgba(255, 255, 255, 0.3);
}

#authOTPCode {
    text-align: center;
    font-size: 1.2rem;
    letter-spacing: 0.5rem;
    font-weight: 600;
}

.auth-message {
    margin-top: 0.4rem;
    font-size: 0.8rem;
}

.auth-message.error {
    color: #ff6b6b;
}

.auth-message.success {
    color: #51cf66;
}

.auth-profile h3 {
    margin: 0 0 0.5rem 0;
    font-size: 1rem;
}

.auth-profile p {
    margin: 0 0 0.75rem 0;
    font-size: 0.85rem;
    color: var(--text-low);
}

.auth-profile .auth-logout {
    padding: 0.4rem 0.9rem;
    border-radius: var(--radius-full);
    border: 1px solid rgba(255, 255, 255, 0.2);
    background: transparent;
    color: var(--text-secondary);
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.auth-profile .auth-logout:hover {
    background: rgba(255, 107, 107, 0.1);
    border-color: rgba(255, 107, 107, 0.7);
    color: #ff6b6b;
}


/*** RESPONSIVE ********************************************************/

@media screen and (min-width: 35rem) {
    html {
        font-size: 20px;
    }
}


@media screen and (min-width: 50rem) {
    section .group {
        flex-direction: row;
        align-items: center;
    }

    body:is(.scheme-symmetric, .scheme-asymmetric) section .group {
        align-items: flex-start;
    }

    section .group h3 {
        width: 5.5rem;
        text-align: right;
    }

    section img,
    section input[type="text"] {
        width: calc(100% - 6rem);
    }

    #crypt-mapping h3 {
        display: block;
    }

    #crypt-cyphertext {
        flex-direction: row;
    }

    /* Desktop layout overrides for symmetric/asymmetric user cards:
       keep label + textarea + actions stacked so buttons have full width */
    body:is(.scheme-symmetric, .scheme-asymmetric) section.user .group {
        flex-direction: column;
        align-items: stretch;
    }

    body:is(.scheme-symmetric, .scheme-asymmetric) section.user .group h3 {
        width: auto;
        text-align: left;
        margin-bottom: 0.35rem;
    }

    .privatekey::before {
        top: 0.3rem;
        right: 5.7rem;
    }
    
}


@media screen and (min-width: 90rem) {
    body {
        max-width: unset;
        margin: 0;
    }

    body.home {
        flex-direction: column !important;
        gap: 2rem;
        align-items: center;
    }

    /* Keep a vertical flow for regular pages (including lesson pages) */
    body:not(:is(.home, .scheme-symmetric, .scheme-asymmetric)) {
        flex-direction: column;
        gap: 2rem;
        align-items: center;
    }

    /* Removed old sidebar layout CSS - not needed for new home page design */
    body.home header { 
        width: 100% !important;
        max-width: 100% !important;
    }
    
    body.home main { 
        width: 100% !important;
        max-width: 1000px !important;
    }
    
    body.home {
        display: flex !important;
        flex-direction: column !important;
        align-items: center !important;
        max-width: 100% !important;
    }
    
    body.home main img {
        width: 100%;
    }    

    body:is(.scheme-symmetric, .scheme-asymmetric) header {
        flex-wrap: nowrap;
        align-items: flex-start;
        gap: 2rem;
    }
    
    body:is(.scheme-symmetric, .scheme-asymmetric) header h1 {
        min-width: 30%;
    }
    
    body:is(.scheme-symmetric, .scheme-asymmetric) main {
        margin-top: 1rem;
        flex-direction: row;
        flex-wrap: wrap;
        align-items: flex-start;
        justify-content: center;
        gap: 1.5rem;
    }

    /* Tất cả section trong demo symmetric/asymmetric full-width,
       nhưng vẫn giới hạn tối đa để đọc dễ hơn trên màn hình cực rộng */
    body:is(.scheme-symmetric, .scheme-asymmetric) main section {
        width: 100%;
        max-width: 1400px;
    }

    body:is(.scheme-symmetric, .scheme-asymmetric) #user-A       { order: 1; }
    body:is(.scheme-symmetric, .scheme-asymmetric) #transmission { order: 2; align-self: center; }
    body:is(.scheme-symmetric, .scheme-asymmetric) #user-B       { order: 3; }
    body:is(.scheme-symmetric, .scheme-asymmetric) #charts       { order: 4; }
    body:is(.scheme-symmetric, .scheme-asymmetric) #user-E       { order: 5; }

    body:is(.scheme-symmetric, .scheme-asymmetric) #transmission {
        flex-direction: column;
    }

    #transmission :is(.icon-right, .icon-left) { display: inline; }
    #transmission :is(.icon-up, .icon-down)    { display: none; }

    /* Keep encryption mapping inside the viewport; scroll horizontally if needed */
    #encryption {
        min-width: 0;
        width: 100%;
        max-width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
}
