/* Savage SLA Operative Sheet - CSS Design System */
:root {
    --bg-dark: #090d16;
    --card-bg: rgba(18, 24, 38, 0.88);
    --border-color: rgba(56, 189, 248, 0.4);
    --border-hover: rgba(56, 189, 248, 0.8);
    --text-main: #f1f5f9;
    --text-muted: #94a3b8;
    --primary: #38bdf8;
    --accent-purple: #c084fc;
    --accent-pink: #f472b6;
    --accent-red: #f43f5e;
    --accent-green: #34d399;
    --sidebar-bg: #0f172a;
    --input-bg: rgba(15, 23, 42, 0.75);
    --input-border: rgba(56, 189, 248, 0.3);
    --font-family: system-ui, -apple-system, BlinkMacSystemFont, "Outfit", "Segoe UI", sans-serif;
}

/* Classic Paper White Theme */
body.theme-paper {
    --bg-dark: #f8fafc;
    --card-bg: #ffffff;
    --border-color: #000000;
    --border-hover: #1e293b;
    --text-main: #0f172a;
    --text-muted: #475569;
    --primary: #0284c7;
    --accent-purple: #9333ea;
    --accent-pink: #db2777;
    --accent-red: #e11d48;
    --accent-green: #059669;
    --sidebar-bg: #ffffff;
    --input-bg: #f1f5f9;
    --input-border: #94a3b8;
    background-image: none;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    padding: 0;
    font-family: var(--font-family);
    background-color: var(--bg-dark);
    color: var(--text-main);
    display: flex;
    min-height: 100vh;
    transition: background-color 0.3s ease, color 0.3s ease;
    background-image: 
        radial-gradient(circle at 15% 15%, rgba(56, 189, 248, 0.04) 0%, transparent 40%),
        radial-gradient(circle at 85% 85%, rgba(192, 132, 252, 0.04) 0%, transparent 40%);
}

/* Sidebar Navigation & Collapsible Accordion */
.sidebar {
    width: 270px;
    background-color: var(--sidebar-bg);
    border-right: 1px solid var(--border-color);
    padding: 2rem 1.2rem;
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    transition: width 0.3s cubic-bezier(0.16, 1, 0.3, 1), padding 0.3s ease;
}

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

.sidebar-header .logo {
    margin-bottom: 0;
}

/* Toggle Knap Placeret Inde i Hovedmenuen */
.sidebar-collapse-btn {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-main);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 0.95rem;
    font-weight: 800;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.sidebar-collapse-btn:hover {
    background: rgba(56, 189, 248, 0.2);
    color: var(--primary);
    border-color: var(--primary);
}

.sidebar-collapse-btn .toggle-icon {
    display: inline-block;
    transition: transform 0.3s ease;
}

/* Mini-Ikon Rail Tilstand (Når Menuen Er Kollapset Inde i Siden) */
.sidebar.collapsed {
    width: 68px !important;
    padding: 1.8rem 0.6rem !important;
}

.sidebar.collapsed .logo-text,
.sidebar.collapsed .menu-title,
.sidebar.collapsed .item-text,
.sidebar.collapsed .chevron-icon {
    display: none !important;
}

.sidebar.collapsed .sidebar-header {
    justify-content: center;
    flex-direction: column-reverse;
    gap: 12px;
    margin-bottom: 1.5rem;
}

.sidebar.collapsed .sidebar-collapse-btn .toggle-icon {
    transform: rotate(180deg);
}

.sidebar.collapsed .menu-item a {
    justify-content: center;
    padding: 0.65rem 0;
    font-size: 1.2rem;
}


.logo {
    font-size: 1.35rem;
    font-weight: 800;
    margin-bottom: 1.8rem;
    color: var(--text-main);
    display: flex;
    align-items: center;
    gap: 8px;
    text-decoration: none;
}

.logo .badge {
    background: linear-gradient(135deg, var(--primary), var(--accent-purple));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    font-weight: 900;
}

.menu-section {
    margin-bottom: 1.5rem;
}

.menu-title {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    font-weight: 700;
    padding-left: 0.75rem;
    margin-bottom: 0.5rem;
}

/* Fold-out Collapsible Accordion Button Title */
.menu-title.collapsible-title {
    width: 100%;
    background: none;
    border: none;
    padding: 0.45rem 0.75rem;
    margin-bottom: 0.35rem;
    font-family: inherit;
    font-size: 0.72rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
    border-radius: 6px;
    transition: all 0.2s ease;
    user-select: none;
    text-align: left;
}

.menu-title.collapsible-title:hover {
    color: var(--text-main);
    background: rgba(255, 255, 255, 0.06);
}

body.theme-paper .menu-title.collapsible-title:hover {
    background: rgba(0, 0, 0, 0.05);
}

.menu-title.collapsible-title .chevron-icon {
    font-size: 0.75rem;
    transition: transform 0.25s ease;
    display: inline-block;
}

.menu-title.collapsible-title.collapsed .chevron-icon {
    transform: rotate(-90deg);
}

.menu-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    transition: all 0.3s ease;
}

.menu-list.collapsible-list {
    overflow: hidden;
}

.menu-list.collapsible-list.collapsed {
    display: none;
}

.menu-item a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0.65rem 0.85rem;
    text-decoration: none;
    color: var(--text-muted);
    border-radius: 8px;
    font-weight: 500;
    font-size: 0.9rem;
    transition: all 0.2s ease;
}

.menu-item a:hover {
    background-color: rgba(125, 125, 125, 0.1);
    color: var(--text-main);
}

.menu-item.active a {
    background: rgba(56, 189, 248, 0.12);
    color: var(--primary);
    border: 1px solid var(--border-color);
    font-weight: 600;
}

/* Main Container */
.main-content {
    flex: 1;
    padding: 2.5rem 3rem;
    max-width: 1240px;
}

/* Control Bar (Top) */
.control-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 14px;
    padding: 1.2rem 1.8rem;
    margin-bottom: 2rem;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.control-group {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    flex-wrap: wrap;
}

.control-label {
    font-size: 0.85rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
}

.select-input, .btn-action {
    background: var(--input-bg);
    color: var(--text-main);
    border: 1.5px solid var(--input-border);
    padding: 0.5rem 0.9rem;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.select-input:focus, .btn-action:hover {
    border-color: var(--primary);
    outline: none;
}

.btn-action.primary {
    background: var(--primary);
    color: #0f172a;
    font-weight: 700;
    border: none;
}

.btn-action.primary:hover {
    filter: brightness(1.1);
    transform: translateY(-1px);
}

/* Admin & Værktøjer Undermenu Dropdown */
.admin-dropdown-container {
    position: relative;
    display: inline-block;
}

.admin-dropdown-menu {
    display: none;
    position: absolute;
    right: 0;
    top: calc(100% + 8px);
    background: var(--card-bg);
    border: 1.5px solid var(--border-color);
    border-radius: 10px;
    padding: 0.5rem;
    min-width: 230px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.4), 0 0 15px rgba(0, 0, 0, 0.2);
    z-index: 500;
    flex-direction: column;
    gap: 0.35rem;
}

