/* DocCam Plus: small glass surfaces around an unobstructed document. */
:root {
    color-scheme: light;
    --page: #edf1f7;
    --ink: #182536;
    --muted: #59697d;
    --glass: rgba(250, 252, 255, .88);
    --solid: #f6f8fc;
    --edge: rgba(255, 255, 255, .9);
    --line: rgba(35, 55, 80, .16);
    --field: rgba(255, 255, 255, .85);
    --accent: #245bc4;
    --selected: #dce8ff;
    --shadow: 0 12px 42px rgba(30, 48, 80, .12), 0 2px 8px rgba(30, 48, 80, .06);
}
:root[data-theme="dark"] {
    color-scheme: dark;
    --page: #111925;
    --ink: #edf3ff;
    --muted: #b1bfd2;
    --glass: rgba(29, 40, 57, .92);
    --solid: #1d2839;
    --edge: rgba(200, 220, 255, .16);
    --line: rgba(200, 220, 255, .2);
    --field: #263449;
    --accent: #a0c2ff;
    --selected: #304c74;
    --shadow: 0 12px 42px rgba(0, 0, 0, .25);
}
* { box-sizing: border-box; }
body {
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    color: var(--ink);
    background: radial-gradient(ellipse at 14% 18%, #809eeb20, transparent 55%),
                radial-gradient(ellipse at 86% 74%, #68c9b820, transparent 50%), var(--page);
    min-height: 100dvh;
}
button, input, select { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; opacity: .45; }
button:focus-visible, select:focus-visible, input:focus-visible, [tabindex]:focus-visible {
    outline: 3px solid var(--accent); outline-offset: 4px;
}
.app-header { position: fixed; inset: 0 0 auto; padding: 24px 30px; display: flex; align-items: center; justify-content: space-between; gap: 20px; z-index: 20; pointer-events: none; }
.app-header > * { pointer-events: auto; }
.brand { display: flex; gap: 12px; align-items: center; font-size: 20px; letter-spacing: -.6px; }
.brand strong { font-weight: 700; }
.brand small { display: block; font-size: 11px; color: var(--muted); letter-spacing: .3px; margin-top: 3px; }
.brand-mark { display: grid; place-items: center; width: 42px; height: 42px; border: 1px solid var(--edge); border-radius: 14px; background: var(--glass); box-shadow: var(--shadow); font-weight: 750; color: var(--accent); }
.header-actions { display: flex; align-items: center; gap: 16px; }
#camera-status { padding: 9px 13px; border-radius: 30px; background: var(--glass); font-size: 12px; max-width: 320px; }
#appearance-open, #welcome-camera, dialog button { border: 1px solid var(--line); background: var(--glass); color: var(--ink); padding: 10px 16px; border-radius: 12px; }
#empty-state { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; flex-direction: column; text-align: center; padding: 110px 20px 130px; }
#empty-state[hidden] { display: none; }
.empty-eyebrow { color: var(--accent); font-size: 10px; font-weight: 750; letter-spacing: 2.5px; }
#empty-state h1 { font-size: clamp(36px, 5vw, 70px); line-height: 1.08; font-weight: 650; letter-spacing: -2.5px; margin: 22px 0 10px; }
#empty-state p { color: var(--muted); line-height: 1.7; font-size: 15px; }
#welcome-camera { background: #245bc4; color: white; margin: 14px 0 18px; padding: 14px 22px; box-shadow: 0 6px 20px #245bc42a; }
#welcome-camera span { padding-left: 22px; }
#empty-state small { font-size: 11px; color: var(--muted); }
#toolbar {
    left: 50%; right: auto; bottom: 22px; transform: translateX(-50%);
    width: max-content; max-width: calc(100vw - 32px); height: auto; min-height: 66px;
    padding: 10px 12px; gap: 5px; border: 1px solid var(--edge); border-radius: 22px;
    background: var(--glass); box-shadow: var(--shadow); backdrop-filter: blur(16px);
    z-index: 100; overflow-x: auto; justify-content: flex-start;
}
.toolbar-icon { flex-shrink: 0; width: 42px; height: 42px; font-size: 19px; border: 0; background: transparent; color: var(--ink); border-radius: 12px; }
.toolbar-icon:hover { background: var(--field); }
.toolbar-icon:active { transform: scale(.96); }
.tool-selected, .thickness-selected { background: var(--selected); box-shadow: 0 0 0 2px var(--accent); }
#toolbar #camera-select, #toolbar #emoji-tool, #toolbar #camera-pause, #toolbar #save-image { margin-right: 10px; }
#toolbar-view-control { z-index: 101; bottom: 3px; right: 50%; transform: translateX(50%); width: 38px; height: 18px; line-height: 18px; background: var(--glass); border-radius: 7px; }
#toolbar-toggle { border: 0; background: transparent; color: var(--muted); width: 100%; height: 100%; font-size: 12px; display: block; }
#toolbar.toolbar-minimized { bottom: -100px !important; }
#toolbar-view-control.toolbar-view-control-minimized { bottom: 12px !important; }
.floating-menu, #camera-select-menu, #resolution-select-menu, #pip-select-menu,
#pip-resolution-select-menu, #recording-options-menu, #heart-popup-menu,
#loading-popup, #emoji-search-popup, #recording-duration, dialog {
    background: var(--glass); color: var(--ink); border: 1px solid var(--edge);
    box-shadow: var(--shadow); border-radius: 20px; backdrop-filter: blur(16px);
}
.floating-menu { bottom: 104px; left: 50%; transform: translateX(-50%); padding: 14px; height: auto; max-width: calc(100vw - 24px); overflow-x: auto; z-index: 110; }
#pencil-menu, #highlighter-menu, #emoji-menu { background: var(--glass); }
.floating-menu .thickness-icon { margin-top: 0; width: 30px; height: 30px; cursor: pointer; }
.floating-menu .toolbar-icon { font-size: 24px; vertical-align: middle; }
#camera-select-menu, #resolution-select-menu, #pip-select-menu,
#pip-resolution-select-menu, #recording-options-menu, #heart-popup-menu, #loading-popup {
    padding: 26px; width: min(420px, calc(100vw - 32px)); max-height: calc(100dvh - 130px); overflow: auto; z-index: 120;
}
h3 { font-family: inherit; color: var(--ink); font-size: 18px; font-weight: 650; margin: 0 0 20px; letter-spacing: -.4px; }
.mdc-button { background: var(--field); color: var(--ink); border: 1px solid var(--line); border-radius: 10px; padding: 10px 14px; margin: 6px 3px 0 0; }
.mdc-button:hover { background: var(--selected); }
select, #emoji-search-input { background: var(--field); color: var(--ink); border: 1px solid var(--line); border-radius: 10px; padding: 11px; width: 100%; margin: 8px 0 14px; }
label { font-size: 13px; }
.donate-link { color: var(--accent); }
#emoji-search-popup { width: min(640px, calc(100vw - 32px)); top: 100px; }
#clear-search { color: var(--ink); background: transparent; border: 0; }
#recording-duration { z-index: 130; padding: 4px 14px; }
#recording-options-menu h3, #recording-options-menu label { color: var(--ink); font-family: inherit; }
#recording-options-menu select { background: var(--field); color: var(--ink); border-color: var(--line); border-radius: 10px; font-family: inherit; }
#pip-container { border: 1px solid var(--edge); border-radius: 18px; box-shadow: var(--shadow); overflow: hidden; }
#expand-pip, #toggle-position-pip { border: 0; padding: 10px; border-radius: 8px; }
dialog { width: min(420px, calc(100vw - 32px)); padding: 26px; }
dialog::backdrop { background: #0e172a55; }
.dialog-heading { display: flex; justify-content: space-between; align-items: center; }
.dialog-heading h2 { margin: 0; font-size: 23px; letter-spacing: -.6px; }
.dialog-heading button { font-size: 22px; padding: 2px 10px; }
dialog p { color: var(--muted); font-size: 13px; line-height: 1.6; }
.setting-row { display: flex; align-items: center; gap: 9px; margin-top: 10px; }
.setting-hint { margin-left: 25px; }
#app-notice { opacity: 1; transition: opacity 250ms ease; pointer-events: none; }
#app-notice.notice-fading { opacity: 0; }
#app-notice { position: fixed; top: 90px; left: 50%; transform: translateX(-50%); max-width: min(560px, calc(100vw - 32px)); background: var(--solid); border: 1px solid var(--line); border-radius: 14px; padding: 14px 20px; z-index: 150; box-shadow: var(--shadow); font-size: 13px; }
:root[data-solid="true"] { --glass: var(--solid); }
:root[data-solid="true"] * { backdrop-filter: none !important; }
@supports not (backdrop-filter: blur(1px)) { :root { --glass: var(--solid); } }
@media (max-width: 720px) {
    .app-header { padding: 18px; }
    .brand small, #camera-status { display: none; }
    #appearance-open { padding: 9px 12px; font-size: 12px; }
    #toolbar { gap: 2px; padding: 8px; border-radius: 18px; }
    .toolbar-icon { width: 38px; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; } }
@media (forced-colors: active) { button, #toolbar, .floating-menu { border: 1px solid ButtonText; } .tool-selected { outline: 2px solid Highlight; } }

/* Workspace controls live in the dock; branding belongs only to the welcome view. */
.app-header[hidden] { display: none; }
#toolbar { gap: 4px; align-items: center; }
#toolbar #camera-select, #toolbar #emoji-tool, #toolbar #camera-pause, #toolbar #save-image { margin-right: 0; }
#toolbar .toolbar-icon { display: grid; place-items: center; margin: 0; padding: 0; line-height: 1; }
#toolbar #camera-select, #toolbar #emoji-tool, #toolbar #camera-pause, #toolbar #pip-menu { margin-right: 8px; }
#settings-dialog { width: min(680px, calc(100vw - 32px)); max-height: calc(100dvh - 32px); overflow-y: auto; padding: 30px; }
.panel-eyebrow { display: block; font-size: 10px; letter-spacing: 1.8px; font-weight: 700; color: var(--accent); margin-bottom: 8px; }
.settings-section { border-top: 1px solid var(--line); padding-top: 22px; margin-top: 24px; }
.settings-section h3 { margin-bottom: 6px; }
.settings-section p { margin-top: 8px; }
#settings-dialog #camera-status { padding: 0; border-radius: 0; max-width: none; background: none; display: block; }
.settings-footer { display: flex; justify-content: space-between; gap: 16px; margin-top: 24px; padding-top: 18px; border-top: 1px solid var(--line); font-size: 12px; color: var(--muted); }
.floating-menu:is(#pencil-menu, #highlighter-menu, #eraser-menu, #emoji-menu) { width: 360px; white-space: normal; overflow-y: auto; max-height: calc(100dvh - 140px); line-height: normal; padding: 18px; }
.palette-heading { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 14px; font-size: 14px; font-weight: 650; }
.palette-heading small { font-size: 10px; font-weight: 400; color: var(--muted); }
.size-row { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 8px; padding: 2px; }
.floating-menu .size-choice {
    display: flex; flex-direction: column; justify-content: center; align-items: center;
    gap: 9px; height: 66px; width: 100%; margin: 0; padding: 8px 2px;
    border: 1px solid var(--line); border-radius: 12px; background: var(--field); color: var(--ink);
    font: 11px system-ui, sans-serif; line-height: 1;
}
.size-sample { display: block; width: var(--sample-size); height: var(--sample-size); background: currentColor; border-radius: 50%; margin: auto; flex-shrink: 0; }
.floating-menu .size-choice[aria-pressed="true"] { background: var(--selected); border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); color: var(--accent); }
.size-choice:hover { border-color: var(--accent); }
.palette-options { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-start; gap: 8px; margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--line); }
.palette-options .toolbar-icon, .palette-options .emoji-item, .palette-options .fav-emoji { margin: 0; width: 38px; height: 38px; }
#emoji-search { margin: 4px 0 0; width: 100%; justify-content: center; }
.custom-color-row input[type="color"] { width: 38px; height: 38px; margin: 0; padding: 3px; }
:is(#pencil-menu, #highlighter-menu) .palette-options { display: grid; grid-template-columns: repeat(8, minmax(0, 1fr)); gap: 6px; }
:is(#pencil-menu, #highlighter-menu) .color-option { width: 100%; height: 38px; display: grid; place-items: center; }
.custom-color-row { grid-column: 1 / -1; display: flex; align-items: center; justify-content: space-between; padding-top: 8px; font-size: 12px; color: var(--muted); }
#eraser-preview { border-radius: 50%; }

#applets-dialog { width: min(740px, calc(100vw - 32px)); max-height: calc(100dvh - 32px); overflow-y: auto; }
.applet-catalog { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin: 24px 0; }
.applet-card { display: flex; flex-direction: column; align-items: flex-start; gap: 10px; text-align: left; background: var(--field); border: 1px solid var(--line); border-radius: 16px; padding: 18px; color: var(--ink); }
.applet-card:hover { border-color: var(--accent); background: var(--selected); }
.applet-card-icon { font-size: 30px; color: var(--accent); }
.applet-card strong { font-size: 15px; }
.applet-card > span:last-child { font-size: 12px; line-height: 1.6; color: var(--muted); }
.applet-output-note { border-top: 1px solid var(--line); padding-top: 16px; }
#clear-applets { background: var(--field); color: var(--ink); border: 1px solid var(--line); padding: 10px 14px; border-radius: 10px; }
#applet-layer { position: fixed; inset: 0; pointer-events: none; z-index: 40; }
.workspace-applet { position: absolute; pointer-events: auto; width: 270px; max-width: calc(100vw - 16px); border: 1px solid var(--edge); border-radius: 16px; background: var(--solid); color: var(--ink); box-shadow: var(--shadow); overflow: hidden; }
.applet-header { display: flex; align-items: center; justify-content: space-between; background: var(--solid); padding: 6px; border-bottom: 1px solid var(--line); }
.applet-header button { background: none; color: var(--ink); border: 0; border-radius: 8px; }
.applet-handle { flex: 1; text-align: left; cursor: move; touch-action: none; padding: 9px; font-size: 12px; font-weight: 650; }
.applet-close { width: 34px; height: 34px; font-size: 22px; }
.applet-body { padding: 16px; }
.applet-actions { display: flex; gap: 8px; }
.applet-actions button, .cover-controls button { background: var(--field); color: var(--ink); border: 1px solid var(--line); border-radius: 9px; padding: 8px 12px; font-size: 12px; }
.applet-clock { display: block; font-size: 48px; line-height: 1.3; font-variant-numeric: tabular-nums; text-align: center; letter-spacing: -1px; }
.clock-state { text-align: center; color: var(--muted); font-size: 12px; margin: 4px 0 16px; }
.clock-finished { outline: 3px solid var(--accent); }
.clock-finished .clock-state { color: var(--accent); font-weight: 750; }
.countdown-fields { display: flex; gap: 10px; margin-bottom: 10px; }
.countdown-fields label { flex: 1; font-size: 11px; color: var(--muted); }
.countdown-fields input[type="number"] { font: inherit; font-size: 14px; padding: 7px; margin-top: 4px; color: var(--ink); background: var(--field); border: 1px solid var(--line); border-radius: 8px; }
.blur-cover { width: 320px; height: 200px; min-width: 180px; min-height: 150px; max-height: calc(100dvh - 16px); resize: both; background: #798ba324; backdrop-filter: blur(24px); }
:root[data-solid="true"] .blur-cover { backdrop-filter: blur(24px) !important; }
.blur-cover .applet-body { padding: 0; }
.cover-controls { position: absolute; bottom: 0; left: 0; right: 0; background: var(--solid); padding: 10px; display: flex; align-items: center; gap: 12px; }
.cover-controls label { flex: 1; min-width: 0; font-size: 10px; color: var(--muted); }
.cover-controls input { display: block; width: 100%; }
.blur-cover.opaque-cover { background: var(--solid); backdrop-filter: none !important; }
@supports not (backdrop-filter: blur(1px)) { .blur-cover { background: var(--solid); } }
@media (max-width: 580px) { .applet-catalog { grid-template-columns: 1fr; } .applet-card { gap: 6px; padding: 14px; } #settings-dialog { padding: 22px; } }

/* Interactive-panel controls: consistent finger-sized targets on every input. */
:root { --dock-bottom: 64px; }
button, [role="button"], input, select { touch-action: manipulation; }
#camera-container { touch-action: none; }
#toolbar { bottom: var(--dock-bottom); transition: none; gap: 5px; }
#toolbar .toolbar-icon { width: 48px; height: 48px; min-width: 48px; min-height: 48px; font-size: 21px; }
#toolbar-view-control { bottom: calc(var(--dock-bottom) - 52px); width: 64px; height: 44px; line-height: 44px; border-radius: 12px; transition: none; background: color-mix(in srgb, var(--glass) 85%, transparent); }
#toolbar-toggle { min-width: 44px; min-height: 44px; font-size: 18px; }
.floating-menu { bottom: calc(var(--dock-bottom) + 92px); }
.floating-menu:is(#pencil-menu, #highlighter-menu, #eraser-menu, #emoji-menu) { width: 390px; max-height: calc(100dvh - var(--dock-bottom) - 112px); }
.floating-menu .size-choice { min-width: 44px; min-height: 72px; font-size: 13px; }
.palette-options .toolbar-icon, .palette-options .emoji-item, .palette-options .fav-emoji { width: 48px; height: 48px; min-height: 48px; }
:is(#pencil-menu, #highlighter-menu) .palette-options { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
:is(#pencil-menu, #highlighter-menu) .color-option { height: 48px; font-size: 28px; }
.custom-color-row input[type="color"] { width: 56px; height: 48px; }
.mdc-button, dialog button, .applet-actions button, .cover-controls button,
#expand-pip, #toggle-position-pip, #clear-applets, #clear-search { min-height: 48px; min-width: 48px; }
select, input[type="search"], #emoji-search-input { min-height: 48px; font-size: 16px; }
.setting-row { min-height: 48px; cursor: pointer; }
.setting-row input { width: 24px; height: 24px; }
.checkbox-container label, .donate-link { display: flex; align-items: center; min-height: 48px; }
.quick-stamps { display: flex; gap: 8px; width: 100%; }
.favorite-stamps { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 7px; width: 100%; }
.favorite-stamps .fav-emoji, .quick-stamps .emoji-item { background: var(--field); color: var(--ink); border: 1px solid var(--line); border-radius: 12px; width: 100%; min-width: 44px; min-height: 48px; font-size: 29px; margin: 0; padding: 0; }
.quick-stamps .emoji-item { width: 52px; }
.fav-emoji { -webkit-touch-callout: none; user-select: none; }
.favorites-label { display: flex; justify-content: space-between; gap: 10px; width: 100%; font-size: 13px; padding: 8px 0 4px; }
.favorites-label small { color: var(--muted); font-size: 11px; }
.emoji-search-results .emoji-item { width: 48px; height: 48px; border: 0; background: var(--field); }

#applets-dialog { width: min(450px, calc(100vw - 24px)); padding: 20px; }
#applets-dialog .dialog-heading h2 { font-size: 22px; }
#applets-dialog .panel-eyebrow { display: none; }
.applet-search-label { display: block; margin: 16px 0 6px; font-size: 12px; color: var(--muted); }
#applet-search { width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; color: var(--ink); background: var(--field); }
.applet-catalog { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin: 14px 0; max-height: min(38dvh, 300px); overflow-y: auto; overscroll-behavior: contain; touch-action: pan-y; }
.applet-card { padding: 12px; gap: 6px; min-height: 116px; }
.applet-card[hidden] { display: none; }
.applet-card-icon { font-size: 24px; }
.applet-card strong { font-size: 14px; }
.applet-card > span:last-child { font-size: 11px; line-height: 1.4; }
#applets-dialog .applet-output-note { font-size: 11px; line-height: 1.5; padding-top: 10px; }
.workspace-applet { width: 340px; }
.applet-header { min-height: 60px; }
.applet-handle { min-height: 48px; font-size: 14px; }
.applet-close { width: 48px; height: 48px; font-size: 26px; }
.applet-actions { gap: 12px; }
.applet-actions button { flex: 1; min-height: 56px; font-size: 16px; font-weight: 600; }
.applet-clock { font-size: 56px; }
.countdown-fields { gap: 12px; }
.countdown-fields label { min-width: 0; }
.time-field { flex: 1; min-width: 0; }
.time-stepper { display: grid; grid-template-columns: 44px minmax(0, 1fr) 44px; gap: 3px; margin-top: 6px; }
.time-stepper button { min-width: 44px; min-height: 48px; padding: 0; font-size: 23px; color: var(--ink); background: var(--field); border: 1px solid var(--line); border-radius: 9px; }
.time-stepper input[type="number"] { width: 100%; min-width: 0; height: 48px; margin: 0; padding: 2px; text-align: center; font-size: 17px; appearance: textfield; }
.time-stepper input::-webkit-inner-spin-button, .time-stepper input::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
.blur-cover { resize: none; min-width: 220px; min-height: 180px; height: 240px; }
.cover-controls { right: 58px; padding: 8px; background: none; }
.cover-controls button { font-size: 14px; background: var(--solid); }
.applet-resize { position: absolute; bottom: 3px; right: 3px; width: 56px; height: 56px; padding: 0; font-size: 26px; color: var(--ink); background: var(--solid); border: 1px solid var(--line); border-radius: 12px 0 12px 0; touch-action: none; cursor: nwse-resize; }
:root[data-sharing="true"][data-sharing-clearance="true"] { --dock-bottom: 140px; }





@media (max-width: 370px) { .favorite-stamps { grid-template-columns: repeat(4, minmax(0, 1fr)); } .time-stepper { grid-template-columns: 44px minmax(0, 1fr) 44px; } .applet-body { padding: 10px; } }

/* A searchable tool palette, matching the emoji search popup. */
#applets-dialog { position: fixed; top: 100px; left: 50%; transform: translateX(-50%); margin: 0; width: min(640px, calc(100vw - 32px)); max-height: calc(100dvh - 120px); padding: 16px; z-index: 150; }
#applets-dialog .dialog-heading h2 { font-size: 18px; }
.applet-search-label { margin-top: 8px; }
.applet-search-row { display: flex; align-items: center; gap: 8px; }
#applet-search { min-width: 0; flex: 1; }
#applet-clear-search { flex: 0 0 48px; padding: 0; font-size: 24px; }
#applet-catalog { grid-template-columns: repeat(auto-fill, 176px); justify-content: center; grid-auto-rows: 56px; gap: 10px; max-height: min(300px, 42dvh); padding: 4px; }
#applet-catalog .applet-card { display: flex; flex-direction: row; align-items: center; justify-content: flex-start; width: 176px; height: 56px; min-height: 56px; padding: 10px 12px; gap: 10px; border-radius: 10px; }
#applet-catalog .applet-card[hidden] { display: none; }
#applet-catalog .applet-card-icon { display: grid; place-items: center; width: 26px; flex: 0 0 26px; font-size: 24px; line-height: 1; }
#applet-catalog .applet-card strong { font-size: 14px; line-height: 1.2; }
#applet-catalog .applet-description { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
#recording-duration { width: max-content; min-width: 96px; height: 44px; padding: 0 16px; line-height: 44px; transform: none; text-align: center; pointer-events: none; }
#recording-info { width: auto; margin: 0; padding: 0; font: 600 18px/42px system-ui, sans-serif; font-variant-numeric: tabular-nums; letter-spacing: .5px; color: var(--ink); text-align: center; }

/* One panel frame and dock placement for tools and the Applets launcher. */
.tool-panel:is(#pencil-menu, #highlighter-menu, #eraser-menu, #emoji-menu, #template-menu, #applets-dialog, #emoji-search-popup) {
    position: fixed; top: auto; bottom: calc(var(--dock-bottom) + 92px);
    left: 50%; transform: translateX(-50%); margin: 0;
    width: 410px; max-width: calc(100vw - 24px); height: auto;
    max-height: calc(100dvh - var(--dock-bottom) - 112px);
    padding: 18px; overflow-y: auto; white-space: normal; line-height: normal;
    background: var(--glass); border: 1px solid var(--edge); border-radius: 20px;
    box-shadow: var(--shadow); backdrop-filter: blur(16px); z-index: 150;
}
.tool-panel-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: -18px -18px 16px; padding: 8px 12px 8px 18px; border-bottom: 1px solid var(--line); background: var(--solid); }
.tool-panel-header h2 { margin: 0; font: 650 15px/1.3 system-ui, sans-serif; color: var(--ink); }
.tool-panel-header .tool-panel-close { display: grid; place-items: center; flex: 0 0 48px; width: 48px; height: 48px; padding: 0; border: 0; border-radius: 10px; background: transparent; color: var(--ink); font: 24px/1 system-ui, sans-serif; }
.tool-panel-close:hover { background: var(--field); }

@media (max-width: 420px) { #applet-catalog { grid-template-columns: repeat(2, minmax(0, 1fr)); } #applet-catalog .applet-card { width: 100%; padding: 8px; gap: 6px; } }

/* Wider Applets shelf; the same shared panel behavior as Stamps. */
#applets-dialog.tool-panel { width: 640px; }
.emoji-search-container, .applet-search-row { display: flex; align-items: center; gap: 8px; width: 100%; }
#emoji-search-input, #applet-search { flex: 1; width: 0; min-width: 0; height: 48px; margin: 0; padding: 10px 12px; }
#clear-search, #applet-clear-search {
    display: grid; place-items: center; flex: 0 0 48px; width: 48px; height: 48px;
    margin: 0; padding: 0; border: 1px solid var(--line); border-radius: 10px;
    background: var(--field); color: var(--ink); font: 24px/1 system-ui, sans-serif;
}
#clear-search:disabled, #applet-clear-search:disabled { opacity: .4; }
#applet-search::-webkit-search-cancel-button { -webkit-appearance: none; }
