/*
=================================================================
* QRYPTIC - INLINED STYLES
* Main stylesheet for the Qryptic application with Material 3 Theming.
*
* Sections:
* 1. CSS Reset
* 2. CSS Variables (Material 3 Theming)
* - Light Theme
* - Dark Theme
* 3. General Body & Typography
* 4. Core Layout & Utility Classes
* 5. Component Styles
* 6. Animations & Transitions
=================================================================
*/

/* 1. CSS Reset */
html,
body,
div,
span,
applet,
object,
iframe,
h1,
h2,
h3,
h4,
h5,
h6,
p,
blockquote,
pre,
a,
abbr,
acronym,
address,
big,
cite,
code,
del,
dfn,
em,
img,
ins,
kbd,
q,
s,
samp,
small,
strike,
strong,
sub,
sup,
tt,
var,
b,
u,
i,
center,
dl,
dt,
dd,
ol,
ul,
li,
fieldset,
form,
label,
legend,
table,
caption,
tbody,
tfoot,
thead,
tr,
th,
td,
article,
aside,
canvas,
details,
embed,
figure,
figcaption,
footer,
header,
hgroup,
menu,
nav,
output,
ruby,
section,
summary,
time,
mark,
audio,
video {
    margin: 0;
    padding: 0;
    border: 0;
    font: inherit;
    font-size: 100%;
    vertical-align: baseline;
}

article,
aside,
details,
figcaption,
figure,
footer,
header,
hgroup,
menu,
nav,
section {
    display: block;
}

body {
    line-height: 1;
}

ol,
ul {
    list-style: none;
}

blockquote,
q {
    quotes: none;
}

blockquote:before,
blockquote:after,
q:before,
q:after {
    content: "";
    content: none;
}

table {
    border-collapse: collapse;
    border-spacing: 0;
}

* {
    box-sizing: border-box;
}

* {
    box-sizing: border-box;
}


/* 2. CSS Variables (Material 3 Theming) */
:root {
    /* M3 Light Theme */
    --primary: #6750A4;
    --on-primary: #FFFFFF;
    --primary-container: #EADDFF;
    --on-primary-container: #21005D;
    --secondary: #625B71;
    --on-secondary: #FFFFFF;
    --secondary-container: #E8DEF8;
    --on-secondary-container: #1D192B;
    --tertiary: #7D5260;
    --on-tertiary: #FFFFFF;
    --tertiary-container: #FFD8E4;
    --on-tertiary-container: #31111D;
    --error: #B3261E;
    --on-error: #FFFFFF;
    --error-container: #F9DEDC;
    --on-error-container: #410E0B;
    --background: #FFFBFE;
    --on-background: #1C1B1F;
    --surface: #FFFBFE;
    --on-surface: #1C1B1F;
    --surface-variant: #E7E0EC;
    --on-surface-variant: #49454F;
    --outline: #79747E;
    --outline-variant: #CAC4D0;
    --shadow: #000000;
    --scrim: #000000;
    --inverse-surface: #313033;
    --inverse-on-surface: #F4EFF4;
    --inverse-primary: #D0BCFF;
    --surface-dim: #DED8E1;
    --surface-bright: #FFFBFE;
    --surface-container-lowest: #FFFFFF;
    --surface-container-low: #F7F2FA;
    --surface-container: #F3EDF7;
    --surface-container-high: #EEE8F4;
    --surface-container-highest: #E6E0E9;
    --success-color: #1B5E20;

    /* M3 Type Scale */
    --m3-font-family: 'Plus Jakarta Sans', sans-serif;
    --m3-display-large-font-size: 57px;
    --m3-display-large-font-weight: 400;
    --m3-display-medium-font-size: 45px;
    --m3-display-medium-font-weight: 400;
    --m3-display-small-font-size: 36px;
    --m3-display-small-font-weight: 400;
    --m3-headline-large-font-size: 32px;
    --m3-headline-large-font-weight: 400;
    --m3-headline-medium-font-size: 28px;
    --m3-headline-medium-font-weight: 400;
    --m3-headline-small-font-size: 24px;
    --m3-headline-small-font-weight: 400;
    --m3-title-large-font-size: 22px;
    --m3-title-large-font-weight: 400;
    --m3-title-medium-font-size: 16px;
    --m3-title-medium-font-weight: 500;
    --m3-title-small-font-size: 14px;
    --m3-title-small-font-weight: 500;
    --m3-body-large-font-size: 16px;
    --m3-body-large-font-weight: 400;
    --m3-body-medium-font-size: 14px;
    --m3-body-medium-font-weight: 400;
    --m3-body-small-font-size: 12px;
    --m3-body-small-font-weight: 400;
    --m3-label-large-font-size: 14px;
    --m3-label-large-font-weight: 500;
    --m3-label-medium-font-size: 12px;
    --m3-label-medium-font-weight: 500;
    --m3-label-small-font-size: 11px;
    --m3-label-small-font-weight: 500;
}