body.theme-paper .admin-dropdown-menu {
    background: #ffffff;
    border-color: #cbd5e1;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15);
}

.admin-dropdown-menu.show {
    display: flex;
}

.dropdown-item {
    background: transparent;
    border: none;
    color: var(--text-main);
    padding: 0.6rem 0.85rem;
    border-radius: 6px;
    font-size: 0.88rem;
    font-weight: 600;
    font-family: inherit;
    text-align: left;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.15s ease;
    width: 100%;
}

body.theme-paper .dropdown-item {
    color: #1e293b;
}

.dropdown-item:hover {
    background: rgba(56, 189, 248, 0.15);
    color: var(--primary);
}

body.theme-paper .dropdown-item:hover {
    background: rgba(2, 132, 199, 0.12);
    color: #0284c7;
}

.dropdown-item.danger {
    color: var(--accent-red);
}

.dropdown-item.danger:hover {
    background: rgba(244, 63, 94, 0.15);
    color: var(--accent-red);
}

.dropdown-divider {
    height: 1px;
    background: var(--border-color);
    margin: 0.25rem 0;
}

/* Character Sheet Grid & Boxes */
.sheet-header {
    border: 2px solid var(--border-color);
    border-radius: 12px;
    padding: 1.5rem;
    background: var(--card-bg);
    margin-bottom: 2rem;
    position: relative;
}

.header-main-layout {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1.5rem;
}

.header-left-col {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 1.2rem;
    min-width: 0;
}

.sheet-title {
    font-size: 1.6rem;
    font-weight: 900;
    letter-spacing: 0.05em;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

/* Dynamic Responsive Header Grid */
.header-fields {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1.2rem;
}

@media (max-width: 900px) {
    .header-main-layout {
        flex-direction: column-reverse;
        align-items: center;
    }
}

/* Larger Operative ID Badge Frame in Top Header Card (115px x 115px) */
.mini-portrait-box {
    width: 115px;
    height: 115px;
    min-width: 115px;
    min-height: 115px;
    border: 2.5px solid var(--primary);
    border-radius: 12px;
    background: rgba(15, 23, 42, 0.75);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    cursor: pointer;
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.4), 0 0 14px rgba(56, 189, 248, 0.25);
    transition: all 0.25s ease;
    flex-shrink: 0;
    align-self: flex-start;
    margin-top: 0.2rem;
}

.mini-portrait-box:hover {
    transform: scale(1.06);
    border-color: var(--accent-pink);
    box-shadow: 0 6px 20px rgba(217, 70, 239, 0.45);
}

.mini-portrait-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.mini-portrait-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    user-select: none;
}

body.theme-paper .mini-portrait-box {
    border-color: #0284c7;
    background: #f1f5f9;
}

.field-group {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    min-width: 0;
}

.field-label {
    font-size: 0.75rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
}

.field-input {
    background: var(--input-bg);
    border: 1.5px solid var(--input-border);
    color: var(--text-main);
    padding: 0.55rem 0.6rem;
    border-radius: 6px;
    font-size: 0.9rem;
    font-family: inherit;
    transition: border-color 0.2s;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    min-width: 0;
    text-overflow: ellipsis;
    white-space: nowrap;
    overflow: hidden;
}

.field-input:focus {
    border-color: var(--primary);
    outline: none;
}

/* Credits Row Layout Inside Header Field Group */
.credits-input-row {
    display: flex;
    align-items: center;
    gap: 6px;
}

/* Character Portrait Frame */
.portrait-container {
    width: 100%;
    height: 320px;
    border: 2.5px dashed var(--border-color);
    border-radius: 14px;
    background: rgba(15, 23, 42, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    position: relative;
    overflow: hidden;
    transition: all 0.25s ease;
}

.portrait-container:hover {
    border-color: var(--primary);
    background: rgba(56, 189, 248, 0.08);
}

.portrait-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    pointer-events: none;
}

.portrait-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 12px;
}

/* Auto-expanding Biography, Background & Note Textareas (NUL SCROLLBAR!) */
.bio-textarea {
    width: 100%;
    min-height: 90px;
    height: auto;
    max-height: none !important; /* Vokser automatisk med indholdet uden begrænsning */
    resize: none !important; /* Fjern manuel resize-håndtag */
    overflow: hidden !important; /* SKJUL AL SCROLLBAR DA BOKSEN UDVIDER SIG HERTIL! */
    overflow-y: hidden !important;
    line-height: 1.45;
    font-size: 0.95rem;
    padding: 0.65rem 0.85rem;
    transition: border-color 0.2s;
}

/* Vertikalt Ekspanderende Beskrivelsesfelter (Maks 3 linjer højde for tabeller) */
/* SCROLLBAR SKJULES SOM STANDARD OG VISES KUN NÅR MUSEN ER OVER FELTET! */
.desc-textarea {
    width: 100%;
    min-height: 36px;
    max-height: 74px; /* Maks 3 linjer højde */
    resize: vertical;
    font-family: inherit;
    font-size: 0.88rem;
    line-height: 1.35;
    padding: 0.4rem 0.6rem;
    background: var(--input-bg);
    border: 1.5px solid var(--input-border);
    color: var(--text-main);
    border-radius: 6px;
    overflow-y: auto;
    scrollbar-width: none; /* Skjul scrollbar i Firefox som standard */
    transition: border-color 0.2s, scrollbar-color 0.2s;
}

/* Skjul WebKit/Chrome/Edge scrollbar som standard */
.desc-textarea::-webkit-scrollbar {
    width: 0px;
    background: transparent;
}

.desc-textarea::-webkit-scrollbar-track {
    background: transparent;
}

.desc-textarea::-webkit-scrollbar-thumb {
    background: transparent;
    border-radius: 4px;
}

/* Vis kun mørk/stilfuld slank scrollbar ved HOVER eller FOCUS */
.desc-textarea:hover, .desc-textarea:focus {
    scrollbar-width: thin;
    scrollbar-color: var(--primary) transparent;
}

.desc-textarea:hover::-webkit-scrollbar,
.desc-textarea:focus::-webkit-scrollbar {
    width: 6px;
}

.desc-textarea:hover::-webkit-scrollbar-thumb,
.desc-textarea:focus::-webkit-scrollbar-thumb {
    background: var(--input-border);
}

.desc-textarea:hover::-webkit-scrollbar-thumb:hover {
    background: var(--primary);
}

