:root {
    color-scheme: dark;
    --bg: #090b0f;
    --tabbar: #0d1015;
    --chrome: #151922;
    --surface: #1a1f29;
    --surface-2: #212733;
    --line: rgba(255,255,255,.07);
    --line-strong: rgba(255,255,255,.13);
    --text: #eef1f6;
    --text-2: #b4bccb;
    --muted: #7f8898;
    --accent: #6fd6c8;
    --field-focus: #0b0e13;
    --glass: rgba(26,31,41,.8);
    --glow: #10151d;
    --pop: #1d222d;
    --accent-ink: #06211e;
    --accent-soft: color-mix(in srgb, var(--accent) 16%, transparent);
    --hover: rgba(255,255,255,.065);
    --press: rgba(255,255,255,.1);
    --ease: cubic-bezier(.22,.8,.24,1);
    --spring: cubic-bezier(.34,1.45,.5,1);
    --ico-x: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.2' stroke-linecap='round'%3E%3Cpath d='M18 6 6 18M6 6l12 12'/%3E%3C/svg%3E");
    --ico-search: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3Cpath d='m21 21-4.3-4.3'/%3E%3C/svg%3E");
}
* { box-sizing: border-box; }
html, body { width: 100%; height: 100%; margin: 0; overflow: hidden; background: var(--bg); color: var(--text); font-family: Inter, "SF Pro Text", "Segoe UI Variable", "Segoe UI", system-ui, -apple-system, sans-serif; -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility; }
button, input, select { font: inherit; }
button { color: inherit; -webkit-tap-highlight-color: transparent; }
button:focus-visible, input:focus-visible, select:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
::selection { background: rgba(111,214,200,.3); }
#app { width: 100%; height: 100%; display: flex; flex-direction: column; }