html.dark {
    /* M3 Dark Theme */
    --primary: #D0BCFF;
    --on-primary: #381E72;
    --primary-container: #4F378B;
    --on-primary-container: #EADDFF;
    --secondary: #CCC2DC;
    --on-secondary: #332D41;
    --secondary-container: #4A4458;
    --on-secondary-container: #E8DEF8;
    --tertiary: #EFB8C8;
    --on-tertiary: #492532;
    --tertiary-container: #633B48;
    --on-tertiary-container: #FFD8E4;
    --error: #F2B8B5;
    --on-error: #601410;
    --error-container: #8C1D18;
    --on-error-container: #F9DEDC;
    --background: #141314;
    --on-background: #E6E1E5;
    --surface: #1C1B1F;
    --on-surface: #E6E1E5;
    --surface-variant: #49454F;
    --on-surface-variant: #CAC4D0;
    --outline: #938F99;
    --outline-variant: #49454F;
    --shadow: #000000;
    --scrim: #000000;
    --inverse-surface: #E6E1E5;
    --inverse-on-surface: #313033;
    --inverse-primary: #6750A4;
    --surface-dim: #141218;
    --surface-bright: #3B383E;
    --surface-container-lowest: #141218;
    --surface-container-low: #1C1B1F;
    --surface-container: #211F26;
    --surface-container-high: #2B2930;
    --surface-container-highest: #36343B;
    --success-color: #A5D6A7;
}

/* 3. General Body & Typography */
body {
    font-family: var(--m3-font-family);
    background-color: var(--background);
    color: var(--on-surface);
    transition: background-color 0.3s, color 0.3s;
    font-size: var(--m3-body-large-font-size);
    font-weight: var(--m3-body-large-font-weight);
    line-height: 1.5; /* 24px */
    display: flex;
    flex-direction: column;
    justify-content: center;
    min-height: 100vh;
}

h1,
h2,
h3,
h4,
h5,
h6 {
    font-family: var(--m3-font-family);
}

/* M3 Typography Application */
.main-container > div:first-child h1 {
    font-size: var(--m3-headline-small-font-size);
    font-weight: var(--m3-headline-small-font-weight);
    line-height: 32px;
}
.main-container > div:first-child p {
    font-size: var(--m3-body-medium-font-size);
    font-weight: var(--m3-body-medium-font-weight);
    line-height: 20px;
}

.dialog-title {
    font-size: var(--m3-title-large-font-size);
    font-weight: var(--m3-title-large-font-weight);
    line-height: 28px;
}

.start-card h3, #make-secure-container .font-medium, .download-options-grid .font-medium, #password-help-panel .font-bold, .m3-list-subheader {
    font-size: var(--m3-title-medium-font-size);
    font-weight: var(--m3-title-medium-font-weight);
    line-height: 24px;
}

.m3-list-item-headline {
    font-size: var(--m3-body-large-font-size);
    font-weight: var(--m3-body-large-font-weight);
    line-height: 24px;
}

.m3-textfield-input, .dialog-body {
    font-size: var(--m3-body-large-font-size);
    font-weight: var(--m3-body-large-font-weight);
    line-height: 24px;
}

.start-card p, #make-secure-container .text-sm, .download-options-grid .text-sm {
    font-size: var(--m3-body-medium-font-size);
    font-weight: var(--m3-body-medium-font-weight);
    line-height: 20px;
}