.desc-textarea:focus, .bio-textarea:focus {
    border-color: var(--primary);
    outline: none;
}

select.table-input, select.field-input {
    background-color: var(--input-bg);
    color: var(--text-main);
    cursor: pointer;
}

select.table-input option, select.field-input option {
    background-color: #0f172a;
    color: var(--text-main);
    padding: 6px;
}

body.theme-paper select.table-input option, 
body.theme-paper select.field-input option {
    background-color: #ffffff;
    color: #1e293b;
}

/* Credits Calculator Inline Controls (+ and - Compact Buttons) */
.calc-control {
    display: flex;
    align-items: center;
    gap: 4px;
}

.calc-input {
    width: 65px;
    padding: 0.35rem 0.4rem;
    font-size: 0.82rem;
    border-radius: 6px;
    background: var(--input-bg);
    border: 1.5px solid var(--input-border);
    color: var(--text-main);
    font-family: inherit;
    transition: border-color 0.2s;
}

.calc-input:focus {
    border-color: var(--primary);
    outline: none;
}

/* Skjul lys/hvid browser-spinner på tal-input felter (f.eks. Credits & XP regner) */
input[type=number]::-webkit-outer-spin-button,
input[type=number]::-webkit-inner-spin-button {
    -webkit-appearance: none !important;
    margin: 0;
}

input[type=number] {
    -moz-appearance: textfield;
    appearance: textfield;
}

.btn-calc {
    background: var(--input-bg);
    border: 1.5px solid var(--input-border);
    color: var(--text-main);
    width: 28px;
    height: 28px;
    padding: 0;
    border-radius: 6px;
    font-weight: 900;
    font-size: 1.1rem;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s ease;
    flex-shrink: 0;
}

.btn-calc.add { color: var(--accent-green); border-color: rgba(52, 211, 153, 0.6); }
.btn-calc.sub { color: var(--accent-red); border-color: rgba(244, 63, 94, 0.6); }

.btn-calc:hover {
    transform: scale(1.12);
}

/* Bennies Interactive Counter */
.counter-box {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.btn-counter {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background: var(--input-bg);
    border: 1.5px solid var(--input-border);
    color: var(--primary);
    font-size: 1.1rem;
    font-weight: 900;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s ease;
}

.btn-counter:hover {
    background: var(--primary);
    color: #0f172a;
}

.btn-daily-bennies {
    font-size: 1.1rem;
    margin-left: 2px;
    transition: all 0.2s ease;
}

.btn-daily-bennies:hover {
    background: rgba(234, 179, 8, 0.2);
    border-color: #eab308;
    color: #fde047;
    transform: scale(1.08);
}

/* 2-Column Section Layout (Strict Equal 50/50 Split & No Horizontal Overflow) */
.section-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1.8rem;
    margin-bottom: 1.8rem;
    width: 100%;
    box-sizing: border-box;
}

@media (max-width: 960px) {
    .section-grid {
        grid-template-columns: 1fr;
    }
}

/* Dynamic Table Delete Button (🗑️ / ❌) */
.btn-del-row {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 0.85rem;
    cursor: pointer;
    padding: 0.2rem 0.35rem;
    border-radius: 6px;
    transition: all 0.2s ease;
    user-select: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    opacity: 0.6;
}

.btn-del-row:hover {
    opacity: 1;
    color: var(--accent-red);
    background: rgba(244, 63, 94, 0.2);
    transform: scale(1.2);
}

body.theme-paper .btn-del-row:hover {
    color: #e11d48;
    background: #ffe4e6;
}

/* Possessions & Equipment Table Column Split (Full Width) */
#possession-table {
    table-layout: fixed;
    width: 100%;
}

#possession-table th:nth-child(1), #possession-table td:nth-child(1) { width: 20%; }
#possession-table th:nth-child(2), #possession-table td:nth-child(2) { width: 56%; }
#possession-table th:nth-child(3), #possession-table td:nth-child(3) { width: 10%; }
#possession-table th:nth-child(4), #possession-table td:nth-child(4) { width: 10%; }
#possession-table th:nth-child(5), #possession-table td:nth-child(5) { width: 4%; }

/* Hindrance & Edge Table Column Split */
#hindrance-table, #edge-table {
    table-layout: fixed;
    width: 100%;
}

#hindrance-table th:nth-child(1), #hindrance-table td:nth-child(1),
#edge-table th:nth-child(1), #edge-table td:nth-child(1) { width: 17%; }

#hindrance-table th:nth-child(2), #hindrance-table td:nth-child(2),
#edge-table th:nth-child(2), #edge-table td:nth-child(2) { width: 10%; }

#hindrance-table th:nth-child(3), #hindrance-table td:nth-child(3),
#edge-table th:nth-child(3), #edge-table td:nth-child(3) { width: 17%; }

#hindrance-table th:nth-child(4), #hindrance-table td:nth-child(4),
#edge-table th:nth-child(4), #edge-table td:nth-child(4) { width: 7%; }

#hindrance-table th:nth-child(5), #hindrance-table td:nth-child(5),
#edge-table th:nth-child(5), #edge-table td:nth-child(5) { width: 22%; }

#hindrance-table th:nth-child(6), #hindrance-table td:nth-child(6),
#edge-table th:nth-child(6), #edge-table td:nth-child(6) { width: 23%; }

#hindrance-table th:nth-child(7), #hindrance-table td:nth-child(7),
#edge-table th:nth-child(7), #edge-table td:nth-child(7) { width: 4%; }

/* Linked Modifier Pills & Badges System (Dedicated Right-Aligned Column) */
.modifier-pills-container {
    flex: 1;
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    align-items: center;
    gap: 0.35rem;
    margin-top: 0;
    padding-left: 0.5rem;
}

.modifier-pill {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 0.73rem;
    font-weight: 800;
    padding: 0.2rem 0.55rem;
    border-radius: 12px;
    cursor: pointer;
    user-select: none;
    transition: all 0.2s ease;
    background: rgba(56, 189, 248, 0.12);
    border: 1.5px solid var(--primary);
    color: var(--primary);
}

.modifier-pill:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(56, 189, 248, 0.3);
}

.modifier-pill.positive {
    background: rgba(52, 211, 153, 0.15);
    border-color: rgba(52, 211, 153, 0.6);
    color: var(--accent-green);
}

.modifier-pill.negative {
    background: rgba(244, 63, 94, 0.15);
    border-color: rgba(244, 63, 94, 0.6);
    color: var(--accent-red);
}

.modifier-pill.disabled {
    opacity: 0.45;
    background: rgba(148, 163, 184, 0.1);
    border-color: rgba(148, 163, 184, 0.3);
    color: var(--text-muted);
    text-decoration: line-through;
}