/* Loading */
#tide-loading { position: fixed; inset: 0; z-index: 10000; display: grid; place-items: center; background: radial-gradient(ellipse at 50% 36%, #17222b 0, #0d1218 46%, #07090c 100%); transition: opacity .45s var(--ease), visibility .45s; }
#tide-loading.hidden { opacity: 0; visibility: hidden; pointer-events: none; }
.loading-card { width: 220px; text-align: center; animation: rise .6s var(--ease) both; }
.loading-logo, .tide-logo { display: block; width: 72px; height: 72px; margin: 0 auto 18px; border-radius: 22px; object-fit: cover; box-shadow: 0 18px 50px rgba(0,0,0,.5), inset 0 1px 0 rgba(255,255,255,.25); }
.loading-logo { display: grid; place-items: center; background: linear-gradient(145deg,#9be9dd,#4aa9ba); color: #06211e; font-size: 36px; font-weight: 760; animation: float 3.2s ease-in-out infinite; }
@keyframes float { 50% { transform: translateY(-5px); } }
.loading-card h1 { margin: 0; font-size: 22px; font-weight: 650; letter-spacing: -.03em; }
.loading-bar { height: 3px; margin: 18px auto 0; overflow: hidden; border-radius: 3px; background: rgba(255,255,255,.08); }
.loading-bar span { display: block; width: 40%; height: 100%; border-radius: 3px; background: var(--accent); animation: slide 1.2s var(--ease) infinite; }
@keyframes slide { from { transform: translateX(-110%); } to { transform: translateX(260%); } }
.loading-card p { margin: 12px 0 0; color: var(--muted); font-size: 12.5px; }

/* Tab strip */
#tabs-bar { height: 46px; flex: 0 0 46px; display: flex; align-items: flex-end; gap: 6px; padding: 0 10px; background: var(--tabbar); }
#tabs { min-width: 0; height: 100%; flex: 1; display: flex; align-items: flex-end; gap: 2px; padding-top: 8px; overflow-x: auto; overflow-y: hidden; scrollbar-width: none; }
#tabs::-webkit-scrollbar { display: none; }
.tab { position: relative; height: 100%; min-width: 112px; max-width: 232px; flex: 1 1 200px; display: flex; align-items: center; gap: 9px; padding: 0 8px 0 12px; border: 0; border-radius: 11px 11px 0 0; background: transparent; color: var(--muted); cursor: pointer; animation: tab-in .32s var(--ease) both; transition: color .2s var(--ease), background .25s var(--ease); }
@keyframes tab-in { from { opacity: 0; transform: translateY(6px) scale(.97); } to { opacity: 1; transform: none; } }
.tab:hover { background: var(--hover); color: var(--text-2); }
.tab.active { background: var(--chrome); color: var(--text); }
.tab-icon { width: 16px; height: 16px; flex: 0 0 16px; object-fit: contain; border-radius: 4px; }
.tab-title { min-width: 0; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-align: left; font-size: 12.5px; font-weight: 500; letter-spacing: -.005em; }
.tab-close { position: relative; width: 22px; height: 22px; flex: 0 0 22px; display: block; border-radius: 7px; font-size: 0; line-height: 0; color: var(--muted); opacity: 0; transition: opacity .18s, color .16s, background .16s, transform .2s var(--ease); }
.tab-close::before { content: ""; position: absolute; inset: 0; margin: auto; width: 12px; height: 12px; background: currentColor; -webkit-mask: var(--ico-x) 50% 50% / 12px 12px no-repeat; mask: var(--ico-x) 50% 50% / 12px 12px no-repeat; }
.tab:hover .tab-close, .tab.active .tab-close, .tab:focus-visible .tab-close { opacity: 1; }
.tab-close:hover { background: var(--press); color: var(--text); }
.tab-close:active { transform: scale(.88); }
#new-tab { width: 32px; height: 32px; display: grid; place-items: center; flex: 0 0 32px; margin: 0 0 7px; border: 0; border-radius: 10px; background: transparent; color: var(--text-2); cursor: pointer; transition: background .2s var(--ease), color .2s, transform .25s var(--spring); }
#new-tab:hover { background: var(--hover); color: var(--text); }
#new-tab:active { transform: scale(.88); }

/* Toolbar */
#toolbar { min-height: 54px; flex: 0 0 54px; display: flex; align-items: center; gap: 8px; padding: 8px 12px; background: var(--chrome); border-bottom: 1px solid var(--line); position: relative; z-index: 3; }
.nav-buttons { display: flex; gap: 2px; }
.nav-buttons button, #settings, #account-button { width: 34px; height: 34px; display: grid; place-items: center; flex: 0 0 auto; border: 0; border-radius: 10px; background: transparent; color: var(--text-2); cursor: pointer; transition: background .18s var(--ease), color .18s, transform .22s var(--spring), opacity .2s; }
.nav-buttons button:hover:not(:disabled), #settings:hover, #account-button:hover { background: var(--hover); color: var(--text); }
.nav-buttons button:active:not(:disabled), #settings:active, #account-button:active { background: var(--press); transform: scale(.9); }
.nav-buttons button:disabled { opacity: .3; cursor: default; }
#reload:active:not(:disabled) svg { transform: rotate(-90deg); }
svg { display: block; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.nav-buttons svg, #settings svg, #account-button svg { width: 18px; height: 18px; transition: transform .4s var(--ease); }
#new-tab svg { width: 16px; height: 16px; transition: transform .35s var(--ease); }
#new-tab:hover svg { transform: rotate(90deg); }
#address-form { position: relative; min-width: 0; flex: 1; height: 38px; display: flex; align-items: center; border: 1px solid transparent; border-radius: 999px; background: var(--bg); transition: background .2s, border-color .2s, box-shadow .25s var(--ease); }
#address-form:hover { border-color: var(--line-strong); }
#address-form:focus-within { border-color: color-mix(in srgb, var(--accent) 60%, transparent); background: var(--field-focus); box-shadow: 0 0 0 4px var(--accent-soft); }
.address-icon { display: grid; place-items: center; margin-left: 14px; color: var(--muted); transition: color .2s; }
#address-form:focus-within .address-icon { color: var(--accent); }
.address-icon svg { width: 15px; height: 15px; }
#address { width: 100%; height: 100%; padding: 0 6px 0 10px; border: 0; outline: 0; background: transparent; color: var(--text); font-size: 13.5px; letter-spacing: -.005em; text-overflow: ellipsis; }
#address::placeholder { color: var(--muted); }
#address:focus-visible { outline: none; }

/* Viewport */
#browser { position: relative; flex: 1; min-height: 0; overflow: hidden; background: var(--bg); }
#frame-container, #new-tab-container { position: absolute; inset: 0; overflow: hidden; }
#frame-container { z-index: 1; } #new-tab-container { z-index: 2; overflow: auto; }
.tide-frame { width: 100%; height: 100%; display: block; border: 0; background: #fff; animation: fade .3s ease both; }

/* New tab page */
.tide-new-tab { width: 100%; min-height: 100%; display: grid; grid-template-columns: minmax(0,1fr); place-items: center; padding: clamp(28px,8vh,88px) 22px; background: radial-gradient(ellipse 70% 55% at 50% 28%, var(--accent-soft), transparent 70%), radial-gradient(ellipse at 50% 100%, var(--glow) 0, var(--bg) 70%); }
.tide-new-tab-content { width: min(640px,100%); text-align: center; animation: rise .55s var(--ease) both; }
@keyframes rise { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }
.tide-logo { width: 64px; height: 64px; margin-bottom: 18px; border-radius: 20px; }
.tide-new-tab h1 { margin: 0 0 28px; font-size: clamp(30px,5vw,40px); letter-spacing: -.045em; font-weight: 700; }
.tide-search-form { position: relative; width: 100%; display: flex; align-items: center; padding: 6px; border: 1px solid var(--line-strong); border-radius: 999px; background: var(--glass); backdrop-filter: blur(10px); box-shadow: 0 18px 50px rgba(0,0,0,.35); transition: border-color .25s, box-shadow .3s var(--ease), transform .3s var(--ease); }
.tide-search-form::before { content: ""; width: 18px; height: 18px; flex: 0 0 18px; margin: 0 2px 0 16px; background: var(--muted); -webkit-mask: var(--ico-search) center / contain no-repeat; mask: var(--ico-search) center / contain no-repeat; transition: background .2s; }
.tide-search-form:focus-within { border-color: color-mix(in srgb, var(--accent) 60%, transparent); box-shadow: 0 0 0 5px var(--accent-soft), 0 18px 50px rgba(0,0,0,.4); transform: translateY(-1px); }
.tide-search-form:focus-within::before { background: var(--accent); }
.tide-search { min-width: 0; flex: 1; height: 46px; padding: 0 12px; border: 0; outline: 0; background: transparent; color: var(--text); font-size: 15px; letter-spacing: -.01em; }
.tide-search::placeholder { color: var(--muted); }
.tide-search:focus-visible { outline: none; }
.tide-search-form button { height: 44px; min-width: 88px; padding: 0 22px; border: 0; border-radius: 999px; background: var(--accent); color: var(--accent-ink); font-size: 13.5px; font-weight: 650; cursor: pointer; transition: filter .2s, transform .22s var(--spring); }
.tide-search-form button:hover { filter: brightness(1.08); } .tide-search-form button:active { transform: scale(.95); }
.tide-section-title { margin: 38px 0 12px 4px; text-align: left; color: var(--muted); font-size: 12.5px; font-weight: 600; letter-spacing: 0; }
.tide-bookmarks { display: grid; grid-template-columns: repeat(auto-fill,minmax(148px,1fr)); gap: 10px; }
.tide-bookmark { width: 100%; min-height: 56px; display: flex; align-items: center; gap: 9px; padding: 0 10px 0 8px; border: 1px solid var(--line); border-radius: 16px; background: var(--surface); color: var(--text-2); cursor: pointer; font-size: 13px; font-weight: 500; text-align: left; transition: transform .28s var(--ease), border-color .2s, background .2s, color .2s, box-shadow .28s var(--ease); }
.tide-bookmark-label { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tide-bookmark-icon { width: 34px; height: 34px; flex: 0 0 34px; display: grid; place-items: center; border-radius: 11px; background: hsl(var(--h,170) 55% 55% / .16); color: hsl(var(--h,170) 85% 76%); font-size: 14px; font-weight: 700; }
.tide-bookmark:hover { transform: translateY(-2px); border-color: var(--line-strong); background: var(--surface-2); color: var(--text); box-shadow: 0 10px 28px rgba(0,0,0,.35); }
.tide-bookmark:active { transform: scale(.97); }
.tide-bookmark-item { position: relative; min-width: 0; animation: tile-in .5s var(--ease) both; animation-delay: calc(var(--i, 0) * 38ms + 60ms); }
@keyframes tile-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* Settings */
/* tide://settings and tide://account are pages inside the browser area. */
/* Full-page layout: a sidebar of Tide's pages, and the page filling the rest. */
#internal-container { position: absolute; inset: 0; z-index: 2; display: flex; overflow: hidden; background: var(--bg); }
.tide-nav { flex: 0 0 232px; display: flex; flex-direction: column; gap: 2px; padding: 22px 12px; border-right: 1px solid var(--line); background: var(--chrome); overflow-y: auto; }
.tide-nav-brand { display: flex; align-items: center; gap: 10px; margin: 0 8px 18px; font-size: 17px; font-weight: 700; letter-spacing: -.02em; }
.tide-nav-logo { width: 28px; height: 28px; display: grid; place-items: center; border-radius: 8px; background: var(--accent); color: var(--accent-ink); font-size: 15px; font-weight: 800; }
.tide-nav a { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 10px; color: var(--text-2); font-size: 14px; font-weight: 550; text-decoration: none; white-space: nowrap; transition: background .16s, color .16s; }
.tide-nav a:hover { background: var(--hover); color: var(--text); }
.tide-nav a.active { background: var(--accent-soft); color: var(--accent); }
.tide-nav svg { width: 18px; height: 18px; flex: 0 0 18px; }
.tide-pages { flex: 1; min-width: 0; overflow-y: auto; background: radial-gradient(ellipse 60% 30% at 50% 0, var(--accent-soft), transparent 70%), var(--bg); }
#internal-container[hidden] { display: none; }
.tide-page { width: min(760px, 100%); margin: 0 auto; padding: 40px 32px 80px; }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.tide-page[hidden] { display: none; }
.settings-card { width: min(420px,100%); max-height: calc(100dvh - 36px); overflow: auto; padding: 24px; border: 1px solid var(--line-strong); border-radius: 22px; background: var(--chrome); box-shadow: 0 40px 100px rgba(0,0,0,.6); scrollbar-width: thin; }
/* The page is the content itself, not a box on the page. */
.tide-page .settings-card { width: 100%; max-height: none; overflow: visible; padding: 0; border: 0; border-radius: 0; background: none; box-shadow: none; animation: fade .25s ease both; }
.tide-page .settings-header { margin-bottom: 4px; }
.tide-page .settings-header h2 { font-size: 30px; font-weight: 700; letter-spacing: -.035em; }
.tide-page .settings-card > .settings-note:first-of-type { font-size: 13.5px; }
.tide-page .settings-card label { margin-top: 22px; font-size: 13px; }

@media (max-width: 720px) {
    #internal-container { flex-direction: column; }
    .tide-nav { flex: 0 0 auto; flex-direction: row; gap: 4px; padding: 8px 10px; border-right: 0; border-bottom: 1px solid var(--line); overflow-x: auto; overflow-y: hidden; scrollbar-width: none; }
    .tide-nav::-webkit-scrollbar { display: none; }
    .tide-nav-brand { display: none; }
    .tide-nav a { padding: 8px 12px; font-size: 13px; }
    .tide-page { padding: 24px 16px 64px; }
    .tide-page .settings-header h2 { font-size: 24px; }
}
@keyframes modal-in { from { opacity: 0; transform: translateY(14px) scale(.97); } to { opacity: 1; transform: none; } }
.settings-header { display: flex; align-items: center; justify-content: space-between; }
.settings-header h2 { margin: 0; font-size: 20px; font-weight: 650; letter-spacing: -.03em; }
#close-settings, .icon-close { width: 34px; height: 34px; display: grid; place-items: center; border: 0; border-radius: 10px; background: transparent; color: var(--muted); cursor: pointer; transition: background .18s, color .18s, transform .22s var(--spring); }
#close-settings svg, .icon-close svg { width: 18px; height: 18px; }
#close-settings:hover, .icon-close:hover { background: var(--hover); color: var(--text); }
#close-settings:active, .icon-close:active { transform: scale(.88); }
.settings-note { margin: 10px 0 18px; color: var(--muted); font-size: 12.5px; line-height: 1.55; }
.settings-card label { display: block; margin: 16px 0 7px; color: var(--text-2); font-size: 12.5px; font-weight: 600; }
.settings-card input, .settings-card select { width: 100%; height: 42px; padding: 0 13px; border: 1px solid var(--line-strong); border-radius: 12px; outline: 0; background: var(--bg); color: var(--text); font-size: 13.5px; transition: border-color .2s, box-shadow .25s var(--ease); }
.settings-card input::placeholder { color: var(--muted); }
.settings-card select { appearance: none; -webkit-appearance: none; padding-right: 36px; cursor: pointer; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%237f8898' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; background-size: 16px; }
.settings-card input:hover, .settings-card select:hover { border-color: var(--line-strong); }
.settings-card input:focus, .settings-card select:focus { border-color: color-mix(in srgb, var(--accent) 60%, transparent); box-shadow: 0 0 0 4px var(--accent-soft); }
.engine-warning { margin-top: 9px; margin-bottom: 0; }
.save-button { width: 100%; height: 44px; margin-top: 22px; border: 0; border-radius: 12px; background: var(--accent); color: var(--accent-ink); font-weight: 650; font-size: 14px; cursor: pointer; transition: filter .2s, transform .22s var(--spring); }
.save-button:hover { filter: brightness(1.08); } .save-button:active { transform: scale(.98); }

@media (max-width: 650px) {
    #tabs-bar { height: 42px; flex-basis: 42px; padding: 0 6px; gap: 2px; }
    #tabs { padding-top: 6px; }
    #new-tab { margin-bottom: 5px; }
    .tab { min-width: 92px; max-width: 180px; flex: 0 1 150px; gap: 7px; padding: 0 6px 0 9px; }
    .tab-title { font-size: 11.5px; }
    .tab-close { opacity: 1; }
    #toolbar { min-height: 52px; flex-basis: 52px; gap: 4px; padding: 7px 8px; }
    .nav-buttons { gap: 0; }
    .nav-buttons button, #settings, #account-button { width: 32px; height: 34px; }
    #address-form { height: 36px; }
    .address-icon { margin-left: 11px; }
    #address { padding: 0 12px 0 8px; font-size: 13px; }
    .tide-new-tab { padding: 28px 16px; }
    .tide-bookmarks { grid-template-columns: repeat(2,minmax(0,1fr)); gap: 8px; }
    .tide-section-title { margin-top: 30px; }
}
@media (max-width: 380px) {
    #toolbar { gap: 2px; padding-inline: 5px; }
    .nav-buttons button, #settings, #account-button { width: 29px; }
    .address-icon { display: none; }
    #address { padding-left: 12px; }
    .tab { min-width: 80px; }
    .tide-search-form::before { display: none; }
    .tide-search-form button { min-width: 74px; padding-inline: 14px; }
}
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}

/* ---------- light theme ---------- */
:root[data-theme="light"] {
    color-scheme: light;
    --bg: #f3f5f9;
    --tabbar: #e4e8ef;
    --chrome: #ffffff;
    --surface: #ffffff;
    --surface-2: #f0f3f8;
    --line: rgba(15,23,42,.09);
    --line-strong: rgba(15,23,42,.17);
    --text: #141a26;
    --text-2: #475167;
    --muted: #7a8396;
    --hover: rgba(15,23,42,.06);
    --press: rgba(15,23,42,.11);
    --field-focus: #ffffff;
    --glass: rgba(255,255,255,.85);
    --glow: #e8edf5;
    --pop: #ffffff;
    --accent-ink: #0a1a18;
}
:root[data-theme="light"] #tide-loading { background: radial-gradient(ellipse at 50% 36%, #ffffff 0, #eef2f8 55%, #e3e8f0 100%); }
:root[data-theme="light"] .tide-search-form { box-shadow: 0 14px 40px rgba(30,41,59,.12); }
:root[data-theme="light"] .tide-bookmark:hover { box-shadow: 0 10px 26px rgba(30,41,59,.14); }
:root[data-theme="light"] .tide-bookmark-icon { background: hsl(var(--h,170) 60% 50% / .16); color: hsl(var(--h,170) 60% 30%); }
:root[data-theme="light"] .overlay { background: rgba(20,26,38,.35); }
/* Only pop-up cards cast a shadow; tide:// pages are part of the page. */
:root[data-theme="light"] .settings-card:not(.tide-page .settings-card) { box-shadow: 0 30px 80px rgba(20,26,38,.25); }

/* ---------- loading bar + tab spinner ---------- */
#load-bar { position: relative; z-index: 4; height: 2px; flex: 0 0 2px; margin-top: -2px; overflow: hidden; opacity: 0; pointer-events: none; transition: opacity .3s var(--ease); }
#load-bar.on { opacity: 1; }
#load-bar span { position: absolute; top: 0; bottom: 0; left: 0; width: 38%; background: var(--accent); border-radius: 2px; box-shadow: 0 0 10px var(--accent); animation: bar-slide 1.15s var(--ease) infinite; }
@keyframes bar-slide { from { transform: translateX(-110%); } to { transform: translateX(300%); } }
.tab.loading .tab-icon { opacity: 0; }
.tab.loading::before { content: ""; position: absolute; left: 12px; top: 50%; width: 14px; height: 14px; margin-top: -7px; border: 2px solid var(--line-strong); border-top-color: var(--accent); border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.tab.dragging { opacity: .45; }

/* ---------- address bar: bookmark button + suggestions ---------- */
#bookmark { width: 30px; height: 30px; margin-right: 4px; display: grid; place-items: center; flex: 0 0 30px; border: 0; border-radius: 999px; background: transparent; color: var(--muted); cursor: pointer; transition: background .18s, color .18s, transform .25s var(--spring), opacity .2s; }
#bookmark svg { width: 16px; height: 16px; transition: fill .2s, transform .35s var(--spring); }
#bookmark:hover:not(:disabled) { background: var(--hover); color: var(--text); }
#bookmark:active:not(:disabled) { transform: scale(.88); }
#bookmark:disabled { opacity: .3; cursor: default; }
#bookmark.on { color: var(--accent); }
#bookmark.on svg { fill: currentColor; transform: scale(1.08); }
#suggestions { position: absolute; z-index: 20; left: 0; right: 0; top: calc(100% + 8px); padding: 6px; border: 1px solid var(--line-strong); border-radius: 18px; background: var(--pop); box-shadow: 0 24px 60px rgba(0,0,0,.45); transform-origin: top center; animation: pop-in .18s var(--ease) both; }
#suggestions[hidden] { display: none; }
@keyframes pop-in { from { opacity: 0; transform: translateY(-4px) scale(.985); } to { opacity: 1; transform: none; } }
.suggestion { display: flex; align-items: center; gap: 12px; padding: 8px 10px; border-radius: 12px; color: var(--text-2); cursor: pointer; transition: background .12s; }
.suggestion:hover, .suggestion.selected { background: var(--hover); color: var(--text); }
.suggestion.selected { background: var(--accent-soft); }
.s-icon { width: 28px; height: 28px; display: grid; place-items: center; flex: 0 0 28px; border-radius: 9px; background: var(--hover); color: var(--muted); }
.s-icon svg { width: 15px; height: 15px; }
.suggestion.selected .s-icon { color: var(--accent); }
.s-main { min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.s-title, .s-sub { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.s-title { font-size: 13px; font-weight: 500; }
.s-sub { color: var(--muted); font-size: 11.5px; }

/* ---------- new tab sites ---------- */
.tide-bookmark-icon { position: relative; overflow: hidden; }
.tide-bookmark-icon svg { width: 16px; height: 16px; }
.tide-bookmark-favicon { position: absolute; inset: 0; width: 100%; height: 100%; padding: 7px; object-fit: contain; background: var(--surface-2); opacity: 0; transition: opacity .25s; }
.tide-bookmark-icon.has-icon .tide-bookmark-favicon { opacity: 1; }
.tide-bookmark.add { border-style: dashed; background: transparent; color: var(--muted); }
.tide-bookmark.add .tide-bookmark-icon { background: var(--hover); color: var(--text-2); }
.tide-bookmark.add:hover { color: var(--text); border-color: var(--accent); }
.tide-bookmark-remove { position: absolute; top: 6px; right: 6px; width: 22px; height: 22px; display: grid; place-items: center; border: 0; border-radius: 7px; background: var(--hover); color: var(--muted); cursor: pointer; opacity: 0; transform: scale(.85); transition: opacity .18s, transform .22s var(--spring), background .16s, color .16s; }
.tide-bookmark-remove svg { width: 12px; height: 12px; }
.tide-bookmark-item:hover .tide-bookmark-remove, .tide-bookmark-remove:focus-visible { opacity: 1; transform: none; }
.tide-bookmark-remove:hover { background: var(--press); color: var(--text); }
@media (hover: none) { .tide-bookmark-remove { opacity: 1; transform: none; } }

/* ---------- dialog / overlay ---------- */
.overlay { position: fixed; inset: 0; z-index: 5200; display: grid; place-items: center; padding: 18px; background: rgba(4,5,8,.62); backdrop-filter: blur(10px) saturate(1.2); animation: fade .2s ease both; }
.overlay .settings-card { animation: modal-in .35s var(--ease) both; }
.dialog-card { width: min(380px,100%); }

/* ---------- settings controls ---------- */
.seg { display: grid; grid-template-columns: repeat(3,1fr); gap: 4px; padding: 4px; border: 1px solid var(--line-strong); border-radius: 13px; background: var(--bg); }
.seg button { height: 34px; border: 0; border-radius: 9px; background: transparent; color: var(--text-2); font-size: 13px; font-weight: 550; cursor: pointer; transition: background .2s var(--ease), color .2s, transform .2s var(--spring); }
.seg button:hover { color: var(--text); }
.seg button:active { transform: scale(.96); }
.seg button[aria-pressed="true"] { background: var(--surface-2); color: var(--text); box-shadow: 0 1px 0 var(--line-strong), 0 4px 10px rgba(0,0,0,.18); }
.swatches { display: flex; gap: 10px; flex-wrap: wrap; }
.swatches button { width: 30px; height: 30px; border: 0; border-radius: 50%; background: var(--c); cursor: pointer; box-shadow: inset 0 0 0 1px rgba(0,0,0,.12); transition: transform .25s var(--spring), box-shadow .2s; }
.swatches button:hover { transform: scale(1.1); }
.swatches button[aria-pressed="true"] { box-shadow: 0 0 0 2px var(--chrome), 0 0 0 4px var(--c); transform: scale(1.04); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.chips button { height: 28px; padding: 0 12px; border: 1px solid var(--line-strong); border-radius: 999px; background: transparent; color: var(--text-2); font-size: 12px; font-weight: 550; cursor: pointer; transition: background .16s, color .16s, border-color .16s, transform .2s var(--spring); }
.chips button:hover { background: var(--hover); color: var(--text); }
.chips button:active { transform: scale(.94); }
.settings-card label.toggle { display: flex; align-items: center; gap: 12px; margin: 14px 0 0; color: var(--text-2); font-size: 13px; font-weight: 500; cursor: pointer; }
.toggle input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch { position: relative; width: 38px; height: 22px; flex: 0 0 38px; border-radius: 999px; background: var(--press); transition: background .25s var(--ease); }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.35); transition: transform .3s var(--spring); }
.toggle input:checked + .switch { background: var(--accent); }
.toggle input:checked + .switch::after { transform: translateX(16px); }
.toggle input:focus-visible + .switch { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- toasts ---------- */
#toasts { position: fixed; z-index: 9000; left: 50%; bottom: 22px; display: flex; flex-direction: column; align-items: center; gap: 8px; transform: translateX(-50%); pointer-events: none; }
.toast { display: flex; align-items: center; gap: 14px; max-width: min(460px, calc(100vw - 28px)); padding: 11px 14px 11px 16px; border: 1px solid var(--line-strong); border-radius: 14px; background: var(--pop); color: var(--text); font-size: 13px; box-shadow: 0 18px 44px rgba(0,0,0,.42); pointer-events: auto; animation: toast-in .4s var(--spring) both; }
.toast.out { animation: toast-out .26s var(--ease) both; }
.toast.error { border-color: rgba(255,122,144,.5); }
.toast-action { height: 26px; padding: 0 10px; border: 0; border-radius: 8px; background: var(--accent-soft); color: var(--accent); font-size: 12.5px; font-weight: 650; cursor: pointer; transition: background .16s, transform .2s var(--spring); }
.toast-action:hover { background: color-mix(in srgb, var(--accent) 28%, transparent); }
.toast-action:active { transform: scale(.94); }
@keyframes toast-in { from { opacity: 0; transform: translateY(14px) scale(.96); } to { opacity: 1; transform: none; } }
@keyframes toast-out { to { opacity: 0; transform: translateY(8px) scale(.97); } }

/* ---------- context menu + tab preview ---------- */
.menu { position: fixed; z-index: 8000; min-width: 220px; padding: 6px; border: 1px solid var(--line-strong); border-radius: 14px; background: var(--pop); box-shadow: 0 24px 60px rgba(0,0,0,.45); transform-origin: top left; animation: pop-in .16s var(--ease) both; }
.menu-item { width: 100%; height: 34px; display: flex; align-items: center; justify-content: space-between; gap: 18px; padding: 0 10px; border: 0; border-radius: 9px; background: transparent; color: var(--text-2); font-size: 13px; text-align: left; cursor: pointer; transition: background .12s, color .12s; }
.menu-item:hover:not(:disabled), .menu-item:focus-visible { background: var(--hover); color: var(--text); outline: none; }
.menu-item:disabled { opacity: .38; cursor: default; }
.menu-item.danger:hover:not(:disabled) { background: rgba(255,122,144,.14); color: #ff7a90; }
.menu-item kbd { color: var(--muted); font: inherit; font-size: 11.5px; }
.menu-sep { height: 1px; margin: 5px 6px; background: var(--line); }
#tab-tip { position: fixed; z-index: 7000; max-width: 320px; padding: 9px 12px; border: 1px solid var(--line-strong); border-radius: 12px; background: var(--pop); box-shadow: 0 16px 40px rgba(0,0,0,.4); opacity: 0; transform: translateY(-3px); pointer-events: none; transition: opacity .15s, transform .2s var(--ease); }
#tab-tip.show { opacity: 1; transform: none; }
.tip-title { font-size: 12.5px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tip-url { margin-top: 2px; color: var(--muted); font-size: 11.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- hide screen ---------- */

/* ---------- page load error ---------- */
#frame-error { position: absolute; inset: 0; z-index: 3; display: grid; place-items: center; padding: 22px; background: radial-gradient(ellipse 70% 55% at 50% 28%, var(--accent-soft), transparent 70%), var(--bg); }
#frame-error[hidden] { display: none; }
.frame-error-card { width: min(420px, 100%); padding: 26px; border: 1px solid var(--line-strong); border-radius: 18px; background: var(--pop); box-shadow: 0 18px 50px rgba(0,0,0,.35); animation: fade .3s ease both; }
.frame-error-card h2 { margin: 0 0 8px; font-size: 19px; letter-spacing: -.01em; }
.frame-error-url { margin: 0; color: var(--text-2); font-size: 13px; overflow-wrap: anywhere; }
.frame-error-explain { margin: 12px 0 0; color: var(--text-2); font-size: 13.5px; line-height: 1.55; }
.frame-error-explain:empty { display: none; }
.frame-error-message { margin: 10px 0 0; color: var(--muted); font: 11.5px/1.5 ui-monospace, "Cascadia Mono", Consolas, monospace; overflow-wrap: anywhere; }
/* Whose fault it was, at a glance. */
.frame-error-badge { display: inline-block; margin-bottom: 12px; padding: 3px 9px; border-radius: 999px; font-size: 11.5px; font-weight: 650; letter-spacing: .01em; background: var(--hover); color: var(--text-2); }
.frame-error-badge:empty { display: none; }
.frame-error-badge.site { background: color-mix(in srgb, #ffb454 18%, transparent); color: #ffb454; }
.frame-error-badge.tide { background: var(--accent-soft); color: var(--accent); }
.frame-error-badge.blocked { background: color-mix(in srgb, #ff7a90 18%, transparent); color: #ff7a90; }
.frame-error-message:empty { display: none; }
.frame-error-actions .save-button { margin-top: 20px; }
.frame-error-secondary { width: 100%; height: 40px; margin-top: 8px; border: 1px solid var(--line-strong); border-radius: 12px; background: transparent; color: var(--text-2); font-size: 13.5px; font-weight: 600; cursor: pointer; transition: background .18s, color .18s; }
.frame-error-secondary:hover { background: var(--hover); color: var(--text); }

/* ---------- account ---------- */
.account-section { margin-top: 18px; }
.account-section .settings-note { margin: 0 0 12px; }
.account-form input { margin-top: 8px; }
.account-form input:first-of-type { margin-top: 0; }
.account-actions .save-button { margin-top: 14px; }
.account-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; font-size: 13.5px; color: var(--text-2); }
.account-row b { color: var(--text); font-weight: 650; }
.account-link { border: 0; background: none; padding: 4px 2px; color: var(--accent); font-size: 12.5px; font-weight: 600; cursor: pointer; }
.account-link:hover { text-decoration: underline; }
.account-speed { margin: 8px 0 0; color: var(--muted); font-size: 12.5px; line-height: 1.5; }
.account-speed.premium { color: var(--accent); }
.account-section label { margin-top: 14px; }
.settings-card textarea { width: 100%; padding: 10px 13px; border: 1px solid var(--line-strong); border-radius: 12px; outline: 0; background: var(--chrome); color: var(--text); font: 13px ui-monospace, "Cascadia Mono", Consolas, monospace; resize: vertical; transition: border-color .2s, box-shadow .25s var(--ease); }
.settings-card textarea:focus { border-color: color-mix(in srgb, var(--accent) 60%, transparent); box-shadow: 0 0 0 4px var(--accent-soft); }
.account-section button:disabled { opacity: .6; cursor: progress; }
.account-forgot-link { display: block; margin: 10px auto 0; }
.account-inline { display: flex; gap: 8px; }
.account-inline input { flex: 1; min-width: 0; }
.account-inline .frame-error-secondary { width: auto; height: 42px; margin: 0; padding: 0 16px; }
.account-email-confirm { margin-top: 8px; }
#account-button { position: relative; }
#account-button[hidden] { display: none; }
/* Small dot when signed in; accent colour, filled ring when premium. */
#account-button.signed-in::after { content: ""; position: absolute; right: 6px; bottom: 6px; width: 7px; height: 7px; border-radius: 50%; background: var(--text-2); box-shadow: 0 0 0 2px var(--chrome); }
#account-button.premium::after { background: var(--accent); }
.account-details { margin-top: 14px; border-top: 1px solid var(--line); padding-top: 12px; }
.account-details summary { cursor: pointer; color: var(--text-2); font-size: 12.5px; font-weight: 600; list-style: none; }
.account-details summary::-webkit-details-marker { display: none; }
.account-details summary::after { content: " ▸"; color: var(--muted); }
.account-details[open] summary::after { content: " ▾"; }
.account-details .account-form { margin-top: 10px; }
.account-details .frame-error-secondary { margin-top: 10px; }
.account-intro { margin-bottom: 16px; }
.account-intro-lead { margin: 0 0 12px; color: var(--text-2); font-size: 13px; line-height: 1.5; }
.account-perks { display: grid; gap: 10px; margin: 0; padding: 0; list-style: none; }
.account-perks li { display: grid; grid-template-columns: 30px 1fr; gap: 10px; align-items: start; }
.account-perks li[hidden] { display: none; }
.account-perks svg { width: 30px; height: 30px; padding: 7px; border-radius: 9px; background: var(--accent-soft); fill: none; stroke: var(--accent); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.account-perks li > span { color: var(--muted); font-size: 12.5px; line-height: 1.45; }
.account-perks b { display: block; color: var(--text); font-size: 13px; font-weight: 600; margin-bottom: 1px; }
.account-privacy { margin: 14px 0 0; padding-top: 12px; border-top: 1px solid var(--line); color: var(--muted); font-size: 11.5px; line-height: 1.5; }
:root[data-theme="light"] .frame-error-badge.site { color: #8a5200; }
:root[data-theme="light"] .frame-error-badge.blocked { color: #b4233c; }

/* ---------- announcement banner ---------- */
.announcement { flex: 0 0 auto; display: flex; align-items: center; gap: 10px; padding: 8px 10px 8px 14px; background: var(--accent-soft); border-bottom: 1px solid var(--line); color: var(--text); font-size: 13px; line-height: 1.45; animation: fade .3s ease both; }
.announcement[hidden] { display: none; }
.announcement > svg { width: 17px; height: 17px; flex: 0 0 17px; fill: none; stroke: var(--accent); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.announcement.warning { background: color-mix(in srgb, #ffb454 16%, transparent); }
.announcement.warning > svg { stroke: #ffb454; }
.announcement-text { flex: 1; min-width: 0; overflow-wrap: anywhere; }
#announcement-close { width: 28px; height: 28px; flex: 0 0 28px; display: grid; place-items: center; border: 0; border-radius: 8px; background: transparent; color: var(--text-2); cursor: pointer; }
#announcement-close:hover { background: var(--hover); color: var(--text); }
#announcement-close svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; }
:root[data-theme="light"] .announcement.warning > svg { stroke: #8a5200; }

/* ---------- tide://history, tide://shortcuts, tide://about ---------- */
.tide-page .settings-header .account-link { font-size: 12.5px; }
#history-search { margin-bottom: 6px; }
.history-list { display: grid; }
.history-day { margin: 18px 0 6px; color: var(--muted); font-size: 11.5px; font-weight: 650; text-transform: uppercase; letter-spacing: .05em; }
.history-item { display: grid; grid-template-columns: 18px minmax(0, 1fr) auto auto; align-items: center; gap: 10px; padding: 7px 8px; border-radius: 10px; }
.history-item:hover { background: var(--hover); }
.history-item img { width: 16px; height: 16px; border-radius: 4px; }
.history-open { min-width: 0; padding: 0; border: 0; background: none; color: var(--text); text-align: left; cursor: pointer; }
.history-open span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.history-open .h-title { font-size: 13.5px; }
.history-open .h-url { color: var(--muted); font-size: 12px; }
.history-time { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.history-remove { width: 26px; height: 26px; display: grid; place-items: center; padding: 0; border: 0; border-radius: 7px; background: none; color: var(--muted); cursor: pointer; opacity: 0; }
.history-item:hover .history-remove, .history-remove:focus-visible { opacity: 1; }
.history-remove:hover { background: var(--press); color: var(--text); }
.history-remove svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; }
.history-empty { margin-top: 18px; text-align: center; }
@media (hover: none) { .history-remove { opacity: 1; } }

.tide-page-h3 { margin: 22px 0 8px; color: var(--muted); font-size: 11.5px; font-weight: 650; text-transform: uppercase; letter-spacing: .05em; }
.shortcut-list { display: grid; gap: 2px; margin: 0; }
.shortcut-list > div { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.shortcut-list dt { color: var(--text-2); font-size: 13.5px; }
.shortcut-list dd { margin: 0; white-space: nowrap; }
kbd { display: inline-block; min-width: 24px; padding: 3px 7px; border: 1px solid var(--line-strong); border-bottom-width: 2px; border-radius: 7px; background: var(--bg); color: var(--text); font-family: inherit; font-size: 12px; font-weight: 600; line-height: 1.2; text-align: center; }
.kbd-plus { margin: 0 4px; color: var(--muted); font-size: 12px; }
.shortcut-note { color: #ffb454; font-weight: 700; }
.shortcut-footnote { margin-top: 16px; }

.about-list { display: grid; margin: 4px 0 0; }
.about-list > div { display: flex; justify-content: space-between; gap: 16px; padding: 10px 0; border-bottom: 1px solid var(--line); font-size: 13.5px; }
.about-list dt { color: var(--text-2); }
.about-list dd { margin: 0; color: var(--text); text-align: right; }
.about-list .ok::before, .about-list .bad::before, .about-list .wait::before { content: ""; display: inline-block; width: 8px; height: 8px; margin-right: 8px; border-radius: 50%; vertical-align: 1px; }
.about-list .ok::before { background: #6fd6a0; }
.about-list .bad::before { background: #ff7a90; }
.about-list .wait::before { background: var(--muted); }
.small-links { margin-top: 18px; }
.small-links a { color: var(--accent); text-decoration: none; }
.small-links a:hover { text-decoration: underline; }
#search-custom { margin-top: 8px; }
#search-custom[hidden] { display: none; }
.account-danger summary { color: #ff7a90; }
.account-delete-button { width: 100%; height: 40px; margin-top: 10px; border: 1px solid rgba(255,122,144,.45); border-radius: 12px; background: transparent; color: #ff7a90; font-size: 13.5px; font-weight: 650; cursor: pointer; }
.account-delete-button:hover { background: rgba(255,122,144,.1); }
:root[data-theme="light"] .account-danger summary, :root[data-theme="light"] .account-delete-button { color: #b4233c; }

.settings-warning { margin: 10px 0 0; padding: 10px 12px; border: 1px solid rgba(255,180,84,.45); border-radius: 10px; background: color-mix(in srgb, #ffb454 12%, transparent); color: var(--text); font-size: 12.5px; line-height: 1.5; }
.settings-warning[hidden] { display: none; }
.settings-warning b { color: #ffb454; }
:root[data-theme="light"] .settings-warning b { color: #8a5200; }

.loading-actions { margin-top: 18px; }
.loading-actions[hidden] { display: none; }
.loading-actions .save-button { height: 40px; margin-top: 0; }
#tide-loading.failed .loading-card { width: 300px; }
#tide-loading.failed .loading-bar { visibility: hidden; }

.tide-section-title { display: flex; align-items: center; gap: 6px; min-height: 28px; }
.tide-sites-edit { display: inline-flex; align-items: center; gap: 5px; height: 26px; min-width: 26px; padding: 0 6px; border: 0; border-radius: 8px; background: transparent; color: var(--muted); font: inherit; font-size: 12px; cursor: pointer; transition: background .16s, color .16s; }
.tide-sites-edit svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.tide-sites-edit:hover { background: var(--hover); color: var(--text); }
.tide-sites-edit.on { background: var(--accent); color: var(--accent-ink); font-weight: 650; padding: 0 9px 0 7px; }
.tide-sites-edit.on:hover { filter: brightness(1.08); }
.tide-bookmarks.editing .tide-bookmark:not(.add) { border-style: dashed; }
.tide-bookmarks.editing .tide-bookmark-remove { opacity: 1; transform: none; }
.tide-sites-empty { grid-column: 1 / -1; margin: 4px; color: var(--muted); font-size: 13px; text-align: left; }

/* tide://games */
.tide-page.games-page { width: min(1120px, 100%); }
.games-toolbar { display: flex; align-items: center; gap: 12px; margin-top: 18px; }
.games-toolbar input { flex: 1; min-width: 0; height: 42px; padding: 0 14px; border: 1px solid var(--line-strong); border-radius: 12px; background: var(--surface); color: var(--text); font: inherit; font-size: 14px; outline: none; transition: border-color .18s, box-shadow .18s; }
.games-toolbar input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.games-count { flex: none; color: var(--muted); font-size: 12.5px; }
.games-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 14px; margin-top: 4px; }
.game-item { position: relative; min-width: 0; animation: tile-in .45s var(--ease) both; animation-delay: calc(var(--i, 0) * 22ms); }
.game-card { width: 100%; display: flex; flex-direction: column; gap: 9px; padding: 0; border: 0; background: none; color: var(--text-2); cursor: pointer; text-align: left; font: inherit; }
.game-art { position: relative; display: grid; place-items: center; aspect-ratio: 4 / 3; overflow: hidden; border-radius: 16px; border: 1px solid rgba(255,255,255,.08);
  background:
    radial-gradient(circle at 18% 18%, hsl(calc(var(--h) + 40) 90% 70% / .55), transparent 45%),
    radial-gradient(circle at 85% 90%, hsl(calc(var(--h) - 30) 85% 45% / .7), transparent 55%),
    linear-gradient(140deg, hsl(var(--h) 70% 52%), hsl(calc(var(--h) + 50) 65% 34%));
  box-shadow: 0 8px 22px rgba(0,0,0,.28), inset 0 1px 0 rgba(255,255,255,.18);
  transition: transform .3s var(--ease), box-shadow .3s var(--ease); }
.game-art::after { content: ""; position: absolute; inset: 0; background: repeating-linear-gradient(45deg, rgba(255,255,255,.05) 0 2px, transparent 2px 12px); pointer-events: none; }
.game-initials { position: relative; z-index: 1; color: #fff; font-size: 34px; font-weight: 800; letter-spacing: -.04em; text-shadow: 0 3px 14px rgba(0,0,0,.35); transition: transform .3s var(--ease), opacity .25s; }
.game-play { position: absolute; z-index: 2; width: 48px; height: 48px; border-radius: 50%; background: rgba(255,255,255,.92); box-shadow: 0 8px 24px rgba(0,0,0,.35); opacity: 0; transform: scale(.7); transition: opacity .22s, transform .3s var(--spring); }
.game-play::before { content: ""; position: absolute; left: 19px; top: 15px; border-style: solid; border-width: 9px 0 9px 15px; border-color: transparent transparent transparent hsl(var(--h) 60% 38%); }
.game-name { overflow: hidden; padding: 0 4px; font-size: 13.5px; font-weight: 600; text-overflow: ellipsis; white-space: nowrap; transition: color .18s; }
.game-card:hover .game-art, .game-card:focus-visible .game-art { transform: translateY(-4px); box-shadow: 0 18px 36px rgba(0,0,0,.4), 0 0 0 2px var(--accent), inset 0 1px 0 rgba(255,255,255,.2); }
.game-card:hover .game-play, .game-card:focus-visible .game-play { opacity: 1; transform: none; }
.game-card:hover .game-initials, .game-card:focus-visible .game-initials { opacity: .25; transform: scale(.9); }
.game-card:hover .game-name { color: var(--text); }
.game-card:active .game-art { transform: scale(.97); }
.game-card:focus-visible { outline: none; }
.game-fav { position: absolute; top: 8px; right: 8px; z-index: 3; width: 30px; height: 30px; display: grid; place-items: center; border: 0; border-radius: 10px; background: rgba(0,0,0,.35); color: #fff; cursor: pointer; opacity: 0; transform: scale(.85); backdrop-filter: blur(6px); transition: opacity .18s, transform .22s var(--spring), background .16s; }
.game-fav svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linejoin: round; }
.game-item:hover .game-fav, .game-fav:focus-visible, .game-fav.on { opacity: 1; transform: none; }
.game-fav:hover { background: rgba(0,0,0,.55); }
.game-fav.on { color: #ffd166; }
.game-fav.on svg { fill: currentColor; }
.game-item.skeleton { aspect-ratio: 4 / 3; border-radius: 16px; background: linear-gradient(90deg, var(--surface) 25%, var(--surface-2) 50%, var(--surface) 75%); background-size: 200% 100%; animation: games-shimmer 1.2s linear infinite; }
@keyframes games-shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }
.games-status { display: flex; align-items: center; gap: 10px; margin-top: 16px; color: var(--muted); font-size: 13.5px; }
.games-status[hidden] { display: none; }
@media (hover: none) { .game-fav { opacity: 1; transform: none; } }
@media (max-width: 640px) { .games-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; } .game-initials { font-size: 26px; } }
:root[data-theme="light"] .game-art { border-color: rgba(0,0,0,.06); box-shadow: 0 8px 20px rgba(30,41,59,.16), inset 0 1px 0 rgba(255,255,255,.3); }
.game-img { position: absolute; z-index: 1; opacity: 0; transition: opacity .3s, transform .3s var(--ease); }
.game-art.has-img .game-img { opacity: 1; }
.game-art.has-img .game-initials { display: none; }
.game-art.cover .game-img { inset: 0; width: 100%; height: 100%; object-fit: cover; }
.game-art.cover::after { z-index: 1; background: linear-gradient(to top, rgba(0,0,0,.25), transparent 50%); }
.game-art.icon .game-img { width: 46%; max-width: 92px; aspect-ratio: 1; object-fit: contain; padding: 8px; border-radius: 22%; background: rgba(255,255,255,.16); box-shadow: 0 10px 26px rgba(0,0,0,.35), inset 0 1px 0 rgba(255,255,255,.3); backdrop-filter: blur(6px); image-rendering: auto; }
.game-card:hover .game-art.has-img .game-img, .game-card:focus-visible .game-art.has-img .game-img { opacity: .35; transform: scale(.94); }

/* New tab page ads (admin page), one each side */
.tide-new-tab { position: relative; }
.tide-ad { position: absolute; top: 50%; z-index: 1; width: clamp(120px, 12vw, 200px); transform: translateY(-50%); animation: fade .4s ease both; }
.tide-ad[hidden] { display: none; }
.tide-ad.left { left: clamp(16px, 3vw, 48px); }
.tide-ad.right { right: clamp(16px, 3vw, 48px); }
.tide-ad img { display: block; width: 100%; max-height: min(600px, 75vh); object-fit: contain; border-radius: 12px; box-shadow: 0 14px 36px rgba(0,0,0,.35); }
.tide-ad-link { display: block; width: 100%; padding: 0; border: 0; background: none; cursor: pointer; transition: transform .25s var(--ease), filter .2s; }
.tide-ad-link:hover { transform: translateY(-2px); filter: brightness(1.05); }
.tide-ad-label { display: block; margin-bottom: 6px; color: var(--muted); font-size: 10.5px; font-weight: 600; letter-spacing: .08em; text-align: center; text-transform: uppercase; }
@media (max-width: 1100px) { .tide-ad { display: none; } }
.tide-page-icon svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* Bottom banner ad on proxied pages */
.bottom-ad { position: absolute; left: 50%; bottom: 12px; z-index: 4; width: min(360px, calc(100% - 24px)); transform: translateX(-50%); border: 1px solid var(--line-strong); border-radius: 12px; background: var(--chrome); box-shadow: 0 12px 34px rgba(0,0,0,.45); animation: bottom-ad-in .35s var(--ease) both; }
.bottom-ad[hidden] { display: none; }
@keyframes bottom-ad-in { from { opacity: 0; transform: translate(-50%, 12px); } to { opacity: 1; transform: translate(-50%, 0); } }
.bottom-ad-open { display: block; width: 100%; padding: 0; overflow: hidden; border: 0; border-radius: 11px; background: none; cursor: pointer; }
.bottom-ad-open:disabled { cursor: default; }
.bottom-ad-open img { display: block; width: 100%; height: auto; max-height: 100px; object-fit: contain; opacity: 0; transition: opacity .35s ease; }
.bottom-ad-open img.in { opacity: 1; }
.bottom-ad-label { position: absolute; left: 6px; top: 6px; z-index: 1; padding: 1px 5px; border-radius: 4px; background: rgba(0,0,0,.55); color: #fff; font-size: 9.5px; font-weight: 700; letter-spacing: .06em; pointer-events: none; }
.bottom-ad-close { position: absolute; top: -10px; right: -10px; z-index: 1; width: 24px; height: 24px; display: grid; place-items: center; padding: 0; border: 1px solid var(--line-strong); border-radius: 50%; background: var(--chrome); color: var(--text-2); cursor: pointer; box-shadow: 0 4px 12px rgba(0,0,0,.35); transition: background .16s, color .16s; }
.bottom-ad-close:hover { background: var(--hover); color: var(--text); }
.bottom-ad-close svg { width: 13px; height: 13px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; }

/* Sign in / create account tabs */
.account-tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; margin: 4px 0 14px; padding: 4px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
.account-tab { height: 36px; border: 0; border-radius: 9px; background: transparent; color: var(--muted); font: inherit; font-size: 13.5px; font-weight: 600; cursor: pointer; transition: background .18s, color .18s; }
.account-tab:hover { color: var(--text); }
.account-tab.active { background: var(--chrome); color: var(--text); box-shadow: 0 2px 8px rgba(0,0,0,.25); }
.account-form input[hidden], .account-check-note[hidden], .account-forgot-link[hidden] { display: none; }
.account-check-note { margin: 10px 0 0; text-align: center; }

/* tide://byod */
.byod-records { display: grid; gap: 8px; margin-top: 12px; }
.byod-record { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 20px; padding: 12px 14px; border: 1px solid var(--line-strong); border-radius: 14px; background: var(--surface); }
.byod-field { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.byod-field.grow { flex: 1; }
.byod-field small { color: var(--muted); font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; }
.byod-field b { font-size: 14px; }
.byod-field code { font: 600 15px ui-monospace, "Cascadia Mono", Consolas, monospace; color: var(--text); }
.byod-off { color: #ff9f43; }
.tide-page .byod-copy { width: auto; height: 34px; margin: 0; padding: 0 14px; }
.byod-warning { display: flex; gap: 10px; align-items: flex-start; margin-top: 12px; padding: 12px 14px; border: 1px solid rgba(255,159,67,.45); border-radius: 14px; background: color-mix(in srgb, #ff9f43 12%, transparent); font-size: 13px; line-height: 1.5; color: var(--text-2); }
.byod-warning svg { flex: none; width: 18px; height: 18px; margin-top: 1px; fill: none; stroke: #ff9f43; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.byod-warning b { color: var(--text); }
.byod-form { display: flex; gap: 8px; margin-top: 12px; }
.byod-form input { flex: 1; min-width: 0; }
.tide-page .byod-form .save-button { width: auto; height: 42px; margin: 0; padding: 0 22px; }
.byod-result { display: grid; gap: 8px; margin: 12px 0 0; padding: 0; list-style: none; }
.byod-result li { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border-radius: 12px; background: var(--surface); font-size: 13.5px; line-height: 1.5; }
.byod-icon { flex: none; width: 20px; height: 20px; display: grid; place-items: center; border-radius: 50%; font-size: 12px; font-weight: 800; }
.byod-ok .byod-icon { background: color-mix(in srgb, var(--accent) 25%, transparent); color: var(--accent); }
.byod-bad .byod-icon { background: rgba(255,107,129,.2); color: #ff6b81; }
.byod-wait .byod-icon { background: rgba(255,180,84,.2); color: #ffb454; }
.byod-result a { color: var(--accent); }
:root[data-theme="light"] .byod-off, :root[data-theme="light"] .byod-warning svg { color: #b45f06; stroke: #b45f06; }
.tide-page .byod-signin { width: auto; margin-top: 12px; padding: 0 22px; }
.byod-count { margin-left: 6px; color: var(--muted); font-weight: 600; text-transform: none; letter-spacing: 0; }
.byod-mine { display: grid; gap: 8px; }
.byod-domain { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 14px; border: 1px solid var(--line-strong); border-radius: 14px; background: var(--surface); }
.byod-domain-name { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; min-width: 0; font-size: 14px; }
.byod-domain-name a { color: var(--accent); font-weight: 650; text-decoration: none; }
.byod-domain-name a:hover { text-decoration: underline; }
.byod-chip { padding: 2px 9px; border-radius: 999px; font-size: 11.5px; font-weight: 650; }
.byod-chip.byod-ok { background: color-mix(in srgb, var(--accent) 20%, transparent); color: var(--accent); }
.byod-chip.byod-wait { background: rgba(255,180,84,.18); color: #e0951f; }
.byod-chip.byod-bad { background: rgba(255,107,129,.18); color: #ff6b81; }
.byod-domain-actions { display: flex; gap: 6px; }
.tide-page .byod-domain-actions .frame-error-secondary { width: auto; height: 32px; margin: 0; padding: 0 12px; font-size: 12.5px; }
.tide-page .byod-remove:hover { color: #ff6b81; }