#data-input-help, #data-input-counter, #qr-label-help, #qr-label-counter, #nickname-help, #nickname-counter, .passphrase-checklist-grid li, #password-input-error, #password-confirm-error {
    font-size: var(--m3-body-small-font-size);
    font-weight: var(--m3-body-small-font-weight);
    line-height: 16px;
}

.m3-button {
    font-size: var(--m3-label-large-font-size);
    font-weight: var(--m3-label-large-font-weight);
    line-height: 20px;
}

.m3-textfield .m3-textfield-label {
    font-size: var(--m3-body-large-font-size);
    font-weight: var(--m3-body-large-font-weight);
}


.material-symbols-outlined {
    font-family: 'Material Symbols Outlined';
    font-weight: normal;
    font-style: normal;
    font-size: 24px;
    line-height: 1;
    letter-spacing: normal;
    text-transform: none;
    display: inline-block;
    white-space: nowrap;
    word-wrap: normal;
    direction: ltr;
    -webkit-font-feature-settings: 'liga';
    -webkit-font-smoothing: antialiased;
}

button,
#wizard-step-start .flex-grow,
.select-none {
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
}

/* 4. Core Layout & Utility Classes */
.hidden {
    display: none !important;
}

.auto-resize-textarea {
    background: transparent;
    outline: none;
    min-height: 56px;
    resize: none;
}

.auto-resize-textarea::-webkit-scrollbar {
    width: 8px;
}

.auto-resize-textarea::-webkit-scrollbar-track {
    background-color: transparent;
}

.auto-resize-textarea::-webkit-scrollbar-thumb {
    background-color: var(--outline);
    border-radius: 0.5rem;
    border: 2px solid var(--surface-container);
}

.auto-resize-textarea::-webkit-scrollbar-thumb:hover {
    background-color: var(--on-surface-variant);
}

/* 5. Component Styles */

/* --- Loader --- */
.btn-loader {
    border: 2px solid color-mix(in srgb, var(--on-primary) 30%, transparent);
    border-top-color: var(--on-primary);
    border-radius: 50%;
    width: 20px;
    height: 20px;
    animation: spin 1s linear infinite;
}

html.dark .btn-loader {
    border-top-color: var(--on-primary);
}

.m3-text-button .btn-loader,
.m3-outlined-button .btn-loader {
    border: 2px solid color-mix(in srgb, var(--primary) 30%, transparent);
    border-top-color: var(--primary);
}

/* --- QR Code --- */
#qrcode-output-container-inline img,
#qrcode-output-container-inline canvas {
    display: block;
    max-width: 100%;
    height: auto;
    border-radius: 1rem;
}

/* --- Dialogs & Modals --- */
.dialog-scrim {
    position: fixed;
    inset: 0;
    display: grid;
    place-items: center;
    z-index: 50;
    padding: 1rem;
    background-color: rgba(0, 0, 0, 0.32);
    opacity: 0;
    transition: opacity 200ms cubic-bezier(0.4, 0, 0.2, 1);
}

.dialog-scrim.visible {
    opacity: 1;
}

.dialog-container {
    background-color: var(--surface-container-high);
    padding: 24px;
    border-radius: 1.75rem;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
    width: 100%;
    max-width: 320px;
    text-align: left;
    height: fit-content;
    opacity: 0;
    transform: scale(0.9);
    transition: opacity 250ms cubic-bezier(0.4, 0, 0.2, 1), transform 250ms cubic-bezier(0.4, 0, 0.2, 1);
    max-height: 90vh;
    overflow-y: auto;
}

.dialog-scrim.visible .dialog-container {
    opacity: 1;
    transform: scale(1);
}

.dialog-header {
    margin-bottom: 16px;
}

.dialog-title {
    font-size: 1.5rem;
    line-height: 2rem;
    font-weight: 400;
    color: var(--on-surface);
}

.dialog-body {
    font-size: 0.875rem;
    line-height: 1.25rem;
    color: var(--on-surface-variant);
    margin-bottom: 24px;
}