body.theme-paper .modifier-pill.positive {
    background: rgba(5, 150, 105, 0.12);
    border-color: #059669;
    color: #047857;
}

body.theme-paper .modifier-pill.negative {
    background: rgba(225, 29, 72, 0.12);
    border-color: #e11d48;
    color: #be123c;
}

.box {
    background: var(--card-bg);
    border: 2px solid var(--border-color);
    border-radius: 12px;
    padding: 1.4rem;
    margin-bottom: 1.8rem;
    position: relative;
    box-sizing: border-box;
    width: 100%;
}

.box-header {
    font-size: 1.2rem;
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin: 0 0 1rem 0;
    padding-bottom: 0.4rem;
    border-bottom: 2px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    color: var(--primary);
}

/* SVG Polyhedral Dice Selectors (Fixed Column Width) */
.dice-selector {
    display: inline-flex;
    gap: 2px;
    align-items: center;
    width: 220px;
    min-width: 220px;
    flex-shrink: 0;
}

/* Dedicated Reset / Untrained Button (🚫) */
.dice-btn.reset-btn {
    width: 24px;
    height: 24px;
    min-width: 24px;
    min-height: 24px;
    font-size: 0.8rem;
    border: 1.5px solid var(--input-border);
    border-radius: 6px;
    background: var(--input-bg);
    color: var(--text-muted);
    opacity: 0.5;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    user-select: none;
    margin-right: 2px;
}

.dice-btn.reset-btn:hover {
    opacity: 1;
    color: var(--accent-red);
    border-color: var(--accent-red);
    background: rgba(244, 63, 94, 0.18);
    transform: scale(1.1);
}

body.theme-paper .dice-btn.reset-btn {
    border-color: #cbd5e1;
    background: #f1f5f9;
    color: #64748b;
}

body.theme-paper .dice-btn.reset-btn:hover {
    color: #e11d48;
    border-color: #e11d48;
    background: #ffe4e6;
}

/* Uvalgte terninger er skaleret ned for minimal forstyrrelse */
.dice-btn {
    width: 38px;
    height: 38px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    user-select: none;
    opacity: 0.38;
    transform: scale(0.52);
    transition: all 0.22s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.dice-svg {
    width: 100%;
    height: 100%;
    pointer-events: none;
}

/* Default Unselected Dice: Sharp Cyan Outline, NO square drop-shadow box! */
.dice-svg polygon, .dice-svg rect {
    stroke: var(--primary);
    stroke-width: 2.8;
    fill: rgba(56, 189, 248, 0.12);
    transition: all 0.2s ease;
    filter: none !important;
}

.dice-svg text {
    fill: var(--text-main);
    font-size: 11px;
    font-weight: 900;
    font-family: var(--font-family);
    pointer-events: none;
}

body.theme-paper .dice-svg polygon, body.theme-paper .dice-svg rect {
    stroke: #0284c7;
    fill: #e0f2fe;
    stroke-width: 3;
    filter: none !important;
}

body.theme-paper .dice-svg text {
    fill: #0369a1;
}

/* Hover state on unselected die */
.dice-btn:hover {
    opacity: 0.78;
    transform: scale(0.85);
}

.dice-btn:hover .dice-svg polygon, .dice-btn:hover .dice-svg rect {
    stroke: #ffffff;
    fill: rgba(56, 189, 248, 0.35);
    filter: none !important;
}

/* Valgt terning: FREMHÆVET OG STOR (scale 1.22) for krystalklar læsbarhed */
.dice-btn.selected {
    opacity: 1 !important;
    transform: scale(1.22) !important;
}

.dice-btn.selected .dice-svg polygon, .dice-btn.selected .dice-svg rect {
    stroke: #ffffff;
    stroke-width: 2.8;
    fill: #d946ef; /* Strålende lyserød/lilla neonglød KUN inde i polygonens geometri */
    filter: none !important; /* Ingen firkantet skyggeboks uden om terningen! */
}

.dice-btn.selected .dice-svg text {
    fill: #ffffff;
    font-weight: 900;
}

body.theme-paper .dice-btn.selected .dice-svg polygon, body.theme-paper .dice-btn.selected .dice-svg rect {
    stroke: #7e22ce;
    fill: #a855f7;
    filter: none !important;
}

body.theme-paper .dice-svg text {
    fill: #ffffff;
}

/* Attributes & Skills List Layout med Dedikerede Kolonner */
.stat-row {
    display: flex;
    align-items: center;
    padding: 0.45rem 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    gap: 0.6rem;
}

body.theme-paper .stat-row {
    border-bottom: 1px solid rgba(0, 0, 0, 0.12);
}

.stat-name, .stat-row > .field-label, .stat-row > .custom-skill-name-input {
    width: 140px;
    min-width: 140px;
    flex-shrink: 0;
}

.stat-name {
    font-size: 0.95rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: help;
}

.stat-tag {
    font-size: 0.7rem;
    font-weight: 800;
    text-transform: uppercase;
    color: var(--accent-purple);
    background: rgba(192, 132, 252, 0.15);
    padding: 0.1rem 0.35rem;
    border-radius: 4px;
}

/* Instant Roll Toast Popup Banner (Over/Under Layout) */
.roll-toast-banner {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%) translateY(-20px);
    background: linear-gradient(135deg, #0f172a, #1e293b);
    border: 2.5px solid var(--primary);
    color: var(--text-main);
    padding: 1.2rem 2.2rem;
    border-radius: 16px;
    box-shadow: 0 12px 35px rgba(0, 0, 0, 0.6), 0 0 20px rgba(56, 189, 248, 0.4);
    z-index: 10000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    min-width: 320px;
}

.roll-toast-banner.active {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) translateY(0);
}

.roll-toast-title {
    font-size: 1.2rem;
    font-weight: 900;
    color: var(--primary);
    margin-bottom: 0.4rem;
    text-align: center;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 0.4rem;
}

.roll-toast-result {
    font-size: 1.5rem;
    font-weight: 900;
    color: var(--accent-green);
    text-align: center;
    margin-bottom: 0.6rem;
}

.toast-result-num {
    color: var(--accent-green);
    font-size: 1.7rem;
    font-weight: 900;
}

.roll-toast-breakdown {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    background: rgba(15, 23, 42, 0.8);
    border: 1px solid var(--input-border);
    border-radius: 10px;
    padding: 0.6rem 0.9rem;
}

.die-result-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.9rem;
}

.die-result-row span {
    color: var(--text-muted);
    font-weight: 600;
}

.die-result-row strong {
    color: var(--text-main);
    font-weight: 800;
}

