:root {
  --bg: #161617;
  --panel: #1e1f22;
  --panel-2: #24262a;
  --line: #34373d;
  --line-soft: #2b2e34;
  --text: #f2f2f3;
  --muted: #a3a7b0;
  --accent-light: #ffb08a;
  --accent: #f93a00;
  --accent-strong: #f66800;
  --accent-deep: #a82600;
  --accent-soft: rgba(249, 58, 0, 0.16);
  --accent-shadow: rgba(246, 104, 0, 0.3);
  --danger: #f87171;
  --radius: 14px;
  --ui-scale: 1;
  --ui-inverse-scale: 1;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; min-height: 100%; background: var(--bg); color: var(--text); font: 13px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; }
body { padding: 14px; overflow: hidden; }
button, input, select { font: inherit; }
button { user-select: none; }
h1, h2, p { margin: 0; }
h1 { font-size: 22px; line-height: 1.1; font-weight: 800; }
h2 { font-size: 15px; }

.app-shell { display: flex; flex-direction: column; gap: 12px; width: 100%; height: calc((100vh - 28px) * var(--ui-inverse-scale)); min-height: 0; zoom: var(--ui-scale); }
.topbar { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; flex: 0 0 auto; }
.muted { color: var(--muted); font-size: 11px; }
#statusText:empty { display: none; }
.tabs { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; flex: 0 0 auto; min-width: 0; }
.tab { min-height: 48px; padding: 8px; border-radius: 14px; border: 1px solid var(--line); background: var(--panel); color: var(--muted); display: flex; align-items: center; justify-content: center; cursor: pointer; transition: .18s ease; }
.tab:hover { filter: brightness(1.06); }
.tab.is-active { background: var(--panel-2); color: var(--text); border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent-soft); }
.tab-icon { width: 22px; height: 22px; display: block; color: #e7eefb; }
.main-tab-icon { width: 30px; height: 30px; }
.tab-icon path,
.tab-icon polygon { vector-effect: non-scaling-stroke; }

.panels { min-height: 0; flex: 1 1 auto; overflow: hidden; }
.panel { display: none; height: 100%; min-height: 0; flex-direction: column; gap: 10px; overflow: hidden; }
.panel.is-active { display: flex; }
.panel[data-panel="settings"].is-active,
.panel[data-panel="info"].is-active { overflow-y: auto; }
.card { display: flex; flex-direction: column; gap: 14px; padding: 16px; background: var(--panel); border: 1px solid var(--line-soft); border-radius: var(--radius); box-shadow: inset 0 1px 0 rgba(255,255,255,.02); }
.card-title-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.browser-card { min-height: 0; flex: 1 1 auto; overflow: hidden; position: relative; }
.saved-card { flex: 0 0 auto; }
.folder-title-wrap { min-width: 0; }
.path-label { color: var(--muted); font-size: 10px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }
.folder-actions { display: flex; gap: 8px; flex: 0 0 auto; }

.primary-btn, .ghost-btn, .icon-btn { min-height: 42px; border-radius: 14px; padding: 0 14px; cursor: pointer; transition: .18s ease; }
.primary-btn { background: linear-gradient(180deg, var(--accent), var(--accent-strong)); border: 0; color: #120904; font-weight: 800; }
.ghost-btn, .icon-btn { background: var(--panel-2); border: 1px solid rgba(255,255,255,.08); color: #f2f5fa; }
.primary-btn:hover, .ghost-btn:hover, .icon-btn:hover { filter: brightness(1.08); }
.primary-btn:disabled, .ghost-btn:disabled, .icon-btn:disabled { cursor: default; opacity: .45; filter: none; }
.icon-btn { width: 42px; padding: 0; flex: 0 0 auto; font-weight: 800; }

.toolbar-row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(188px, auto); gap: 10px; }
.toolbar-actions { display: grid; grid-template-columns: 116px 70px; gap: 8px; min-width: 0; }
label { display: flex; flex-direction: column; gap: 6px; }
label span, .field-title { color: #b5bcc8; font-size: 11px; letter-spacing: .03em; }
.input-field, .select-field { width: 100%; min-height: 42px; padding: 0 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--panel-2); color: var(--text); }
.input-field { text-align: left; }
.select-field { text-align: center; }
.view-toggle { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; min-height: 42px; padding: 4px; border-radius: 12px; border: 1px solid var(--line); background: var(--panel-2); }
.view-btn { min-width: 0; border: 0; border-radius: 9px; background: transparent; color: var(--muted); display: grid; place-items: center; cursor: pointer; }
.view-btn.is-active { background: var(--accent-soft); color: var(--text); box-shadow: inset 0 0 0 1px rgba(249,58,0,.24); }
.list-view-icon { width: 15px; height: 14px; display: grid; gap: 4px; }
.list-view-icon i { height: 2px; border-radius: 999px; background: currentColor; display: block; opacity: .9; }
.grid-view-icon { width: 15px; height: 15px; display: grid; grid-template-columns: repeat(2, 1fr); gap: 4px; }
.grid-view-icon i { border-radius: 2px; background: currentColor; display: block; opacity: .9; }
.checkbox { flex-direction: row; align-items: center; gap: 9px; color: var(--text); }
.checkbox input { appearance: none; width: 20px; height: 20px; border-radius: 6px; border: 1px solid var(--line); background: var(--panel-2); position: relative; flex: 0 0 auto; }
.checkbox input:checked { background: linear-gradient(180deg, var(--accent), var(--accent-strong)); border-color: transparent; }
.checkbox input:checked::after { content: ""; position: absolute; left: 6px; top: 3px; width: 5px; height: 10px; border: solid #120904; border-width: 0 2px 2px 0; transform: rotate(45deg); }

.saved-card { padding: 8px 12px; gap: 0; }
.saved-folders { display: flex; gap: 7px; overflow-x: auto; padding-bottom: 1px; }
.saved-folder { min-width: 78px; max-width: 150px; min-height: 28px; border: 1px solid var(--line); background: var(--panel-2); color: var(--text); border-radius: 10px; padding: 0 28px 0 10px; text-align: left; position: relative; cursor: pointer; }
.saved-folder.is-active { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent-soft); }
.saved-folder.is-missing { border-color: transparent; background: linear-gradient(180deg, var(--accent), var(--accent-strong)); color: #120904; }
.saved-folder.is-missing .saved-folder-remove { background: rgba(0,0,0,.16); color: #120904; }
.saved-folder strong, .saved-folder small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.saved-folder strong { font-size: 12px; }
.saved-folder small { display: none; }
.saved-folder-remove { position: absolute; top: 50%; right: 7px; transform: translateY(-50%); width: 18px; height: 18px; border-radius: 999px; border: 0; background: rgba(255,255,255,.08); color: var(--muted); line-height: 1; padding: 0; cursor: pointer; text-align: center; display: grid; place-items: center; }
.saved-empty { min-height: 24px; display: flex; align-items: center; color: var(--muted); font-size: 11px; }

.file-list { flex: 1 1 auto; min-width: 0; min-height: 0; overflow-y: auto; overflow-x: hidden; display: flex; flex-direction: column; gap: 6px; padding-right: 2px; }
.file-list.is-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); align-content: start; gap: 10px; }
.empty-state { min-height: 72px; display: grid; place-items: center; text-align: center; color: var(--muted); border: 1px dashed var(--line); border-radius: 14px; padding: 14px; }
.file-row { min-width: 0; max-width: 100%; min-height: 48px; border: 0; border-radius: 12px; background: var(--panel-2); display: grid; grid-template-columns: 30px minmax(0, 1fr) auto; align-items: center; gap: 10px; padding: 9px 11px; cursor: pointer; overflow: hidden; box-shadow: inset 0 0 0 1px transparent; }
.file-row:hover { filter: brightness(1.07); }
.file-row.is-selected { box-shadow: inset 0 0 0 1px var(--accent), inset 0 0 0 2px var(--accent-soft); }
.file-preview { width: 28px; max-width: 100%; height: 28px; border-radius: 9px; display: grid; place-items: center; background: rgba(255,255,255,.06); color: #dce7f5; overflow: hidden; position: relative; }
.file-preview.has-media { background: #101113; }
.audio-preview { cursor: pointer; }
.audio-preview.is-playing { background: linear-gradient(180deg, var(--accent), var(--accent-strong)); color: #120904; }
.audio-preview.is-playing .file-icon { opacity: .18; }
.audio-preview:hover .file-icon { opacity: 0; }
.audio-play { position: absolute; left: 50%; top: 50%; width: 0; height: 0; display: none; transform: translate(-35%, -50%); border-top: 6px solid transparent; border-bottom: 6px solid transparent; border-left: 9px solid currentColor; pointer-events: none; }
.audio-pause { position: absolute; inset: 0; display: none; align-items: center; justify-content: center; gap: 3px; pointer-events: none; }
.audio-pause i { width: 3px; height: 13px; border-radius: 999px; background: currentColor; }
.audio-preview:not(.is-playing):hover .audio-play { display: block; }
.audio-preview.is-playing:hover .audio-wave { display: none; }
.audio-preview.is-playing:hover .audio-pause { display: flex; }
.audio-wave { position: absolute; inset: 0; display: none; align-items: center; justify-content: center; gap: 2px; pointer-events: none; }
.audio-wave i { width: 3px; height: 8px; border-radius: 999px; background: currentColor; animation: audioPulse .62s ease-in-out infinite alternate; }
.audio-wave i:nth-child(2) { height: 14px; animation-delay: .12s; }
.audio-wave i:nth-child(3) { animation-delay: .24s; }
.audio-preview.is-playing .audio-wave { display: flex; }
body.no-file-previews .file-preview.has-media img,
body.no-file-previews .file-preview.has-media video,
body.no-file-previews .file-preview .play-mark { display: none; }
body.no-file-previews .file-preview.has-media { background: rgba(255,255,255,.06); }
.file-preview img, .file-preview video { width: 100%; min-width: 0; max-width: 100%; height: 100%; min-height: 0; object-fit: cover; object-position: center; display: block; }
.file-icon { width: 100%; height: 100%; border-radius: inherit; display: grid; place-items: center; color: inherit; font-size: 13px; font-weight: 800; }
.play-mark { position: absolute; left: 50%; top: 50%; width: 0; height: 0; transform: translate(-38%, -50%); border-top: 6px solid transparent; border-bottom: 6px solid transparent; border-left: 9px solid rgba(255,255,255,.86); filter: drop-shadow(0 1px 4px rgba(0,0,0,.6)); pointer-events: none; }
.file-row > span { min-width: 0; max-width: 100%; overflow: hidden; }
.file-name, .file-meta { display: block; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-name { font-size: 12px; font-weight: 700; }
.file-meta { color: var(--muted); font-size: 10px; }
.file-tags { display: inline-flex; align-items: center; justify-content: flex-end; gap: 7px; min-width: 0; max-width: 100%; overflow: hidden; }
.file-kind { color: var(--muted); font-size: 10px; text-transform: uppercase; letter-spacing: .04em; }
.favorite-btn { width: 22px; height: 22px; flex: 0 0 22px; display: grid; place-items: center; padding: 0; border: 0; border-radius: 8px; background: transparent; color: var(--muted); line-height: 1; cursor: pointer; }
.favorite-btn:hover { background: rgba(255,255,255,.06); color: var(--text); }
.favorite-btn.is-active { color: var(--accent-light); text-shadow: 0 0 14px var(--accent-shadow); }
.file-list.is-grid .file-row { width: 100%; min-width: 0; max-width: 100%; min-height: 138px; grid-template-columns: minmax(0, 1fr); grid-template-rows: 72px minmax(0, 1fr) 14px; justify-items: stretch; align-items: center; gap: 8px; padding: 11px; text-align: center; }
.file-list.is-grid .file-preview { width: 100%; max-width: 100%; height: 72px; border-radius: 10px; justify-self: stretch; }
.file-list.is-grid .file-icon { font-size: 18px; }
.file-list.is-grid .file-name { max-width: 100%; white-space: normal; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; min-height: 34px; }
.file-list.is-grid .file-meta { display: none; }
.file-list.is-grid .file-tags { justify-content: center; width: 100%; }
.file-list.is-grid .file-kind { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 9px; }
.file-action-bar { display: none; flex: 0 0 auto; width: 100%; grid-template-columns: 1fr minmax(0, calc(25% - 24px)) minmax(0, calc(25% - 24px)) 36px 1fr; gap: 8px; align-items: end; padding-top: 8px; background: var(--panel); }
.file-action-bar.is-visible { display: grid; }
.file-action-bar .selection-meta { grid-column: 1 / -1; }
.file-action-bar .primary-btn { grid-column: 2; }
.file-action-bar .ghost-btn { grid-column: 3; }
.file-action-bar .icon-btn { grid-column: 4; }
.file-action-bar .primary-btn, .file-action-bar .ghost-btn, .file-action-bar .icon-btn { min-height: 34px; border-radius: 12px; }
.file-action-bar .icon-btn { width: 36px; }

@media (max-width: 430px) {
  .toolbar-row { grid-template-columns: 1fr; }
  .toolbar-actions { grid-template-columns: minmax(0, 1fr) 70px; }
}

.selection-meta { display: flex; justify-content: center; align-items: center; gap: 10px; color: var(--muted); font-size: 10px; }
.selection-meta strong { color: var(--text); font-size: 12px; }
.customize-size-row { display: grid; grid-template-columns: 44px 1fr 44px; gap: 10px; align-items: center; }
.scale-value { min-height: 42px; display: grid; place-items: center; border-radius: 12px; border: 1px solid var(--line); background: var(--panel-2); color: var(--text); font-weight: 800; font-size: 15px; }
.theme-preset-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.theme-preset { min-height: 64px; padding: 8px 6px; border-radius: 13px; border: 1px solid var(--line); background: var(--panel-2); color: var(--muted); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 7px; font-size: 10px; font-weight: 800; cursor: pointer; transition: .18s ease; }
.theme-preset span { width: 22px; height: 22px; border-radius: 999px; background: radial-gradient(circle at 30% 25%, var(--swatch-light), var(--swatch), var(--swatch-strong), var(--swatch-deep)); box-shadow: 0 7px 18px rgba(0,0,0,.28), inset 0 1px 2px rgba(255,255,255,.35); }
.theme-preset:hover, .theme-preset.is-active { color: var(--text); border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent-soft); }
.theme-preset[data-theme="what"] { --swatch-light: #ffb08a; --swatch: #f93a00; --swatch-strong: #f66800; --swatch-deep: #a82600; }
.theme-preset[data-theme="blue"] { --swatch-light: #bfe3ff; --swatch: #62b0ff; --swatch-strong: #318dff; --swatch-deep: #1a5fc7; }
.theme-preset[data-theme="mint"] { --swatch-light: #c7ffe7; --swatch: #5ee6ae; --swatch-strong: #23c986; --swatch-deep: #0f7f59; }
.theme-preset[data-theme="amber"] { --swatch-light: #fff0b8; --swatch: #ffd166; --swatch-strong: #f5a524; --swatch-deep: #b76a08; }
.theme-preset[data-theme="rose"] { --swatch-light: #ffd1dc; --swatch: #ff8fab; --swatch-strong: #f45d83; --swatch-deep: #b91c50; }
.theme-preset[data-theme="violet"] { --swatch-light: #ddd2ff; --swatch: #b59cff; --swatch-strong: #8b5cf6; --swatch-deep: #5536b8; }

.card-copy { color: #c4cad5; font-size: 12px; line-height: 1.45; }
.info-card { flex: 0 0 auto; }
.info-banner { display: block; width: 100%; border-radius: 12px; }
.support-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.support-grid .ghost-btn { min-width: 0; padding: 0 8px; }

.toast { position: fixed; left: 50%; bottom: 18px; transform: translate(-50%, 12px); z-index: 1000; padding: 9px 13px; border-radius: 999px; background: #272a30; border: 1px solid var(--line); color: var(--text); opacity: 0; pointer-events: none; transition: .18s ease; box-shadow: 0 12px 28px rgba(0,0,0,.36); }
.toast.is-visible { opacity: 1; transform: translate(-50%, 0); }
.context-menu { position: fixed; z-index: 1200; display: none; min-width: 172px; padding: 6px; border-radius: 12px; border: 1px solid var(--line); background: #25272c; box-shadow: 0 16px 34px rgba(0,0,0,.42); }
.context-menu.is-visible { display: block; }
.context-menu button { width: 100%; min-height: 32px; padding: 0 10px; border: 0; border-radius: 8px; background: transparent; color: var(--text); text-align: left; cursor: pointer; }
.context-menu button:hover { background: var(--accent-soft); }

@keyframes audioPulse {
  from { transform: scaleY(.45); opacity: .65; }
  to { transform: scaleY(1); opacity: 1; }
}