/* --- State Layers --- */
.m3-button::before,
.m3-icon-button::before,
.start-card::before,
.m3-list-item-interactive::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    border-radius: inherit;
    opacity: 0;
    transition: opacity 150ms cubic-bezier(0.4, 0, 0.2, 1);
    pointer-events: none;
}

.m3-filled-button::before {
    background-color: var(--on-primary);
}

.m3-tonal-button::before {
    background-color: var(--on-secondary-container);
}

.m3-outlined-button::before,
.m3-text-button::before {
    background-color: var(--primary);
}

.m3-icon-button::before {
    background-color: var(--on-surface-variant);
}

#start-action-create::before {
    background-color: var(--on-primary-container);
}

#start-action-scan::before,
#start-action-upload::before,
.m3-list-item-interactive::before {
    background-color: var(--on-surface);
}

.m3-button:hover::before,
.m3-icon-button:hover::before,
.start-card:hover::before,
.m3-list-item-interactive:hover::before {
    opacity: 0.08;
}

.m3-button:focus-visible::before,
.m3-icon-button:focus-visible::before,
.start-card:focus-visible::before,
.m3-list-item-interactive:focus-visible::before {
    opacity: 0.12;
}

.m3-button:active::before,
.m3-icon-button:active::before,
.start-card:active::before,
.m3-list-item-interactive:active::before {
    opacity: 0.12;
}

/* --- M3 Icon Button --- */
.m3-icon-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    transition: background-color 0.2s;
    color: var(--on-surface-variant);
    position: relative;
    overflow: hidden;
}

/* --- M3 Button Styles --- */
.m3-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    font-weight: 500;
    border-radius: 9999px;
    padding: 0 1.5rem;
    transition: background-color 0.2s, box-shadow 0.2s, border-color 0.2s, color 0.2s;
    border: 1px solid transparent;
    font-size: 0.875rem;
    line-height: 1.25rem;
    height: 40px;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
    position: relative;
    overflow: hidden;
}

.m3-button .material-symbols-outlined {
    font-size: 18px;
}

.m3-button:disabled {
    background-color: color-mix(in srgb, var(--on-surface) 12%, transparent);
    color: color-mix(in srgb, var(--on-surface) 38%, transparent);
    box-shadow: none;
    border-color: transparent;
    pointer-events: none;
}

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

/* High-Emphasis: Filled Button */
.m3-filled-button {
    background-color: var(--primary);
    color: var(--on-primary);
    box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.1);
}

.m3-filled-button:hover:not(:disabled) {
    box-shadow: 0 2px 6px -1px rgba(0, 0, 0, 0.15), 0 2px 4px -1px rgba(0, 0, 0, 0.1);
}

.m3-filled-button:disabled {
    background-color: color-mix(in srgb, var(--on-surface) 12%, transparent);
    color: color-mix(in srgb, var(--on-surface) 38%, transparent);
}

/* Medium-Emphasis: Tonal Button */
.m3-tonal-button {
    background-color: var(--secondary-container);
    color: var(--on-secondary-container);
}

.m3-tonal-button:disabled {
    background-color: color-mix(in srgb, var(--on-surface) 12%, transparent);
    color: color-mix(in srgb, var(--on-surface) 38%, transparent);
}

/* Medium-Emphasis: Outlined Button */
.m3-outlined-button {
    border-color: var(--outline);
    color: var(--primary);
}

.m3-outlined-button:disabled {
    border-color: color-mix(in srgb, var(--on-surface) 12%, transparent);
    color: color-mix(in srgb, var(--on-surface) 38%, transparent);
    background-color: transparent;
}

/* Low-Emphasis: Text Button */
.m3-text-button {
    color: var(--primary);
    background-color: transparent;
    padding: 0 0.75rem;
}

.m3-text-button:disabled {
    color: color-mix(in srgb, var(--on-surface) 38%, transparent);
    background-color: transparent;
}

/* --- Password Strength & Validation --- */
#password-strength-wrapper {
    transition: opacity 0.3s ease, transform 0.3s ease, max-height 0.3s ease, margin-top 0.3s ease;
    max-height: 300px;
    border-radius: 0 0 0.5rem 0.5rem;
}