/* Paper Theme - Original Rich Dark Casino Felt Green & Glowing Yellow Gold Result Number */
body.theme-paper .roll-toast-banner {
    background: linear-gradient(135deg, #064e3b, #022c22) !important; /* Den oprindelige mørke casino-dug grøn */
    border-color: #34d399 !important;
    color: #ffffff !important;
    box-shadow: 0 12px 35px rgba(0, 0, 0, 0.6), 0 0 20px rgba(52, 211, 153, 0.4) !important;
}

body.theme-paper .roll-toast-title {
    color: #ffffff !important;
    border-bottom-color: rgba(255, 255, 255, 0.25) !important;
}

body.theme-paper .roll-toast-result {
    color: #ffffff !important; /* Hvid "Resultat:" tekst */
}

body.theme-paper .toast-result-num {
    color: #facc15 !important; /* MEGET LYS STRÅLENDE GULD/GUL FOR SELVE TALLET (F.EKS. 11)! Ingen mørkegrøn! */
    text-shadow: 0 2px 8px rgba(0, 0, 0, 0.8);
}

body.theme-paper .roll-drawer {
    background: linear-gradient(135deg, #064e3b, #022c22) !important;
    border-color: #34d399 !important;
    color: #ffffff !important;
}

body.theme-paper .roll-drawer-header {
    color: #ffffff !important;
}

body.theme-paper .roll-entry {
    background: rgba(2, 44, 34, 0.9) !important;
    border-color: rgba(52, 211, 153, 0.4) !important;
    color: #ffffff !important;
}

body.theme-paper .roll-stacked-lines {
    color: #e2e8f0 !important;
}

body.theme-paper .roll-stacked-lines span {
    color: #e2e8f0 !important;
}

/* Buff Armour Body Location Interactive Diagram */
.armour-legend-bar {
    font-size: 0.82rem;
    color: var(--text-muted);
    margin-bottom: 1.2rem;
    display: flex;
    gap: 1.8rem;
    align-items: center;
    justify-content: center;
}

.sq-legend-icon {
    color: var(--primary);
    border: 1.5px solid var(--primary);
    padding: 2px 7px;
    border-radius: 5px;
    background: rgba(56, 189, 248, 0.15);
}

.rd-legend-icon {
    color: var(--accent-purple);
    border: 1.5px solid var(--accent-purple);
    padding: 2px 7px;
    border-radius: 14px;
    background: rgba(192, 132, 252, 0.15);
}

.armour-body-wrapper {
    position: relative;
    width: 380px;
    height: 380px;
    margin: 0 auto;
    background: rgba(15, 23, 42, 0.5);
    border: 1.5px solid var(--input-border);
    border-radius: 16px;
    padding: 10px;
}

@media (max-width: 480px) {
    .armour-body-wrapper {
        width: 100%;
        height: 360px;
    }
}

.armour-svg-diagram {
    width: 100%;
    height: 100%;
}

.armour-part {
    stroke: var(--primary);
    fill: rgba(56, 189, 248, 0.12);
    stroke-width: 2.8;
    transition: all 0.2s ease;
}

/* Positioned Location Badges */
.loc-badge {
    position: absolute;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    z-index: 10;
}

.loc-label {
    font-size: 0.65rem;
    font-weight: 900;
    color: var(--primary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    background: rgba(15, 23, 42, 0.95);
    padding: 1px 6px;
    border-radius: 4px;
    border: 1px solid var(--border-color);
}

.btn-repair-all-icon {
    background: rgba(34, 197, 94, 0.18);
    border: 1.5px solid #22c55e;
    color: #4ade80;
    font-size: 1.1rem;
    padding: 3px 8px;
    border-radius: 6px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    box-shadow: 0 2px 8px rgba(34, 197, 94, 0.25);
}

.btn-repair-all-icon:hover {
    background: #22c55e;
    color: #0f172a;
    transform: scale(1.1);
    box-shadow: 0 0 12px rgba(34, 197, 94, 0.6);
}

.loc-toughness-control {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
}

.armour-adjust-btn {
    width: 26px;
    height: 14px;
    border-radius: 3px;
    border: 1px solid var(--border-color);
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-main);
    font-size: 0.55rem;
    font-weight: bold;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    transition: all 0.15s ease;
    user-select: none;
    line-height: 1;
}

.armour-adjust-btn:hover {
    transform: scale(1.2);
}

.btn-armour-down:hover {
    background: #ef4444 !important;
    color: #ffffff !important;
    border-color: #ef4444 !important;
}

.btn-armour-up:hover {
    background: #22c55e !important;
    color: #ffffff !important;
    border-color: #22c55e !important;
}

/* PERFEKT Rund Cirkel (Total Toughness inc. Armour) */
.loc-input.rd {
    width: 34px;
    height: 34px;
    min-width: 34px;
    min-height: 34px;
    aspect-ratio: 1 / 1;
    border-radius: 50%;
    text-align: center;
    font-weight: 900;
    font-size: 0.88rem;
    padding: 0;
    border: 2px solid var(--accent-purple);
    background: rgba(192, 132, 252, 0.25);
    color: var(--text-main);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.4), 0 0 10px rgba(192, 132, 252, 0.4);
    flex-shrink: 0;
    transition: all 0.2s ease;
}

.loc-input.rd.damaged {
    border-color: #ef4444 !important;
    background: rgba(239, 68, 68, 0.35) !important;
    color: #ffffff !important;
    box-shadow: 0 0 14px rgba(239, 68, 68, 0.9) !important;
    animation: pulseDamage 1.5s infinite alternate;
}

@keyframes pulseDamage {
    0% { box-shadow: 0 0 8px rgba(239, 68, 68, 0.6); }
    100% { box-shadow: 0 0 16px rgba(239, 68, 68, 1); }
}

body.theme-paper .loc-input.rd {
    border-color: #9333ea;
    background: #f3e8ff;
    color: #581c87;
}

body.theme-paper .loc-input.rd.damaged {
    border-color: #dc2626 !important;
    background: #fef2f2 !important;
    color: #991b1b !important;
}

/* Precise Positions: 
   - HEAD centered ABOVE robot head with horizontal side arrows (top: 4px; left: 50%; transform: translateX(-50%);)
   - TORSO moved UP inside chest (top: 114px)
   - ARMS outside shoulders (top: 130px; left: 8px; right: 8px;)
   - LEGS closer to legs (bottom: 25px; left: 70px; right: 70px;)
*/
.loc-badge.head-c { top: -1px; left: 50%; transform: translateX(-50%); }

.loc-badge.l-arm  { top: 130px; left: 8px; }
.loc-badge.torso  { top: 114px; left: 50%; transform: translateX(-50%); } /* INSIDE CHEST */
.loc-badge.r-arm  { top: 130px; right: 8px; }

.loc-badge.l-leg  { bottom: 25px; left: 70px; }
.loc-badge.r-leg  { bottom: 25px; right: 70px; }

.loc-toughness-control.horiz {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 4px;
}

.loc-toughness-control.horiz .armour-adjust-btn {
    width: 20px;
    height: 20px;
    border-radius: 50%;
}

/* Suit Details & Summary Fields Moved BELOW Character Diagram */
.armour-bottom-fields {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.2rem;
    margin-top: 1.5rem;
    padding-top: 1.2rem;
    border-top: 1.5px dashed var(--border-color);
}

/* Wounds & Fatigue Checkboxes & Causes */
.wounds-fatigue-container {
    display: flex;
    flex-wrap: wrap;
    gap: 1.5rem;
    align-items: flex-start;
}

.wounds-section {
    flex: 0 0 auto;
}

.fatigue-section {
    flex: 1 1 auto;
}

.fatigue-rows {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    margin-top: 0.5rem;
}

.fatigue-row {
    display: flex;
    flex-direction: row !important;
    align-items: center !important;
    flex-wrap: nowrap !important;
    gap: 0.5rem;
    white-space: nowrap;
}

.fatigue-source-input {
    width: 150px;
    max-width: 180px;
    flex: 0 1 150px;
    font-size: 0.82rem;
    padding: 0.25rem 0.5rem;
    border-radius: 6px;
    box-sizing: border-box;
}

.checkbox-group {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-top: 0.5rem;
}

.custom-checkbox {
    flex-shrink: 0;
    width: 26px;
    height: 26px;
    border: 2px solid var(--border-color);
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-weight: 900;
    font-size: 0.9rem;
    user-select: none;
    transition: all 0.2s ease;
}

.custom-checkbox.checked {
    background: var(--accent-red);
    border-color: var(--accent-red);
    color: white;
}

/* Add Row Buttons (+ Tilføj) */
.btn-add-skill, .btn-add-row {
    background: rgba(56, 189, 248, 0.1);
    color: var(--primary);
    border: 1.5px dashed var(--border-color);
    padding: 0.55rem 1rem;
    border-radius: 8px;
    font-weight: 700;
    font-size: 0.85rem;
    cursor: pointer;
    width: 100%;
    margin-top: 0.8rem;
    transition: all 0.2s ease;
}

.btn-add-skill:hover, .btn-add-row:hover {
    background: rgba(56, 189, 248, 0.22);
    border-color: var(--primary);
    transform: translateY(-1px);
}

/* Tables for Possessions, Edges, Hindrances, Vehicles, Weapons */
.data-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 0.5rem;
}

