/* Re:Vault — universal theme. All colors are CSS variables so the theme is fully
   user-tweakable. Dark by default; [data-theme="light"] flips the tokens. */
:root {
	--accent: #e9c46a;
	--accent-2: #bf953f;
	--font: Verdana, Geneva, Tahoma, sans-serif;
	--fs: 13px;
	--icon: 17px;
	--ctrl: 34px;

	--bg: #000;
	--surface: #0c0c0c;
	--surface-2: #161616;
	--line: #1c1c1c;
	--fg: #ededed;
	--fg-2: #cfcfcf;
	--muted: #8a8a8a;
	--muted-2: #9a9a9a;
	--danger: #ff6b6b;
	/* corner-roundness tiers (overridden per cornerStyle by app/theme.js) */
	--radius-sm: 6px;
	--radius: 8px;
	--radius-lg: 12px;
	--radius-pill: 22px;
	/* translucent chrome surface, used only when a wallpaper is active */
	--veil: rgba(0, 0, 0, 0.5);
}
/* --- base color schemes (data-theme); --veil set on the light-mode ones ------ */
:root[data-theme="slate"] {
	--bg: #15171b; --surface: #1e2127; --surface-2: #2a2e35; --line: #333841;
	--fg: #f0f1f4; --fg-2: #ccd0d7; --muted: #9197a1; --muted-2: #a0a7b1;
}
:root[data-theme="midnight"] {
	--bg: #080d1a; --surface: #111a30; --surface-2: #1b2742; --line: #28354f;
	--fg: #e9eef8; --fg-2: #c6cfe3; --muted: #8893ad; --muted-2: #97a2bb;
}
:root[data-theme="plum"] {
	--bg: #120a1a; --surface: #1d1230; --surface-2: #291a3c; --line: #37254c;
	--fg: #efe9f5; --fg-2: #d4cae0; --muted: #9d90b0; --muted-2: #ab9ebd;
}
:root[data-theme="forest"] {
	--bg: #0a140e; --surface: #111e16; --surface-2: #1a2c20; --line: #26392c;
	--fg: #e9f2ec; --fg-2: #c8d6cd; --muted: #8a9b91; --muted-2: #9aab9f;
}
:root[data-theme="light"] {
	--bg: #f5f5f6; --surface: #ffffff; --surface-2: #ececee; --line: #dcdce0;
	--fg: #16181d; --fg-2: #33363d; --muted: #5b5e66; --muted-2: #4a4d54;
	--veil: rgba(245, 245, 246, 0.62);
}
:root[data-theme="sepia"] {
	--bg: #f4efe4; --surface: #fdf9f1; --surface-2: #ece3d2; --line: #ddd2bd;
	--fg: #2a2620; --fg-2: #473f33; --muted: #6e6450; --muted-2: #5a5142;
	--veil: rgba(244, 239, 228, 0.62);
}
/* more standard dark palettes */
:root[data-theme="crimson"] { --bg: #1a0d10; --surface: #261218; --surface-2: #341921; --line: #43232d; --fg: #f5e8eb; --fg-2: #e6c9cf; --muted: #bb8e95; --muted-2: #c99ca3; }
:root[data-theme="ocean"] { --bg: #08161c; --surface: #0f222a; --surface-2: #173039; --line: #21404b; --fg: #e7f3f6; --fg-2: #c6dde2; --muted: #8ba7af; --muted-2: #9bb7bf; }
:root[data-theme="rose"] { --bg: #1a0e15; --surface: #26141f; --surface-2: #341d2b; --line: #43283a; --fg: #f6e9f0; --fg-2: #e6cdd9; --muted: #bb909f; --muted-2: #c9a0af; }
:root[data-theme="mocha"] { --bg: #17110d; --surface: #221a14; --surface-2: #30251c; --line: #3f3024; --fg: #f1e9e0; --fg-2: #dbcdbe; --muted: #ab9b8a; --muted-2: #bbab9a; }
:root[data-theme="nord"] { --bg: #2e3440; --surface: #3b4252; --surface-2: #434c5e; --line: #4c566a; --fg: #eceff4; --fg-2: #d8dee9; --muted: #a7b0c0; --muted-2: #b8c0cd; }
:root[data-theme="dracula"] { --bg: #282a36; --surface: #343746; --surface-2: #424557; --line: #4d5068; --fg: #f8f8f2; --fg-2: #dddde2; --muted: #aab0c2; --muted-2: #bcc0ce; }
/* Vocaloid character palettes */
:root[data-theme="miku"] { --bg: #07171a; --surface: #0e2428; --surface-2: #163337; --line: #20454a; --fg: #e6f6f5; --fg-2: #c3dedb; --muted: #88aaa6; --muted-2: #98bab6; }
:root[data-theme="teto"] { --bg: #190a0c; --surface: #261013; --surface-2: #34181c; --line: #442026; --fg: #f6e9ea; --fg-2: #e6cccf; --muted: #bb9094; --muted-2: #c9a0a3; }
:root[data-theme="rin"] { --bg: #1a1206; --surface: #261c0d; --surface-2: #342817; --line: #443521; --fg: #f6efe2; --fg-2: #e4d6bf; --muted: #b39d7a; --muted-2: #c1ac8a; }
:root[data-theme="len"] { --bg: #181606; --surface: #24210d; --surface-2: #322e16; --line: #423c20; --fg: #f5f2e0; --fg-2: #dfdabb; --muted: #ada577; --muted-2: #bbb487; }
:root[data-theme="luka"] { --bg: #1a0e13; --surface: #27151f; --surface-2: #351e2c; --line: #44283a; --fg: #f7e9f0; --fg-2: #e6ccd8; --muted: #bb909f; --muted-2: #c9a0af; }
:root[data-theme="kaito"] { --bg: #08101f; --surface: #0f1a30; --surface-2: #182742; --line: #233452; --fg: #e8eef9; --fg-2: #c8d1e6; --muted: #8b96b3; --muted-2: #9ba6c1; }
:root[data-theme="meiko"] { --bg: #1a0a0a; --surface: #271010; --surface-2: #351818; --line: #452323; --fg: #f6e8e8; --fg-2: #e6c9c9; --muted: #bb8e8e; --muted-2: #c99c9c; }
:root[data-theme="gumi"] { --bg: #0a160e; --surface: #112015; --surface-2: #1a2e20; --line: #25402c; --fg: #e8f4ec; --fg-2: #cbdecf; --muted: #8ca895; --muted-2: #9cb8a5; }
:root[data-theme="naruto"] { --bg: #1a1005; --surface: #281a0a; --surface-2: #3e3123; --line: #53483b; --fg: #f7e8d4; --fg-2: #f0d5b0; --muted: #c0a06c; --muted-2: #c6aa7b; }
:root[data-theme="sasuke"] { --bg: #0c0e1a; --surface: #161a2c; --surface-2: #2d3141; --line: #454856; --fg: #e4e6f1; --fg-2: #cdd2e6; --muted: #9197b3; --muted-2: #9ca1bb; }
:root[data-theme="sakura"] { --bg: #1a0e14; --surface: #28141e; --surface-2: #3e2c35; --line: #53434b; --fg: #f5e3ea; --fg-2: #ecccd8; --muted: #c191a0; --muted-2: #c79caa; }
:root[data-theme="kakashi"] { --bg: #12161a; --surface: #1c2228; --surface-2: #33383e; --line: #494e53; --fg: #e4e7ea; --fg-2: #cdd4d8; --muted: #8e979c; --muted-2: #99a1a6; }
:root[data-theme="itachi"] { --bg: #160709; --surface: #220c10; --surface-2: #382428; --line: #4e3d40; --fg: #f2dfe1; --fg-2: #e8c4c8; --muted: #bd868c; --muted-2: #c49298; }
:root[data-theme="gaara"] { --bg: #1a1308; --surface: #281d0e; --surface-2: #3e3426; --line: #534a3e; --fg: #f5ead6; --fg-2: #ecd9b5; --muted: #bd9f72; --muted-2: #c4a980; }
:root[data-theme="hinata"] { --bg: #14101c; --surface: #1f1830; --surface-2: #352f45; --line: #4c4659; --fg: #eae5f3; --fg-2: #d8d0ea; --muted: #a89fc4; --muted-2: #b1a9ca; }
:root[data-theme="lee"] { --bg: #0a160e; --surface: #112016; --surface-2: #29362d; --line: #414d45; --fg: #e2ece5; --fg-2: #cbddcf; --muted: #8ca895; --muted-2: #98b1a0; }
:root[data-theme="jeffy"] { --bg: #161806; --surface: #22260d; --surface-2: #383c25; --line: #4e513d; --fg: #eceed9; --fg-2: #dde0ba; --muted: #aaad78; --muted-2: #b3b586; }
:root[data-theme="mario"] { --bg: #190809; --surface: #260d0f; --surface-2: #3c2527; --line: #513d3f; --fg: #f2e0e1; --fg-2: #e8c6c8; --muted: #bd888a; --muted-2: #c49496; }
:root[data-theme="bowser"] { --bg: #0e1606; --surface: #18230c; --surface-2: #2f3924; --line: #464f3d; --fg: #e8ecd9; --fg-2: #d6ddba; --muted: #a6aa78; --muted-2: #afb386; }
:root[data-theme="junior"] { --bg: #0c160f; --surface: #14201a; --surface-2: #2c3631; --line: #434d48; --fg: #e1ece5; --fg-2: #c9ddd0; --muted: #8ba996; --muted-2: #97b2a1; }
:root[data-theme="cody"] { --bg: #100e1c; --surface: #1a1730; --surface-2: #312e45; --line: #484559; --fg: #e6e3f1; --fg-2: #d2cce6; --muted: #9a93bd; --muted-2: #a49ec4; }
:root[data-theme="woodland"] { --bg: #0c160e; --surface: #142017; --surface-2: #2c362e; --line: #434d45; --fg: #e2ece5; --fg-2: #cbdccf; --muted: #8ba894; --muted-2: #97b19f; }
:root[data-theme="tide"] { --bg: #08161e; --surface: #0f2230; --surface-2: #273845; --line: #3f4e59; --fg: #e0ecf0; --fg-2: #c6dde4; --muted: #88a7b0; --muted-2: #94b0b8; }
:root[data-theme="alpine"] { --bg: #0e131c; --surface: #182234; --surface-2: #2f3848; --line: #464e5d; --fg: #e3e7ef; --fg-2: #ccd4e2; --muted: #919bb0; --muted-2: #9ca5b8; }
:root[data-theme="autumn"] { --bg: #1a1108; --surface: #271a0d; --surface-2: #3d3125; --line: #52483d; --fg: #f5e7d8; --fg-2: #ecd4b8; --muted: #bd9a74; --muted-2: #c4a482; }
:root[data-theme="bloom"] { --bg: #170f14; --surface: #241620; --surface-2: #3a2d36; --line: #50454d; --fg: #f5e3e8; --fg-2: #ecccd6; --muted: #c191a0; --muted-2: #c79caa; }
:root[data-theme="jdm"] { --bg: #160a0c; --surface: #221012; --surface-2: #38282a; --line: #4e4041; --fg: #f1e1e3; --fg-2: #e6c9cc; --muted: #bb8e92; --muted-2: #c2999d; }
:root[data-theme="lambo"] { --bg: #121706; --surface: #1d260c; --surface-2: #343c24; --line: #4a513d; --fg: #ecefd9; --fg-2: #dde2ba; --muted: #a8ad77; --muted-2: #b1b585; }
:root[data-theme="ferrari"] { --bg: #1a0708; --surface: #270c0e; --surface-2: #3d2426; --line: #523d3e; --fg: #f2dfe0; --fg-2: #e8c4c6; --muted: #bd868a; --muted-2: #c49296; }
:root[data-theme="gtr"] { --bg: #0e1418; --surface: #182226; --surface-2: #2f383c; --line: #464e51; --fg: #e4e8eb; --fg-2: #cdd6da; --muted: #8e989e; --muted-2: #99a2a8; }
:root[data-theme="chalkboard"] { --bg: #0d1410; --surface: #161f1a; --surface-2: #2d3531; --line: #454c48; --fg: #e3e8e5; --fg-2: #ccd6cf; --muted: #8c9892; --muted-2: #98a29d; }
:root[data-theme="notebook"] { --bg: #eef2fb; --surface: #ffffff; --surface-2: #ffffff; --line: #ffffff; --fg: #8a8f96; --fg-2: #2a3340; --muted: #586472; --muted-2: #697480; --veil: rgba(238,242,251,0.62); }
:root[data-theme="library"] { --bg: #16110b; --surface: #221a12; --surface-2: #38312a; --line: #4e4841; --fg: #ebe4da; --fg-2: #dbcdbb; --muted: #ab9b80; --muted-2: #b3a58d; }
:root[data-density="compact"] { --fs: 12px; --ctrl: 30px; }
:root[data-animations="off"] * { transition: none !important; animation-duration: 0.001s !important; }
/* respect the OS reduced-motion preference (kills transitions; keeps the loading
   feedback animations, just slower) */
@media (prefers-reduced-motion: reduce) {
	:root:not([data-animations="off"]) * { transition-duration: 0.01ms !important; }
	.rv-spin { animation-duration: 1.3s !important; }
	.rv-pipe span { animation-duration: 2.4s !important; }
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; background: var(--bg); overflow: hidden; }
/* font-size-adjust normalizes apparent size across faces (different fonts have
   different x-heights, so some looked smaller); the value tracks Verdana's aspect
   so the default is unchanged while smaller-x-height fonts grow to match. It also
   steadies the fallback->webfont swap (less CLS). */
body { font-family: var(--font); font-size: var(--fs); color: var(--fg-2); font-size-adjust: 0.545; -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility; }
::selection { background: #2a2a2a; color: #fff; }
input::placeholder { color: var(--muted); }
@keyframes rvspin { to { transform: rotate(360deg); } }

button { cursor: pointer; font-family: inherit; color: inherit; -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
button[disabled] { cursor: default; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 3px; }
a { color: var(--accent); }

.rv-root { display: flex; flex-direction: column; height: 100vh; width: 100vw; background: var(--bg); overflow: hidden; user-select: none; -webkit-user-select: none; }

/* tab strip */
.rv-tabstrip { display: flex; align-items: flex-end; height: 36px; background: var(--bg); border-bottom: 1px solid var(--line); }
.rv-brand { display: flex; align-items: center; gap: 7px; height: 36px; padding: 0 10px 0 10px; font-size: var(--fs); font-weight: 600; color: var(--fg); flex: none; }
.rv-brand #rv-logo { display: inline-flex; align-items: center; justify-content: center; width: 19px; height: 19px; flex: none; } /* reserve space so the JS-injected logo can't shift the brand row */
.rv-brand svg { width: 19px; height: 19px; flex: none; }
.rv-conn { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); flex: none; margin-left: 2px; }
.rv-conn[data-state="ok"] { background: #27c093; }
.rv-conn[data-state="down"] { background: var(--danger); }
.rv-conn[data-state="connecting"] { background: var(--accent); }
.rv-conn[data-state="offline"] { background: #6a6a6a; box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.08); }
.rv-tabs { display: flex; align-items: flex-end; flex: 0 1 auto; overflow: hidden; min-width: 120px; } /* reserve one tab's width so the New-tab button doesn't shift when the first tab hydrates */
/* minimal active tab: no top border, just a stronger background fill */
.rv-tab { display: flex; align-items: center; gap: 7px; height: 32px; padding: 0 8px 0 12px; max-width: 200px; min-width: 120px; cursor: pointer; font-size: var(--fs); color: var(--muted); background: transparent; border-radius: var(--radius-sm) var(--radius-sm) 0 0; }
.rv-tab:hover { background: var(--surface-2); color: var(--fg-2); }
.rv-tab.active { color: var(--fg); background: var(--surface); }
.rv-tab-favicon { width: 16px; height: 16px; flex: none; background-size: contain; background-repeat: no-repeat; background-position: center; border-radius: 3px; }
.rv-tab-title { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rv-tab-close { display: flex; align-items: center; justify-content: center; width: 24px; height: 24px; border: 0; background: transparent; border-radius: var(--radius-sm); flex: none; color: var(--muted); }
.rv-tab-close:hover { background: var(--surface-2); color: var(--fg); }
.rv-newtab { display: flex; align-items: center; justify-content: center; width: 30px; height: 30px; margin: 0 4px 3px 5px; border: 0; background: transparent; border-radius: var(--radius-sm); flex: none; }
.rv-newtab svg { width: var(--icon); height: var(--icon); }
.rv-newtab:hover { background: var(--surface); }
.rv-spacer { flex: 1; }

/* nav bar */
.rv-navbar { display: flex; align-items: center; gap: 2px; height: 44px; background: var(--bg); border-bottom: 1px solid var(--line); padding: 0 8px; }
.rv-nav { display: flex; align-items: center; justify-content: center; width: var(--ctrl); height: var(--ctrl); border: 0; background: transparent; border-radius: var(--radius-sm); flex: none; color: var(--muted-2); }
.rv-nav svg { width: var(--icon); height: var(--icon); }
.rv-nav:hover { background: var(--surface); }
.rv-nav:active { background: var(--surface-2); }
.rv-nav[disabled] { opacity: 0.35; }
.rv-nav[disabled]:hover { background: transparent; }
.rv-omnibox { flex: 1; display: flex; align-items: center; height: 32px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 0 11px; gap: 9px; margin: 0 6px; cursor: text; }
.rv-omnibox > svg { width: 15px; height: 15px; flex: none; color: var(--muted); }
.rv-omnibox input { flex: 1; height: 100%; border: 0; background: transparent; outline: none; color: var(--fg); font-family: inherit; font-size: var(--fs); user-select: text; -webkit-user-select: text; }
.rv-spin { width: 14px; height: 14px; border: 1.5px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: rvspin 0.7s linear infinite; flex: none; }

/* content */
.rv-content { position: relative; flex: 1; background: var(--bg); }
/* dark (not white) background so a navigating iframe never flashes white */
.rv-frame { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; background: var(--bg); }
.rv-frame[hidden] { display: none; }

/* start screen */
.rv-start { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 26px; background: var(--bg); padding: 24px; }
.rv-clock { font-size: 58px; color: var(--fg); font-variant-numeric: tabular-nums; letter-spacing: 1px; width: 100%; text-align: center; } /* full-width box so the ticking time can't resize/re-center (CLS) */
.rv-shortcuts { display: flex; gap: 28px; }
.rv-shortcut { display: flex; flex-direction: column; align-items: center; gap: 10px; }
.rv-shortcut-btn { display: flex; align-items: center; justify-content: center; width: 66px; height: 66px; border: 1px solid var(--line); background: var(--bg); border-radius: 50%; cursor: pointer; color: var(--accent); }
.rv-shortcut-btn svg { width: 26px; height: 26px; }
.rv-shortcut-btn:hover { border-color: var(--accent-2); }
.rv-shortcut-btn:active { border-color: var(--accent); }
.rv-shortcut span { font-size: var(--fs); color: var(--fg-2); }
.rv-ad { min-height: 0; width: min(728px, 92%); display: flex; justify-content: center; }
.rv-ad ins { display: block; }

/* folder view */
.rv-folder { position: absolute; inset: 0; display: flex; flex-direction: column; background: var(--bg); }
.rv-folder-head { display: flex; align-items: center; gap: 10px; padding: 18px 24px 12px; flex: none; border-bottom: 1px solid var(--line); }
.rv-folder-head svg { width: 21px; height: 21px; flex: none; color: var(--accent); }
.rv-folder-title { font-size: 18px; font-weight: 600; color: var(--fg); letter-spacing: 0.3px; }
.rv-folder-search { margin-left: auto; height: 32px; width: clamp(160px, 30vw, 320px); border: 1px solid var(--line); background: var(--bg); color: var(--fg); border-radius: var(--radius); padding: 0 12px; font: inherit; font-size: 13px; outline: none; user-select: text; -webkit-user-select: text; }
.rv-folder-search:focus { border-color: var(--accent); }
.rv-folder-empty { flex: 1; display: flex; align-items: center; justify-content: center; color: var(--muted); font-size: var(--fs); text-align: center; padding: 20px; }
/* grid-auto-rows:max-content keeps each row at its cards' content height — without
   it, overflow:hidden cards get an automatic min-size of 0 and the rows collapse
   to slivers (whole grid scrolls / shrinks them away). */
.rv-grid { flex: 1; overflow: auto; -webkit-overflow-scrolling: touch; display: grid; grid-template-columns: repeat(auto-fill, minmax(168px, 1fr)); grid-auto-rows: max-content; gap: 16px; padding: 18px 24px 26px; align-content: start; }
.rv-card { display: flex; flex-direction: column; cursor: pointer; border: 1px solid var(--line); background: var(--surface); border-radius: var(--radius); overflow: hidden; transition: transform 0.12s ease, border-color 0.12s ease; }
.rv-card:hover { border-color: var(--accent-2); transform: translateY(-2px); }
.rv-card:active { transform: translateY(0); }
/* square image area, image shown whole (not cropped) — used by Books + Worksheets */
.rv-card-imgwrap { position: relative; aspect-ratio: 1 / 1; width: 100%; flex: none; background: linear-gradient(135deg, #1a1813, #0b0b0b); overflow: hidden; }
.rv-card-img { position: absolute; inset: 0; width: 100%; height: 100%; display: block; object-fit: contain; padding: 6%; }
.rv-card-fallback { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; padding: 8px; text-align: center; font-size: 12px; line-height: 1.3; color: var(--muted-2); }
.rv-card-title { padding: 10px 12px; font-size: var(--fs); color: var(--fg-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* error overlay */
.rv-error { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; background: var(--bg); padding: 24px; }
.rv-err-card { max-width: 440px; text-align: center; display: flex; flex-direction: column; align-items: center; gap: 12px; }
.rv-err-icon { width: 56px; height: 56px; display: flex; align-items: center; justify-content: center; border-radius: 50%; border: 1px solid var(--line); background: var(--surface); }
.rv-err-title { font-size: 19px; color: var(--fg); font-weight: 600; }
.rv-err-msg { color: var(--muted-2); line-height: 1.5; }
.rv-err-actions { display: flex; gap: 10px; margin-top: 6px; flex-wrap: wrap; justify-content: center; }

/* buttons */
.rv-btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 34px; padding: 0 14px; border: 1px solid var(--line); background: var(--surface); color: var(--fg); border-radius: var(--radius); font-size: var(--fs); }
.rv-btn:hover { border-color: var(--accent-2); }
.rv-btn-primary { background: var(--accent); color: #1a1500; border-color: var(--accent); font-weight: 600; }
.rv-btn-primary:hover { background: var(--accent-2); }
.rv-btn-danger { color: var(--danger); border-color: #3a1f1f; }

/* scrollbars */
*::-webkit-scrollbar { width: 11px; height: 11px; }
*::-webkit-scrollbar-thumb { background: var(--line); border-radius: var(--radius-sm); border: 3px solid var(--bg); }
*::-webkit-scrollbar-thumb:hover { background: var(--accent-2); }

/* toolbar star */
.rv-star.active { color: var(--accent); }
.rv-star.active svg path { fill: var(--accent); }

/* bookmarks bar */
.rv-bookmarksbar { display: flex; align-items: center; gap: 3px; height: 34px; padding: 0 8px; background: var(--bg); border-bottom: 1px solid var(--line); overflow-x: auto; flex: none; scrollbar-width: none; }
.rv-bookmarksbar::-webkit-scrollbar { height: 0; }
.rv-bm-item { height: 25px; max-width: 180px; padding: 0 9px; border: 0; background: transparent; color: var(--fg-2); border-radius: var(--radius-sm); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: none; }
.rv-bm-item:hover { background: var(--surface); color: var(--fg); }
.rv-bm-empty { color: var(--muted); font-size: 12px; padding: 0 8px; }

/* start-screen dashboard — anchored to the top so any post-load content settle
   extends downward (no re-centering layout shift) */
.rv-start { overflow: auto; justify-content: flex-start; padding: clamp(28px, 9vh, 90px) 24px 36px; }
.rv-start-inner { display: flex; flex-direction: column; align-items: center; gap: 20px; width: 100%; max-width: 720px; margin: 0 auto; }
.rv-greeting { font-size: 15px; color: var(--muted-2); min-height: 19px; }
.rv-clock { font-size: clamp(40px, 7vw, 56px); margin-bottom: -6px; }
.rv-date { font-size: 14px; color: var(--muted); margin-top: -6px; min-height: 18px; }
.rv-startsearch { display: flex; align-items: center; gap: 9px; width: min(560px, 92%); height: 44px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-pill); padding: 0 17px; }
.rv-startsearch svg { width: 16px; height: 16px; color: var(--muted); flex: none; }
.rv-startsearch input { flex: 1; height: 100%; border: 0; background: transparent; outline: none; color: var(--fg); font: inherit; font-size: 14px; user-select: text; -webkit-user-select: text; }
.rv-startsearch:focus-within { border-color: var(--accent); }
.rv-shortcuts { flex-wrap: wrap; justify-content: center; gap: 20px 26px; min-height: 92px; align-content: center; }
.rv-recents { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; max-width: 680px; }
.rv-recent { display: inline-flex; align-items: center; height: 30px; max-width: 220px; border: 1px solid var(--line); background: var(--surface); border-radius: 15px; overflow: hidden; }
.rv-recent:hover { border-color: var(--accent-2); }
.rv-recent-go { max-width: 180px; height: 100%; padding: 0 6px 0 12px; border: 0; background: transparent; color: var(--fg-2); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rv-recent:hover .rv-recent-go { color: var(--fg); }
.rv-recent-x { display: flex; align-items: center; justify-content: center; width: 22px; height: 100%; border: 0; background: transparent; color: var(--muted); flex: none; }
.rv-recent-x:hover { color: var(--danger); }

/* folder category chips + clear */
.rv-folder-clear { height: 32px; padding: 0 12px; border: 1px solid #3a1f1f; background: var(--bg); color: var(--danger); border-radius: var(--radius); font-size: 12px; flex: none; }
.rv-folder-clear:hover { background: var(--surface); }
.rv-folder-cats { display: flex; gap: 8px; flex-wrap: wrap; padding: 11px 24px; border-bottom: 1px solid var(--line); flex: none; }
.rv-chip { height: 28px; padding: 0 13px; border: 1px solid var(--line); background: var(--bg); color: var(--muted-2); border-radius: 14px; font-size: 12px; white-space: nowrap; }
.rv-chip:hover { border-color: var(--accent-2); color: var(--fg-2); }
.rv-chip.active { background: var(--accent); color: #1a1500; border-color: var(--accent); font-weight: 600; }

/* tile fallback for missing icons */
.rv-tile, .rv-tile-sm { width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; color: #fff; font-weight: 700; }
.rv-tile { font-size: 18px; }
.rv-tile-sm { font-size: 11px; }

/* card variants */
.rv-grid[data-style="app"] { grid-template-columns: repeat(auto-fill, minmax(116px, 1fr)); }
.rv-grid[data-style="tool"] { grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); }
.rv-grid[data-style="link"] { grid-template-columns: 1fr; gap: 8px; }
.rv-card-app { align-items: center; text-align: center; padding: 16px 8px 13px; gap: 10px; }
.rv-card-app .rv-card-title { padding: 0; white-space: normal; max-width: 100%; }
.rv-app-icon { width: 46px; height: 46px; display: flex; align-items: center; justify-content: center; border-radius: var(--radius-lg); overflow: hidden; background: var(--surface-2); flex: none; }
.rv-app-icon img { width: 38px; height: 38px; object-fit: contain; }
.rv-card-tool { padding: 16px; gap: 9px; }
.rv-tool-icon { width: 32px; height: 32px; color: var(--accent); }
.rv-tool-icon svg { width: 100%; height: 100%; }
.rv-card-tool .rv-card-title { padding: 0; font-weight: 600; color: var(--fg); white-space: normal; }
.rv-card-blurb { font-size: 12px; color: var(--muted); white-space: normal; line-height: 1.35; }
.rv-card-link { flex-direction: row; align-items: center; gap: 12px; padding: 9px 12px; }
.rv-card-link:hover { transform: none; }
.rv-link-fav { width: 26px; height: 26px; flex: none; border-radius: var(--radius-sm); overflow: hidden; display: flex; align-items: center; justify-content: center; background: var(--surface-2); }
.rv-link-fav img { width: 20px; height: 20px; }
.rv-link-text { flex: 1; min-width: 0; }
.rv-link-title { color: var(--fg); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rv-link-url { color: var(--muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rv-link-remove { width: 26px; height: 26px; border: 0; background: transparent; color: var(--muted); border-radius: var(--radius-sm); flex: none; display: flex; align-items: center; justify-content: center; }
.rv-link-remove:hover { background: var(--surface-2); color: var(--fg); }

/* command palette */
.rv-palette { position: fixed; inset: 0; z-index: 1000; background: rgba(0, 0, 0, 0.5); display: flex; align-items: flex-start; justify-content: center; padding-top: 12vh; }
.rv-palette-box { width: min(620px, 94%); background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5); overflow: hidden; display: flex; flex-direction: column; max-height: 70vh; }
.rv-palette-input { height: 50px; border: 0; border-bottom: 1px solid var(--line); background: transparent; color: var(--fg); font: inherit; font-size: 16px; padding: 0 18px; outline: none; user-select: text; -webkit-user-select: text; }
.rv-palette-list { overflow: auto; }
.rv-palette-item { display: flex; align-items: center; gap: 10px; padding: 10px 16px; cursor: pointer; }
.rv-palette-item.sel { background: var(--surface-2); }
.rv-palette-title { color: var(--fg); flex: none; max-width: 60%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rv-palette-sub { color: var(--muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; }
.rv-palette-kind { margin-left: auto; color: var(--muted-2); font-size: 11px; border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 1px 6px; flex: none; }

/* find-in-page bar */
.rv-findbar { position: fixed; top: 8px; right: 16px; z-index: 1000; display: flex; align-items: center; gap: 4px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 5px 6px; box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4); }
.rv-findbar input { height: 28px; width: 200px; border: 0; background: transparent; color: var(--fg); outline: none; font: inherit; padding: 0 6px; user-select: text; -webkit-user-select: text; }
.rv-find-btn { width: 28px; height: 28px; border: 0; background: transparent; color: var(--muted-2); border-radius: var(--radius-sm); }
.rv-find-btn:hover { background: var(--surface-2); color: var(--fg); }

/* favorite ★ on book + app cards */
.rv-card { position: relative; }
.rv-fav-star { position: absolute; top: 6px; right: 6px; width: 26px; height: 26px; display: flex; align-items: center; justify-content: center; border: 0; border-radius: var(--radius); background: rgba(0, 0, 0, 0.45); color: #fff; opacity: 0.55; transition: opacity 0.12s ease, color 0.12s ease, background 0.12s ease; z-index: 2; }
.rv-fav-star svg { width: 16px; height: 16px; }
.rv-card:hover .rv-fav-star, .rv-fav-star.on { opacity: 1; }
.rv-fav-star:hover { background: rgba(0, 0, 0, 0.7); }
.rv-fav-star.on { color: var(--accent); }
.rv-fav-star.on svg path { fill: var(--accent); }
.rv-card-app .rv-fav-star { top: 5px; right: 5px; background: var(--surface-2); }
.rv-card-app .rv-fav-star:hover { background: var(--line); }

/* favorites: a small book cover thumb inside a link row */
.rv-link-cover { width: 42px; height: 30px; border-radius: var(--radius-sm); overflow: hidden; position: relative; background: linear-gradient(135deg, #1a1813, #0b0b0b); flex: none; }
.rv-link-cover .rv-card-img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; padding: 0; }
.rv-link-cover .rv-card-fallback { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: 9px; color: var(--muted-2); padding: 2px; text-align: center; }

/* pagination */
.rv-pager { display: flex; align-items: center; justify-content: center; gap: 14px; padding: 10px 24px 14px; flex: none; border-top: 1px solid var(--line); }
.rv-pager-btn { height: 32px; padding: 0 14px; border: 1px solid var(--line); background: var(--surface); color: var(--fg); border-radius: var(--radius); font-size: 13px; }
.rv-pager-btn:hover:not([disabled]) { border-color: var(--accent-2); }
.rv-pager-btn[disabled] { opacity: 0.4; }
.rv-pager-ind { color: var(--muted); font-size: 12px; }

/* loading overlay + pipeline bar (covers the iframe white-flash) */
.rv-loader { position: absolute; inset: 0; z-index: 50; display: flex; align-items: center; justify-content: center; background: var(--bg); opacity: 0; pointer-events: none; transition: opacity 0.25s ease; }
.rv-loader[data-on="1"] { opacity: 1; pointer-events: auto; transition: opacity 0.25s ease 0.14s; } /* delayed fade-in → fast pages never flash it */
.rv-loader-card { display: flex; flex-direction: column; align-items: center; gap: 16px; }
.rv-loader-row { display: flex; align-items: center; gap: 14px; }
.rv-loader-label { color: var(--muted-2); font-size: 13px; max-width: 280px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rv-loader-skip { height: 28px; padding: 0 13px; border: 1px solid var(--line); background: var(--surface); color: var(--fg-2); border-radius: var(--radius); font-size: 12px; }
.rv-loader-skip:hover { border-color: var(--accent-2); color: var(--fg); }
.rv-pipe { width: 260px; max-width: 70vw; height: 16px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--line); overflow: hidden; position: relative; box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.4); }
.rv-pipe span { position: absolute; top: 0; bottom: 0; left: -28px; right: -28px; background-image: radial-gradient(circle 4px at 14px 50%, var(--accent) 0 4px, transparent 5px); background-size: 28px 100%; background-repeat: repeat-x; animation: rvpipe 0.75s linear infinite; will-change: transform; }
@keyframes rvpipe { from { transform: translateX(0); } to { transform: translateX(28px); } }
@media (prefers-reduced-motion: reduce) { .rv-pipe span { animation-duration: 2.4s; } }

/* collapsible top chrome + pull tab */
.rv-root.collapsed .rv-tabstrip,
.rv-root.collapsed .rv-navbar,
.rv-root.collapsed .rv-bookmarksbar { display: none; }
.rv-pulltab { position: absolute; top: 0; left: 50%; transform: translateX(-50%); z-index: 60; display: flex; align-items: center; justify-content: center; width: 56px; height: 15px; padding: 0; border: 1px solid var(--line); border-top: 0; border-radius: 0 0 var(--radius) var(--radius); background: var(--surface); color: var(--muted-2); opacity: 0.75; transition: opacity 0.15s ease, height 0.15s ease, color 0.15s ease, background 0.15s ease; }
.rv-pulltab svg { width: 15px; height: 15px; }
.rv-pulltab:hover { opacity: 1; height: 20px; color: var(--fg); background: var(--surface-2); }

/* optional hiding of the top-left branding + status dot (Appearance settings) */
[data-brand="off"] .rv-brand #rv-logo,
[data-brand="off"] .rv-brand-name { display: none; }
[data-status="off"] .rv-conn { display: none; }
[data-brand="off"] .rv-brand { padding-left: 8px; }
[data-brand="off"][data-status="off"] .rv-brand { display: none; }

/* font-preview dropdown: each option renders in its own face */
.rv-font-select option { font-size: 15px; padding: 3px 4px; }

/* off-screen image cards skip layout/paint (paginated grids stay light) */
.rv-grid[data-style="image"] .rv-card { content-visibility: auto; contain-intrinsic-size: auto 226px; }

/* tab context menu (right-click / long-press) */
.rv-ctxmenu { position: fixed; z-index: 200; min-width: 170px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 5px; box-shadow: 0 12px 36px rgba(0, 0, 0, 0.5); display: flex; flex-direction: column; }
.rv-ctxitem { display: flex; align-items: center; height: 30px; padding: 0 10px; border: 0; background: transparent; color: var(--fg-2); border-radius: var(--radius-sm); font-size: 13px; text-align: left; }
.rv-ctxitem:hover:not([disabled]) { background: var(--surface-2); color: var(--fg); }
.rv-ctxitem[disabled] { opacity: 0.4; }
.rv-ctxsep { height: 1px; background: var(--line); margin: 4px 6px; }

/* pinned tabs */
.rv-tab.pinned { min-width: auto; max-width: 132px; padding-right: 12px; gap: 5px; }
.rv-tab-pin { display: flex; align-items: center; color: var(--accent); flex: none; }

/* bigger hit targets on touchscreens (Chromebooks) */
@media (pointer: coarse) {
	.rv-nav, .rv-newtab { width: 40px; height: 40px; }
	.rv-tab-close { width: 26px; height: 26px; }
	.rv-shortcut-btn { width: 72px; height: 72px; }
}

/* Reserve the start-screen shortcut grid's wrapped height per width band so the
   grid — and the ad below it — don't shift down when the dashboard hydrates after
   first paint. A container pinned at min-height stays put when its content fits. */
@media (max-width: 399px) { .rv-shortcuts { min-height: 318px; } } /* 3 rows (incl. 360px) */
@media (min-width: 400px) and (max-width: 665px) { .rv-shortcuts { min-height: 206px; } } /* 2 rows */

/* address-bar / search autocomplete dropdown */
.rv-suggest { position: fixed; z-index: 300; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 5px; box-shadow: 0 14px 40px rgba(0, 0, 0, 0.5); max-height: 52vh; overflow-y: auto; }
.rv-suggest-item { display: flex; align-items: center; gap: 10px; height: 34px; padding: 0 10px; border-radius: var(--radius); cursor: pointer; color: var(--fg-2); font-size: 13px; }
.rv-suggest-item.sel { background: var(--surface-2); color: var(--fg); }
.rv-suggest-ic { display: flex; flex: none; width: 16px; height: 16px; color: var(--muted-2); }
.rv-suggest-ic svg { width: 16px; height: 16px; }
.rv-suggest-label { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rv-suggest-label b { color: var(--fg); font-weight: 600; }
.rv-suggest-sub { flex: none; color: var(--muted-2); font-size: 11px; margin-left: 8px; max-width: 46%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* boot-failure recovery screen */
.rv-fatal { position: fixed; inset: 0; z-index: 9999; display: flex; align-items: center; justify-content: center; background: var(--bg); padding: 24px; }
.rv-fatal-card { display: flex; flex-direction: column; align-items: center; gap: 13px; text-align: center; max-width: 390px; }
.rv-fatal-card svg { width: 48px; height: 48px; color: var(--accent); }
.rv-fatal-card h1 { color: var(--fg); font-size: 20px; }
.rv-fatal-card p { color: var(--muted-2); font-size: 14px; line-height: 1.5; }
.rv-fatal-actions { display: flex; gap: 10px; margin-top: 4px; flex-wrap: wrap; justify-content: center; }

/* --- auto-update toast (app/update.js) ----------------------------------- */
.rv-update { position: fixed; left: 50%; bottom: 18px; transform: translate(-50%, 14px); z-index: 10000; display: flex; align-items: center; gap: 10px; max-width: calc(100vw - 28px); padding: 9px 9px 9px 15px; background: var(--surface); color: var(--fg); border: 1px solid var(--line); border-radius: var(--radius-lg); box-shadow: 0 10px 30px rgba(0, 0, 0, 0.45); font-size: var(--fs); opacity: 0; pointer-events: none; transition: opacity 0.22s ease, transform 0.22s ease; }
.rv-update.rv-update-in { opacity: 1; transform: translate(-50%, 0); pointer-events: auto; }
.rv-update-msg { color: var(--fg); }
.rv-update-reload { height: 30px; padding: 0 14px; border: 1px solid var(--accent); border-radius: var(--radius); background: var(--accent); color: #1a1500; font: inherit; font-weight: 600; cursor: pointer; flex: none; }
.rv-update-reload:hover { filter: brightness(1.06); }
.rv-update-x { display: flex; align-items: center; justify-content: center; width: 28px; height: 28px; border: 0; border-radius: var(--radius); background: transparent; color: var(--muted); cursor: pointer; flex: none; font-size: 12px; }
.rv-update-x:hover { color: var(--fg); background: var(--line); }

/* --- wallpaper (app/wallpaper.js) ---------------------------------------- */
/* A single fixed layer behind .rv-root. The image paints on ::before (blurred in
   isolation, over-sized so the blur never reveals a hard edge); the dim scrim is
   ::after. html keeps an opaque --bg so a contained/tiled image never flashes the
   white canvas. Surfaces are turned transparent below so the layer shows through. */
.rv-wallpaper { position: fixed; inset: 0; z-index: 0; pointer-events: none; overflow: hidden; }
/* Fully hidden unless a wallpaper is active. Without this, after switching to None
   or resetting, the layer's leftover dim scrim would paint over the shell (the
   chrome loses its z-index lift), tinting the top bar. */
:root:not([data-wallpaper="on"]) .rv-wallpaper { display: none; }
.rv-wallpaper::before {
	content: ""; position: absolute;
	inset: calc(-2 * var(--wp-blur, 0px) - 8px);
	background-color: var(--wp-bg, transparent);
	background-image: var(--wp-image, none);
	background-size: var(--wp-size, cover);
	background-position: center;
	background-repeat: var(--wp-repeat, no-repeat);
	filter: blur(var(--wp-blur, 0px));
}
.rv-wallpaper::after { content: ""; position: absolute; inset: 0; background: rgba(0, 0, 0, var(--wp-dim, 0)); }

/* Reveal the layer: lift the shell into its own stacking context above the layer
   and clear the backgrounds along the start-screen path. Chrome + proxied frames
   stay opaque, so only the new-tab screen shows the wallpaper in "start" scope. */
:root[data-wallpaper="on"] .rv-root { position: relative; z-index: 1; background: transparent; }
:root[data-wallpaper="on"] .rv-content,
:root[data-wallpaper="on"] .rv-start { background: transparent; }
:root[data-wallpaper="on"] .rv-greeting,
:root[data-wallpaper="on"] .rv-clock,
:root[data-wallpaper="on"] .rv-date,
:root[data-wallpaper="on"] .rv-shortcut span { text-shadow: 0 1px 16px rgba(0, 0, 0, 0.55); }
/* light theme over a (usually dark) wallpaper: the text is dark, so flip the halo
   to a light glow instead of a dark one */
:root[data-mode="light"][data-wallpaper="on"] .rv-greeting,
:root[data-mode="light"][data-wallpaper="on"] .rv-clock,
:root[data-mode="light"][data-wallpaper="on"] .rv-date,
:root[data-mode="light"][data-wallpaper="on"] .rv-shortcut span { text-shadow: 0 1px 16px rgba(255, 255, 255, 0.7); }
:root[data-wallpaper="on"] .rv-startsearch,
:root[data-wallpaper="on"] .rv-shortcut-btn,
:root[data-wallpaper="on"] .rv-recent { background: var(--veil); -webkit-backdrop-filter: blur(7px); backdrop-filter: blur(7px); }

/* "app" scope: the wallpaper sits behind the whole shell, so the chrome + folder
   views go translucent too. Proxied page iframes (.rv-frame) deliberately stay
   opaque — a website must never bleed the wallpaper through its own page. */
:root[data-wallpaper="on"][data-wp-scope="app"] .rv-tabstrip,
:root[data-wallpaper="on"][data-wp-scope="app"] .rv-navbar,
:root[data-wallpaper="on"][data-wp-scope="app"] .rv-bookmarksbar,
:root[data-wallpaper="on"][data-wp-scope="app"] .rv-folder-head,
:root[data-wallpaper="on"][data-wp-scope="app"] .rv-folder-cats,
:root[data-wallpaper="on"][data-wp-scope="app"] .rv-pager { background: var(--veil); -webkit-backdrop-filter: blur(7px); backdrop-filter: blur(7px); }
:root[data-wallpaper="on"][data-wp-scope="app"] .rv-folder { background: transparent; }

[hidden] { display: none !important; }