#password-strength-wrapper.strength-hidden {
    opacity: 0;
    transform: translateY(-10px);
    max-height: 0;
    margin-top: 0;
    pointer-events: none;
}

#password-help-panel {
    text-align: left;
    font-size: 0.875rem;
    max-height: 0;
    opacity: 0;
    overflow: hidden;
    padding: 0 12px;
    transition: max-height 0.3s ease-in-out, opacity 0.3s ease-in-out, padding 0.3s ease-in-out;
    background-color: var(--surface-container);
}

#password-help-panel.panel-visible {
    max-height: 200px;
    opacity: 1;
    padding: 1rem;
}

#password-help-panel ul {
    list-style: none;
    padding: 0;
}

#password-input-error {
    padding: 0.5rem 0 0 0;
}

.tip-unmet {
    color: var(--on-surface-variant);
}

.tip-met {
    color: var(--on-surface);
}

.passphrase-checklist-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.5rem 1rem;
}


/* --- M3 Text Field --- */
.m3-textfield {
    position: relative;
    background-color: var(--surface-container);
    border-radius: 0.5rem;
    transition: background-color 0.2s;
}

.m3-textfield::after {
    content: '';
    position: absolute;
    left: 0;
    bottom: 0;
    width: 100%;
    height: 1px;
    background-color: var(--on-surface-variant);
    transition: background-color 0.2s;
}

.m3-textfield::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 1.9rem;
    background-color: var(--surface-container);
    z-index: 2;
    opacity: 0;
    transition: opacity 0.2s;
    border-radius: 0.5rem;
}

.m3-textfield:has(textarea.m3-textfield-input:not(:placeholder-shown))::before,
.m3-textfield:has(textarea.m3-textfield-input:focus)::before {
    opacity: 1;
}

.m3-textfield .m3-textfield-label {
    position: absolute;
    left: 1rem;
    top: 1rem;
    color: var(--on-surface-variant);
    pointer-events: none;
    transition: all 0.2s ease-out;
    transform-origin: left top;
    z-index: 1;
}

.m3-textfield .m3-textfield-input:focus~.m3-textfield-label,
.m3-textfield .m3-textfield-input:not(:placeholder-shown)~.m3-textfield-label {
    transform: translateY(-0.5rem) scale(0.75);
    color: var(--primary);
    z-index: 3;
}


.m3-textfield .m3-textfield-input {
    width: 100%;
    border: none;
    background: transparent;
    padding: 1.5rem 1rem 0.5rem;
    color: var(--on-surface);
    outline: none;
    position: relative;
    z-index: 1;
}

.m3-textfield .m3-textfield-input::placeholder {
    color: transparent;
}

.m3-textfield .m3-textfield-line {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 2px;
    background-color: var(--primary);
    transform: scaleX(0);
    transition: transform 0.2s ease-out;
    z-index: 3;
}

.m3-textfield .m3-textfield-input:focus~.m3-textfield-line {
    transform: scaleX(1);
}

.m3-textfield .m3-textfield-adornment-end {
    position: absolute;
    top: 50%;
    right: 0.75rem;
    transform: translateY(-50%);
    display: flex;
    align-items: center;
    gap: 0.25rem;
    z-index: 3;
}

.m3-textfield:has(textarea) .m3-textfield-adornment-end {
    top: 1rem;
    transform: none;
}

.m3-textfield .m3-textfield-input.has-trailing-adornment {
    padding-right: 3.5rem;
}

.m3-textfield .m3-textfield-input.has-trailing-adornments {
    padding-right: 6rem;
}

#copy-data-btn {
    position: absolute;
    top: 6px;
    right: 6px;
}

.m3-textfield.error .m3-textfield-label,
.m3-textfield.error .m3-textfield-input:focus~.m3-textfield-label,
.m3-textfield.error .m3-textfield-input:not(:placeholder-shown)~.m3-textfield-label {
    color: var(--error);
}

.m3-textfield.error .m3-textfield-line {
    background-color: var(--error);
    transform: scaleX(1);
}

.m3-textfield.error::after {
    background-color: var(--error);
}

.m3-textfield.is-invalid::after {
    background-color: var(--error);
}