.data-table th {
    text-align: left;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    padding: 0.5rem;
    border-bottom: 2px solid var(--border-color);
}

.data-table td {
    padding: 0.4rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

body.theme-paper .data-table td {
    border-bottom: 1px solid #cbd5e1;
}

.table-input {
    width: 100%;
    background: var(--input-bg);
    border: 1.5px solid var(--input-border);
    color: var(--text-main);
    padding: 0.4rem 0.6rem;
    border-radius: 6px;
    font-size: 0.9rem;
}

.table-input:focus {
    border-color: var(--primary);
    outline: none;
}

/* Floating Roll Log Drawer */
.roll-drawer {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    width: 350px;
    background: var(--card-bg);
    border: 2px solid var(--border-color);
    border-radius: 14px;
    padding: 1.2rem;
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.35);
    backdrop-filter: blur(14px);
    z-index: 999;
    transition: padding 0.2s ease, width 0.2s ease;
}

.roll-drawer.collapsed {
    padding: 0.5rem 0.9rem;
    width: auto;
}

.roll-drawer.collapsed .roll-history {
    display: none;
}

.roll-drawer-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-weight: 800;
    font-size: 0.95rem;
    margin-bottom: 0.8rem;
    color: var(--primary);
}

.btn-clear-log {
    background: rgba(244, 63, 94, 0.15);
    color: var(--accent-red);
    border: 1px solid rgba(244, 63, 94, 0.4);
    padding: 0.2rem 0.55rem;
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-clear-log:hover {
    background: var(--accent-red);
    color: #ffffff;
}

.roll-history {
    max-height: 320px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
}

.roll-entry {
    background: var(--input-bg);
    border: 1.5px solid var(--input-border);
    border-radius: 10px;
    padding: 0.65rem 0.85rem;
    font-size: 0.85rem;
}

.roll-entry-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.35rem;
    font-weight: 800;
}

.roll-total-badge {
    background: var(--primary);
    color: #0f172a;
    padding: 0.1rem 0.55rem;
    border-radius: 6px;
    font-weight: 900;
    font-size: 0.9rem;
}

.roll-stacked-lines {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    font-size: 0.82rem;
    color: var(--text-muted);
}

.roll-stacked-lines div {
    display: flex;
    justify-content: space-between;
}

/* Tooltip Popup */
.tooltip-popup {
    position: absolute;
    background: #0f172a;
    color: #f8fafc;
    border: 1.5px solid var(--primary);
    padding: 0.7rem 1rem;
    border-radius: 8px;
    font-size: 0.82rem;
    line-height: 1.4;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.4);
    pointer-events: none;
    z-index: 1000;
    max-width: 320px;
    white-space: pre-wrap;
    word-break: break-word;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.tooltip-popup.active {
    opacity: 1;
}

/* Mobile responsive */
@media (max-width: 768px) {
    body { flex-direction: column; }
    .sidebar { width: auto; border-right: none; border-bottom: 1px solid var(--border-color); padding: 1rem; }
    .main-content { padding: 1.5rem 1rem; }
    .roll-drawer { width: calc(100% - 2rem); left: 1rem; right: 1rem; }
}

/* 🖨️ PRINT & PDF STYLESHEET ENGINE (Fold ALL textareas completely out) */
@media print {
    @page {
        size: A4 portrait;
        margin: 1.2cm;
    }

    /* Force background graphic colors to print cleanly */
    *, *::before, *::after {
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }

    body {
        background: #ffffff !important;
        color: #000000 !important;
        display: block !important;
    }

    /* Hide Non-Printable Elements */
    .sidebar,
    .control-bar,
    .roll-drawer,
    .roll-toast-banner,
    .tooltip-popup,
    .btn-add-skill,
    .btn-add-row,
    .btn-calc,
    .btn-counter,
    .btn-clear-log,
    .reset-btn,
    #upload-portrait-btn,
    #remove-portrait-btn,
    .portrait-placeholder span:nth-child(2),
    .portrait-placeholder span:nth-child(3) {
        display: none !important;
    }

    .main-content {
        max-width: 100% !important;
        width: 100% !important;
        margin: 0 !important;
        padding: 0 !important;
    }

    .box, .sheet-header {
        background: #ffffff !important;
        border: 1.5px solid #000000 !important;
        color: #000000 !important;
        box-shadow: none !important;
        page-break-inside: avoid;
        break-inside: avoid;
    }

    .box-header {
        color: #000000 !important;
        border-bottom: 2px solid #000000 !important;
    }

    .field-input, .table-input {
        background: #ffffff !important;
        color: #000000 !important;
        border: 1px solid #666666 !important;
    }

    /* FOLD ALLE BESKRIVELSESFELTER OG BIOGRAFIFELTER 100% UD VED UDSKRIVNING */
    .desc-textarea, .bio-textarea {
        background: #ffffff !important;
        color: #000000 !important;
        border: 1px solid #666666 !important;
        height: auto !important;
        max-height: none !important;
        overflow: visible !important;
        white-space: pre-wrap !important;
        word-break: break-word !important;
        resize: none !important;
    }

    /* Rustningsdiagram & Badges */
    .armour-body-wrapper {
        background: #f8fafc !important;
        border-color: #000000 !important;
    }

    .armour-part {
        stroke: #000000 !important;
        fill: #f1f5f9 !important;
    }

    .loc-label {
        background: #ffffff !important;
        color: #000000 !important;
        border-color: #000000 !important;
    }

    .loc-input.sq {
        background: #ffffff !important;
        color: #000000 !important;
        border-color: #000000 !important;
    }

    .loc-input.rd {
        background: #e9d5ff !important;
        color: #581c87 !important;
        border-color: #7e22ce !important;
    }

    .dice-svg polygon, .dice-svg rect {
        stroke: #000000 !important;
    }

    .dice-btn.selected .dice-svg polygon, .dice-btn.selected .dice-svg rect {
        fill: #a855f7 !important;
        stroke: #000000 !important;
    }

    .dice-btn.selected .dice-svg text {
        fill: #ffffff !important;
    }

    .portrait-container {
        border-color: #000000 !important;
        background: #ffffff !important;
        height: 280px !important;
    }
}

/* =========================================================================
   DRAG-AND-DROP LAYOUT EDITOR
   ========================================================================= */

/* Edit Mode Styles */
body.layout-edit-mode .box {
    border: 2px dashed var(--primary);
    background: rgba(56, 189, 248, 0.03);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    transition: all 0.2s ease;
}

body.theme-paper.layout-edit-mode .box {
    background: rgba(2, 132, 199, 0.03);
}

body.layout-edit-mode .box-header {
    cursor: grab;
}

body.layout-edit-mode .box-header:active {
    cursor: grabbing;
}

/* Drag Handle */
.drag-handle {
    display: none;
    cursor: grab;
    color: var(--primary);
    font-size: 1.1rem;
    font-weight: bold;
    padding: 0 0.5rem;
    user-select: none;
    transition: transform 0.2s;
}

.drag-handle:hover {
    transform: scale(1.2);
}

body.layout-edit-mode .drag-handle {
    display: inline-block;
}

/* Dragging States */
.box.dragging {
    opacity: 0.5;
    border: 2px solid var(--accent-pink) !important;
    transform: scale(0.98);
}

.layout-column {
    min-height: 100px;
    border-radius: 12px;
    transition: background-color 0.2s;
}

body.layout-edit-mode .layout-column {
    border: 2px dashed rgba(255, 255, 255, 0.1);
    padding: 0.5rem;
}

body.theme-paper.layout-edit-mode .layout-column {
    border-color: rgba(0, 0, 0, 0.1);
}

.layout-column.drag-over {
    background: rgba(56, 189, 248, 0.05);
}

body.theme-paper .layout-column.drag-over {
    background: rgba(2, 132, 199, 0.05);
}

/* Linked Modifier Pills & Table Cell Alignment Styling */
.modifier-pills-container {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    flex-wrap: wrap;
    max-width: 100%;
    overflow: hidden;
}

.modifier-pill {
    display: inline-flex;
    align-items: center;
    padding: 2px 7px;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 800;
    cursor: pointer;
    user-select: none;
    transition: all 0.2s ease;
    border: 1px solid transparent;
    line-height: 1.2;
    white-space: nowrap;
    max-width: 140px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.modifier-pill span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 100%;
}

.modifier-pill.positive {
    background: rgba(34, 197, 94, 0.18);
    color: #4ade80;
    border-color: rgba(34, 197, 94, 0.45);
}

.modifier-pill.positive:hover {
    background: rgba(34, 197, 94, 0.35);
    box-shadow: 0 0 8px rgba(34, 197, 94, 0.4);
}

.modifier-pill.negative {
    background: rgba(239, 68, 68, 0.18);
    color: #f87171;
    border-color: rgba(239, 68, 68, 0.45);
}

.modifier-pill.negative:hover {
    background: rgba(239, 68, 68, 0.35);
    box-shadow: 0 0 8px rgba(239, 68, 68, 0.4);
}

.modifier-pill.disabled {
    opacity: 0.35;
    filter: grayscale(0.8);
    text-decoration: line-through;
    box-shadow: none !important;
}

.data-table td.has-modifier-pills {
    display: flex;
    align-items: center;
    gap: 6px;
}

.data-table td.has-modifier-pills input {
    flex: 1;
    min-width: 80px;
}

/* Modal Overlay & Dialog Card */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(15, 23, 42, 0.85);
    backdrop-filter: blur(8px);
    z-index: 999999 !important;
    display: none !important;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
    box-sizing: border-box;
}

.modal-overlay.active {
    display: flex !important;
}

.modal-card {
    background: var(--card-bg, #1e293b);
    border: 1.5px solid var(--border-color, #334155);
    border-radius: 16px;
    width: 100%;
    max-width: 520px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.4);
    padding: 1.5rem 1.8rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    animation: modalPopIn 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes modalPopIn {
    from { opacity: 0; transform: scale(0.92) translateY(10px); }
    to { opacity: 1; transform: scale(1) translateY(0); }
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 0.8rem;
}

.modal-header h3 {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 800;
    color: var(--text-main);
    display: flex;
    align-items: center;
    gap: 8px;
}

.btn-close-modal {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 1.2rem;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 6px;
    transition: all 0.2s ease;
}

.btn-close-modal:hover {
    color: var(--text-main);
    background: rgba(255, 255, 255, 0.1);
}

.modal-desc {
    margin: 0;
    font-size: 0.88rem;
    color: var(--text-muted);
    line-height: 1.4;
}

.modal-choices-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin: 0.5rem 0;
}

.choice-option-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.9rem 1.1rem;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.04);
    border: 1.5px solid var(--border-color);
    cursor: pointer;
    transition: all 0.2s ease;
}

.choice-option-card:hover {
    background: rgba(56, 189, 248, 0.08);
    border-color: var(--primary);
}