.m3-textfield.is-invalid .m3-textfield-input:focus~.m3-textfield-line {
    background-color: var(--error);
}

.m3-textfield.is-invalid .m3-textfield-input:focus~.m3-textfield-label,
.m3-textfield.is-invalid .m3-textfield-input:not(:placeholder-shown)~.m3-textfield-label {
    color: var(--error);
}

/* --- M3 Switch --- */
#make-secure-container:not(.opacity-50):not(.secure-active):hover {
    background-color: var(--surface-container-low);
}

#make-secure-container.secure-active {
    background-color: var(--primary-container);
}

#make-secure-container.secure-active p {
    color: var(--on-primary-container);
}

.md3-switch {
    position: relative;
    width: 52px;
    height: 32px;
}

.md3-switch input {
    opacity: 0;
    width: 0;
    height: 0;
    position: absolute;
}

.md3-switch .track {
    display: flex;
    align-items: center;
    width: 100%;
    height: 100%;
    background-color: var(--surface-container-highest);
    border: 2px solid var(--outline);
    border-radius: 16px;
    transition: background-color 0.25s ease, border-color 0.25s ease;
}

.md3-switch .thumb {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    margin-left: 2px;
    background-color: var(--outline);
    border-radius: 50%;
    transition: all 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.md3-switch .icon {
    position: absolute;
    font-size: 16px;
    transition: opacity 0.15s ease;
}

.md3-switch .on-icon {
    opacity: 0;
    color: var(--on-primary-container);
}

.md3-switch .off-icon {
    opacity: 1;
    color: var(--surface-container-highest);
}

.md3-switch input:checked+.track {
    background-color: var(--primary);
    border-color: var(--primary);
}

.md3-switch input:checked+.track .thumb {
    width: 24px;
    height: 24px;
    margin-left: 22px;
    background-color: var(--on-primary);
}

.md3-switch input:checked+.track .on-icon {
    opacity: 1;
}

.md3-switch input:checked+.track .off-icon {
    opacity: 0;
}

.md3-switch input:not(:disabled)+.track:hover .thumb {
    box-shadow: 0 0 0 8px color-mix(in srgb, var(--on-surface) 8%, transparent);
}

.md3-switch input:checked:not(:disabled)+.track:hover .thumb {
    box-shadow: 0 0 0 8px color-mix(in srgb, var(--primary) 8%, transparent);
}

.md3-switch input:disabled+.track {
    background-color: color-mix(in srgb, var(--on-surface) 12%, transparent);
    border-color: color-mix(in srgb, var(--on-surface) 12%, transparent);
}

.md3-switch input:disabled+.track .thumb {
    background-color: color-mix(in srgb, var(--on-surface) 38%, transparent);
}

.md3-switch input:disabled:checked+.track {
    background-color: color-mix(in srgb, var(--on-surface) 12%, transparent);
}

.md3-switch input:disabled:checked+.track .thumb {
    background-color: var(--surface);
}

.md3-switch input:disabled:checked+.track .on-icon {
    color: color-mix(in srgb, var(--on-surface) 38%, transparent);
}

/* --- Secure Options & Security Keys Sections --- */
#secure-options-container {
    display: grid;
    grid-template-rows: 0fr;
    transition: grid-template-rows 300ms cubic-bezier(0.4, 0, 0.2, 1), margin-top 300ms cubic-bezier(0.4, 0, 0.2, 1);
}

#security-keys-section {
    display: grid;
    grid-template-rows: 0fr;
}

#secure-options-container.expanded,
#security-keys-section.expanded {
    grid-template-rows: 1fr;
}

#security-keys-section.expanded {
    margin-top: 1rem;
}

#secure-options-container>div,
#security-keys-section>div {
    overflow: hidden;
}

/* --- M3 List --- */
.m3-list-subheader {
    color: var(--primary);
    font-size: 0.875rem;
    /* 14px */
    line-height: 1.25rem;
    font-weight: 500;
    padding: 1rem 1rem 0.5rem;
    display: block;
}

#key-list {
    padding: 0 1rem 0.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

#download-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.m3-list-item {
    position: relative;
    display: flex;
    align-items: center;
    height: 56px;
    padding: 0 16px;
    overflow: hidden;
}

#key-list .m3-list-item {
    background-color: var(--surface);
    border-radius: 1rem;
    border: 1px solid var(--surface-container-highest);
}

html.dark #key-list .m3-list-item {
    border-color: var(--surface-container-high);
}

.m3-list-item-leading {
    display: flex;
    align-items: center;
    gap: 16px;
    flex-grow: 1;
}

.m3-list-item-leading .material-symbols-outlined {
    color: var(--on-surface-variant);
}

.m3-list-item-leading .m3-list-item-headline {
    color: var(--on-surface);
    font-size: 1rem;
    /* 16px */
    line-height: 1.5rem;
}

.m3-list-item-trailing {
    display: flex;
    align-items: center;
    margin-left: 16px;
}

.remove-key-btn:hover {
    color: var(--error);
}

.remove-key-btn:hover::before {
    background-color: var(--error);
}

.m3-split-button-divider {
    width: 1px;
    background-color: color-mix(in srgb, var(--on-secondary-container) 40%, transparent);
}

.m3-list-item-interactive {
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

/* --- M3 Split Button --- */
.m3-split-button {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    height: 40px;
    position: relative;
}

.m3-split-button > .m3-button {
    height: 100%;
    border: none;
    background-color: var(--primary);
    color: var(--on-primary);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
    -webkit-tap-highlight-color: transparent;
    transition: background-color 0.2s, border-radius 0.2s;
    font-size: 0.875rem;
    line-height: 1.25rem;
    font-weight: 500;
}

.m3-split-button > .m3-button::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    border-radius: inherit;
    opacity: 0;
    transition: opacity 150ms cubic-bezier(0.4, 0, 0.2, 1);
    pointer-events: none;
    background-color: var(--on-primary);
}

.m3-split-button > .m3-button:hover::before {
    opacity: 0.08;
}

.m3-split-button > .m3-button:focus-visible::before {
    opacity: 0.12;
}

.m3-split-button > .m3-button:active::before {
    opacity: 0.12;
}

.m3-split-button-leading {
    padding: 0 12px 0 16px;
    border-radius: 20px 4px 4px 20px;
}

.m3-split-button-trailing {
    padding: 0 9px;
    border-radius: 4px 20px 20px 4px;
}

.m3-split-button-leading:hover,
.m3-split-button-leading:focus-visible,
.m3-split-button-leading:active {
    border-radius: 20px 8px 8px 20px;
}

.m3-split-button-trailing:hover,
.m3-split-button-trailing:focus-visible,
.m3-split-button-trailing:active {
    border-radius: 8px 20px 20px 8px;
}

/* Increase specificity to override the :active state */
.m3-split-button > .m3-split-button-trailing.selected {
    border-radius: 20px !important;
}

.m3-split-button-menu {
    position: absolute;
    top: calc(100% + 4px);
    right: 0;
    background-color: var(--surface-container-high);
    border-radius: 0.5rem;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
    z-index: 10;
    overflow: hidden;
    transform-origin: top right;
    transition: transform 0.2s ease, opacity 0.2s ease;
    opacity: 0;
    transform: scale(0.95);
    pointer-events: none;
    min-width: 160px;
    padding: 0.5rem 0;
}

.m3-split-button-menu.open {
    opacity: 1;
    transform: scale(1);
    pointer-events: auto;
}

.m3-split-button-menu .m3-list-item {
    background-color: transparent;
    border: none;
    border-radius: 0;
    height: 48px;
    padding: 0 12px;
}

.m3-split-button-menu .m3-list-item-leading {
    gap: 12px;
}



/* --- M3 Toasts (Snackbars) --- */
#toast-container .m3-toast {
    background-color: var(--surface-container-highest);
    color: var(--on-surface);
    padding: 0.5rem 0.5rem 0.5rem 1rem;
    border-radius: 0.75rem;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.3s ease, transform 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    min-height: 48px;
    pointer-events: auto;
}

#toast-container .m3-toast .m3-icon-button {
    color: var(--on-surface-variant);
}

#toast-container .m3-toast .m3-icon-button::before {
    background-color: var(--on-surface-variant);
}