.choice-option-card.selected {
    background: rgba(56, 189, 248, 0.16);
    border-color: var(--primary);
    box-shadow: 0 0 12px rgba(56, 189, 248, 0.25);
}

.choice-option-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.choice-name {
    font-weight: 700;
    font-size: 0.95rem;
    color: var(--text-main);
}

.choice-req {
    font-size: 0.78rem;
    color: var(--primary);
    font-weight: 600;
}

/* ==========================================================================
   CHEMICAL & DRUG ADDICTION TRACKER STYLES
   ========================================================================== */
.drugs-tracker-box {
    margin-top: 1.5rem;
    border-color: rgba(56, 189, 248, 0.3) !important;
}

.drugs-status-section {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 12px;
    margin-bottom: 16px;
}

.drugs-status-card {
    background: rgba(15, 23, 42, 0.6);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 10px 12px;
}

.status-card-title {
    font-size: 0.75rem;
    font-weight: 800;
    color: var(--text-muted);
    letter-spacing: 0.5px;
    margin-bottom: 6px;
}

.gauge-bar-outer {
    width: 100%;
    height: 10px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 6px;
    overflow: hidden;
}

.gauge-bar-inner.medical-bar {
    height: 100%;
    background: linear-gradient(90deg, #38bdf8, #3b82f6, #ef4444);
    transition: width 0.3s ease;
}

.taste-pill {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 4px 12px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    flex: 1;
    text-align: center;
}

.taste-pill.active {
    background: rgba(239, 68, 68, 0.15);
    border-color: rgba(239, 68, 68, 0.5);

}

.taste-label {
    font-size: 0.7rem;
    color: var(--text-muted);
    font-weight: 700;
}

.taste-val {
    font-size: 1.1rem;
    font-weight: 900;
    color: var(--text-main);
}

.taste-pill.active .taste-val {
    color: #ef4444;
}

.flush-toggle-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-main);
    cursor: pointer;
    user-select: none;
}

.flush-toggle-label input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: var(--primary);
}

.drugs-dose-panel {
    background: rgba(15, 23, 42, 0.4);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 12px;
    margin-bottom: 16px;
}

.panel-subtitle {
    font-size: 0.8rem;
    font-weight: 800;
    color: var(--primary);
    letter-spacing: 0.5px;
    margin-bottom: 8px;
}

.dose-form-grid {
    display: grid;
    grid-template-columns: 2fr 1.5fr 1.5fr;
    gap: 12px;
}

@media (max-width: 768px) {
    .dose-form-grid {
        grid-template-columns: 1fr;
    }
}

.active-hits-container, .addictions-container {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.empty-hits-msg {
    font-size: 0.82rem;
    color: var(--text-muted);
    font-style: italic;
    padding: 8px 12px;
    background: rgba(255, 255, 255, 0.02);
    border-radius: 6px;
    border: 1px dashed var(--border-color);
}

.hit-card {
    background: rgba(15, 23, 42, 0.7);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 8px 12px;
}

.hit-card.waiting {
    border-left: 4px solid #f59e0b;
}

.hit-card.active {
    border-left: 4px solid #10b981;
}

.hit-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 4px;
    width: 100%;
}

.hit-name {
    font-weight: 800;
    font-size: 0.9rem;
    color: var(--text-main);
}

.hit-status-badge {
    font-size: 0.75rem;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.08);
}

.hit-card.waiting .hit-status-badge {
    color: #f59e0b;
    background: rgba(245, 158, 11, 0.15);
}

.hit-card.active .hit-status-badge {
    color: #10b981;
    background: rgba(16, 185, 129, 0.15);
}

.hit-effect {
    font-size: 0.82rem;
    color: var(--text-muted);
}

.addiction-card {
    background: rgba(15, 23, 42, 0.7);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 10px 12px;
}

.addiction-card.withdrawal {
    border-left: 4px solid #ef4444;
    background: rgba(239, 68, 68, 0.06);
}

.addiction-card.suppressed {
    border-left: 4px solid #10b981;
}

.addiction-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.addiction-title {
    font-size: 0.9rem;
    color: var(--text-main);
}

.addiction-controls {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    width: 100%;
}

/* Compact, Right-Aligned Trashcan Delete Row Button */
.btn-del-row {
    background: transparent !important;
    border: none !important;
    color: var(--text-muted);
    cursor: pointer;
    padding: 2px 6px !important;
    border-radius: 4px;
    font-size: 0.95rem;
    line-height: 1;
    transition: all 0.2s ease;
    margin-left: auto !important; /* Pushes button all the way to the right edge */
    flex-shrink: 0;
    width: auto !important;
    max-width: fit-content !important;
    box-shadow: none !important;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.btn-del-row:hover {
    background: rgba(239, 68, 68, 0.2) !important;
    color: #ef4444 !important;
    transform: scale(1.15);
}

.daily-dose-checkbox {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.82rem;
    color: var(--text-main);
    cursor: pointer;
}

.badge-danger {
    background: rgba(239, 68, 68, 0.15);
    color: #f87171;
    border: 1px solid rgba(239, 68, 68, 0.3);
}

.badge-success {
    background: rgba(34, 197, 94, 0.15);
    color: #4ade80;
    border: 1px solid rgba(34, 197, 94, 0.3);
}

.badge-info {
    background: rgba(56, 189, 248, 0.15);
    color: #38bdf8;
    border: 1px solid rgba(56, 189, 248, 0.3);
}

.badge-warning {
    background: rgba(245, 158, 11, 0.15);
    color: #fbbf24;
    border: 1px solid rgba(245, 158, 11, 0.3);
}

/* Collapsible Drug Tracker Box */
.drugs-tracker-box.collapsed .drugs-status-section,
.drugs-tracker-box.collapsed .drugs-dose-panel,
.drugs-tracker-box.collapsed .drugs-active-hits-section,
.drugs-tracker-box.collapsed .drugs-addictions-section {
    display: none !important;
}

.drugs-tracker-box.collapsed {
    padding-bottom: 0.6rem !important;
    margin-bottom: 1rem !important;
}

.drugs-tracker-box.collapsed .box-header {
    border-bottom: none !important;
    padding-bottom: 0 !important;
    margin-bottom: 0 !important;
}

/* Custom Cyberpunk Modal Overlay & Popup Cards */
.modal-overlay {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    background: rgba(15, 23, 42, 0.85) !important;
    backdrop-filter: blur(8px) !important;
    -webkit-backdrop-filter: blur(8px) !important;
    z-index: 99999 !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    padding: 1.5rem !important;
    box-sizing: border-box !important;
}

.modal-overlay[style*="display: none"],
.modal-overlay[style*="display:none"] {
    display: none !important;
}