#toast-container .m3-toast.show {
    opacity: 1;
    transform: translateY(0);
}

/* 6. Animations & Transitions */
@keyframes spin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

.shake {
    animation: shake 0.5s;
}

@keyframes shake {

    0%,
    100% {
        transform: translateX(0);
    }

    25% {
        transform: translateX(-5px);
    }

    50% {
        transform: translateX(5px);
    }

    75% {
        transform: translateX(-5px);
    }
}

.ripple {
    position: absolute;
    border-radius: 50%;
    background-color: rgba(0, 0, 0, 0.1);
    transform: scale(0);
    animation: ripple-animation 600ms linear;
    pointer-events: none;
}

@keyframes ripple-animation {
    to {
        transform: scale(4);
        opacity: 0;
    }
}

.wizard-step {
    animation-duration: 300ms;
    animation-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@keyframes fadeOut {
    from {
        opacity: 1;
    }

    to {
        opacity: 0;
    }
}

@keyframes slideInUp {
    from {
        transform: translateY(20px);
    }

    to {
        transform: translateY(0);
    }
}

@keyframes slideOutUp {
    from {
        transform: translateY(0);
    }

    to {
        transform: translateY(-20px);
    }
}

.fade-in {
    animation-name: fadeIn;
}

.fade-out {
    animation-name: fadeOut;
}

.slide-in-up {
    animation-name: slideInUp, fadeIn;
}

.slide-out-up {
    animation-name: slideOutUp, fadeOut;
}

/* --- Processing Spinner --- */
.download-options-grid {
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: center;
    gap: 1rem;
}

.download-options-grid > *:nth-child(even) {
    justify-self: end;
}

.download-options-grid > *:nth-child(odd) {
    text-align: left;
}

.processing-spinner {
    width: 56px;
    height: 56px;
    border: 7px solid var(--surface-container-highest);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

/* --- Responsive Typography & Layout --- */

/* 7. Print Styles */

.main-container {
    margin-top: 1rem;
    margin-bottom: 1rem;
}

#wizard-step-data-entry .auto-resize-textarea {
    max-height: none; /* Allow textarea to grow beyond its original max-height */
}

@media print {

    /* Reset body to be a simple block element, not flex */
    body {
        display: block !important;
        min-height: 0 !important;
        background: #fff !important;
        margin: 0 !important;
    }

    /* Hide all top-level elements except for the main container */
    body>*:not(#main-container) {
        display: none !important;
    }

    /* Reset all containers in the hierarchy */
    #main-container,
    #app-content,
    #wizard-container {
        all: initial !important;
        display: block !important;
        background: #fff !important;
    }

    /* Hide all steps except the result step */
    #wizard-container>*:not(#wizard-step-result) {
        display: none !important;
    }

    /* Make the result step visible and centered */
    #wizard-step-result {
        display: block !important;
        padding: 0 !important;
        margin: 0 !important;
        /* Added to be certain */
        text-align: center !important;
        page-break-inside: avoid;
    }

    /* Container for centering, full width of printable area */
    #qrcode-output-container-inline {
        display: block !important;
        width: auto !important;
        /* Allow container to shrink to content */
        margin: 0 auto !important;
        page-break-inside: avoid;
        border-radius: 0 !important;
    }

    /* Apply border and padding directly to the canvas, remove rounded corners */
    #qrcode-output-container-inline canvas {
        display: block !important;
        max-width: 100% !important;
        /* Don't overflow page, allow scaling */
        height: auto !important;
        border: 2px dashed #333 !important;
        padding: 1.5em !important;
        box-sizing: border-box !important;
        border-radius: 0 !important;
    }

    /* Hide the text input field for the label */
    .m3-textfield:has(#qr-label-input) {
        display: none !important;
    }

    /* Hide any other UI elements that might be visible */
    .m3-textfield-line,
    .m3-textfield-label,
    .m3-textfield-adornment-end,
    #qr-label-meta,
    #actions-container,
    .dialog-scrim,
    #toast-container,
    #drag-overlay,
    #scanner-container,
    #download-section,
    #main-container>.flex.justify-between {
        display: none !important;
    }
}