/* =====================================================================
   Browser  (.app-browser)
   ===================================================================== */
/* tabs replace the window title, like a modern browser */
.win[data-app="browser"] .win-title { display: none; }
.win[data-app="browser"] .win-bar { gap: 12px; }
.browser-tabwrap { flex: 1; min-width: 0; height: 100%; display: flex; align-items: center; gap: 4px; padding-right: 8px; }
.browser-tabs { display: flex; align-items: center; gap: 3px; min-width: 0; flex: 0 1 auto; overflow: hidden; height: 100%; }
.browser-tab {
  position: relative; flex: 0 1 auto; width: 210px; min-width: 44px; height: 30px; padding: 0 6px 0 10px; border-radius: 9px;
  display: flex; align-items: center; gap: 8px; font-size: 12.5px; font-weight: 600; color: var(--text-2); cursor: default;
  transition: background .12s, color .12s;
}
.browser-tab:hover { background: var(--hover); color: var(--text); }
.browser-tab.on { background: var(--surface); color: var(--text); box-shadow: 0 1px 3px rgba(0, 0, 0, .14), inset 0 0 0 1px var(--line); }
[data-theme="dark"] .browser-tab.on { background: var(--surface-3); }
.browser-tab + .browser-tab:not(.on)::before { content: ''; position: absolute; left: -2px; top: 9px; bottom: 9px; width: 1px; background: var(--line-2); }
.browser-tab.on + .browser-tab::before, .browser-tab:hover + .browser-tab::before { display: none; }
.browser-fav { width: 16px; height: 16px; flex: 0 0 auto; display: grid; place-items: center; color: var(--accent); }
.browser-fav .spinner { width: 13px; height: 13px; border-width: 2px; }
.browser-fav img { width: 16px; height: 16px; border-radius: 3px; object-fit: contain; }
.browser-tab-title { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; -webkit-mask-image: linear-gradient(90deg, #000 85%, transparent); mask-image: linear-gradient(90deg, #000 85%, transparent); }
.browser-tab-x { width: 20px; height: 20px; flex: 0 0 auto; border: 0; padding: 0; border-radius: 6px; display: grid; place-items: center; background: none; color: var(--text-2); opacity: 0; transition: opacity .12s, background .12s; }
.browser-tab:hover .browser-tab-x, .browser-tab.on .browser-tab-x { opacity: 1; }
.browser-tab-x:hover { background: var(--hover); color: var(--text); }
.browser-tabs.many .browser-tab:not(.on) .browser-tab-title { -webkit-mask-image: linear-gradient(90deg, #000 60%, transparent); mask-image: linear-gradient(90deg, #000 60%, transparent); }
.browser-newtab { width: 28px; height: 28px; flex: 0 0 auto; border: 0; padding: 0; border-radius: 8px; display: grid; place-items: center; background: none; color: var(--text-2); }
.browser-newtab:hover { background: var(--hover); color: var(--text); }

/* toolbar */
.app-browser { background: var(--surface); container-type: inline-size; container-name: browser; position: relative; }
.browser-toolbar { height: 46px; flex: 0 0 auto; display: flex; align-items: center; gap: 2px; padding: 0 8px; background: var(--surface); border-bottom: 1px solid var(--line); }
.browser-toolbar .icon-btn { width: 34px; height: 34px; border-radius: 50%; }
.browser-omni { flex: 1; min-width: 0; height: 34px; margin: 0 6px; display: flex; align-items: center; gap: 8px; padding: 0 4px 0 13px; border-radius: 17px; background: var(--tile); transition: background .12s, box-shadow .12s; }
.browser-omni:hover { background: var(--tile-hover); }
.browser-omni:focus-within { background: var(--surface-2); box-shadow: inset 0 0 0 2px var(--accent), 0 4px 18px -8px rgba(var(--accent-rgb), .6); }
.browser-omni-ic { display: grid; place-items: center; color: var(--text-3); flex: 0 0 auto; }
.browser-omni-ic.secure { color: var(--text-2); }
.browser-omni-ic.insecure { color: #e5484d; }
.browser-omni-input { flex: 1; min-width: 0; height: 100%; border: 0; outline: none; background: none; font-size: 13.5px; color: var(--text); }
.browser-omni-input::placeholder { color: var(--text-3); }
.browser-omni .icon-btn { width: 28px; height: 28px; color: var(--text-2); }
.browser-progress { position: relative; height: 2px; margin-top: -2px; z-index: 2; overflow: hidden; pointer-events: none; }
.browser-progress i { position: absolute; left: 0; top: 0; bottom: 0; width: 0; background: var(--accent); opacity: 0; transition: width .3s, opacity .4s .2s; }
.browser-progress.on i { width: 82%; opacity: 1; transition: width 4s cubic-bezier(.1, .7, .2, 1), opacity .1s; }

/* viewport + views */
.browser-viewport { position: relative; flex: 1; min-height: 0; }
.browser-view { position: absolute; inset: 0; display: none; background: var(--surface); overflow: hidden; }
.browser-view.on { display: block; }
.browser-frame { width: 100%; height: 100%; border: 0; display: block; background: #fff; }
.browser-ext-pill {
  position: absolute; right: 14px; bottom: 14px; z-index: 3; height: 30px; padding: 0 12px; border: 0; border-radius: 15px;
  display: inline-flex; align-items: center; gap: 7px; font-size: 12px; font-weight: 600;
  color: #fff; background: rgba(20, 24, 34, .72); -webkit-backdrop-filter: blur(14px) saturate(1.5); backdrop-filter: blur(14px) saturate(1.5);
  box-shadow: 0 6px 20px -6px rgba(0, 0, 0, .45), inset 0 0 0 1px rgba(255, 255, 255, .12); opacity: .82; transition: opacity .15s, transform .15s;
}
.browser-ext-pill:hover { opacity: 1; transform: translateY(-1px); }

/* notice / blocked card */
.browser-notice { position: absolute; inset: 0; display: grid; place-items: center; padding: 24px; overflow: auto;
  background: radial-gradient(60% 50% at 50% 30%, rgba(var(--accent-rgb), .1), transparent 70%), var(--surface); }
.browser-notice.overlay { background: color-mix(in srgb, var(--surface) 82%, transparent); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); z-index: 4; animation: browser-fade .25s; }
@keyframes browser-fade { from { opacity: 0; } to { opacity: 1; } }
.browser-notice-card { max-width: 440px; display: flex; flex-direction: column; align-items: center; text-align: center; gap: 8px; }
.browser-notice-ic { width: 72px; height: 72px; border-radius: 22px; display: grid; place-items: center; color: var(--accent); background: rgba(var(--accent-rgb), .14); margin-bottom: 6px; }
.browser-notice h2 { margin: 0; font-size: 19px; overflow-wrap: anywhere; }
.browser-notice p { margin: 0 0 12px; font-size: 13.5px; line-height: 1.55; color: var(--text-2); }
.browser-notice .row { flex-wrap: wrap; justify-content: center; }

/* start page */
.browser-start { position: absolute; inset: 0; overflow: auto; display: flex; justify-content: center;
  background: linear-gradient(180deg, rgba(var(--accent-rgb), .10), transparent 55%), var(--surface); }
.browser-start-glow { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.browser-start-glow::before, .browser-start-glow::after { content: ''; position: absolute; border-radius: 50%; filter: blur(60px); opacity: .55; }
.browser-start-glow::before { width: 420px; height: 420px; left: -120px; top: -160px; background: rgba(var(--accent-rgb), .45); }
.browser-start-glow::after { width: 360px; height: 360px; right: -100px; top: -60px; background: rgba(124, 108, 255, .3); }
[data-theme="light"] .browser-start-glow::before, [data-theme="light"] .browser-start-glow::after { opacity: .35; }
.browser-start-inner { position: relative; width: min(680px, 100%); padding: 56px 24px 30px; display: flex; flex-direction: column; align-items: center; margin: auto 0; }
.browser-clock { font-family: var(--font-display); font-size: 76px; font-weight: 200; letter-spacing: -.02em; line-height: 1; font-variant-numeric: tabular-nums; }
.browser-greet { margin-top: 8px; font-size: 20px; font-weight: 600; }
.browser-start-meta { margin-top: 6px; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; justify-content: center; font-size: 13.5px; color: var(--text-2); }
.browser-start-meta .ic { display: inline; }
.browser-start-meta .dot { width: 3px; height: 3px; border-radius: 50%; background: var(--text-3); margin: 0 4px; }
.browser-start-search {
  width: 100%; height: 52px; margin: 28px 0 30px; display: flex; align-items: center; gap: 10px; padding: 0 6px 0 18px; border-radius: 26px;
  background: var(--surface-2); color: var(--text-3); box-shadow: inset 0 0 0 1px var(--line-2), 0 10px 30px -14px rgba(0, 0, 0, .35); transition: box-shadow .15s;
}
.browser-start-search:focus-within { box-shadow: inset 0 0 0 2px var(--accent), 0 12px 34px -12px rgba(var(--accent-rgb), .55); }
.browser-start-input { flex: 1; min-width: 0; height: 100%; border: 0; outline: none; background: none; font-size: 16px; color: var(--text); }
.browser-start-input::placeholder { color: var(--text-3); }
.browser-start-go { width: 40px; height: 40px; border: 0; border-radius: 50%; display: grid; place-items: center; background: var(--accent); color: var(--accent-fg); flex: 0 0 auto; }
.browser-start-go:hover { filter: brightness(1.08); }
.browser-tiles { width: min(100%, 560px); display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.browser-tile { position: relative; border: 0; background: none; padding: 12px 4px 10px; border-radius: 16px; display: flex; flex-direction: column; align-items: center; gap: 8px; color: var(--text); transition: background .12s; }
.browser-tile:hover { background: var(--hover); }
.browser-tile-ic { width: 52px; height: 52px; border-radius: 16px; display: grid; place-items: center; color: #fff; font-size: 20px;
  background: linear-gradient(150deg, var(--a), var(--b)); box-shadow: inset 0 1px 0 rgba(255, 255, 255, .3), 0 4px 12px -4px rgba(0, 0, 0, .35); }
.browser-tile.add .browser-tile-ic { background: var(--tile); color: var(--text-2); box-shadow: inset 0 0 0 1.5px var(--line-2); }
.browser-tile-name { font-size: 12.5px; font-weight: 600; max-width: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.browser-tile-ic { position: relative; }
.browser-tile-badge { position: absolute; right: -4px; bottom: -4px; width: 20px; height: 20px; border-radius: 50%; display: grid; place-items: center; color: #fff; background: #7c6cff; box-shadow: 0 0 0 2.5px var(--surface); }
.browser-start-foot { margin: 26px 0 0; display: flex; align-items: center; gap: 7px; font-size: 12px; color: var(--text-3); text-align: center; }

/* web app placeholder page */
.browser-webapp { position: absolute; inset: 0; display: grid; place-items: center; padding: 24px; overflow: auto;
  background: radial-gradient(60% 60% at 50% 20%, color-mix(in srgb, var(--a) 30%, transparent), transparent 70%), var(--surface); }
.browser-webapp-card { max-width: 440px; display: flex; flex-direction: column; align-items: center; text-align: center; gap: 10px; }
.browser-webapp-card .appicon { box-shadow: 0 20px 40px -14px color-mix(in srgb, var(--b) 70%, #000), inset 0 1px 0 rgba(255, 255, 255, .35); margin-bottom: 8px; }
.browser-webapp h1 { margin: 0; font-family: var(--font-display); font-size: 32px; font-weight: 600; }
.browser-webapp p { margin: 0 0 8px; color: var(--text-2); font-size: 14px; line-height: 1.55; }
.browser-webapp .row { flex-wrap: wrap; justify-content: center; }
.browser-webapp small { margin-top: 8px; font-size: 12px; }

/* zoom chip, star, connection chip */
.browser-zoomchip { flex: 0 0 auto; height: 24px; padding: 0 8px; border: 0; border-radius: 12px; font-size: 11.5px; font-weight: 700; color: var(--text-2); background: var(--hover); font-variant-numeric: tabular-nums; }
.browser-zoomchip:hover { color: var(--text); background: var(--press); }
.browser-star.on { color: #f5a524; }
.browser-star.on svg { fill: currentColor; }
.browser-net {
  flex: 0 0 auto; height: 30px; max-width: 240px; margin-right: 2px; padding: 0 11px 0 9px; border: 0; border-radius: 15px;
  display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; white-space: nowrap;
  color: var(--text-2); background: var(--tile); transition: background .12s, color .12s;
}
.browser-net:hover { background: var(--tile-hover); color: var(--text); }
.browser-net span { overflow: hidden; text-overflow: ellipsis; }
.browser-net .spinner { width: 12px; height: 12px; border-width: 2px; }
.browser-net.proxy { color: #15803d; background: rgba(34, 197, 94, .13); }
.browser-net.proxy:hover { background: rgba(34, 197, 94, .2); }
[data-theme="dark"] .browser-net.proxy { color: #4ade80; }
.browser-net.proxy.insecure { color: #b45309; background: rgba(245, 158, 11, .14); }
[data-theme="dark"] .browser-net.proxy.insecure { color: #fbbf24; }
@container browser (max-width: 760px) {
  .browser-net { width: 30px; padding: 0; justify-content: center; }
  .browser-net span:not(.spinner) { display: none; }
}

/* popover under the connection chip */
.browser-pop {
  position: absolute; z-index: 20; width: min(340px, calc(100% - 16px)); padding: 14px; border-radius: 14px;
  background: var(--surface-2); color: var(--text); box-shadow: 0 18px 50px -12px rgba(0, 0, 0, .45), inset 0 0 0 1px var(--line-2);
  animation: browser-fade .15s;
}
.browser-pop-head { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.browser-pop-head b { display: block; font-size: 14px; }
.browser-pop-head small { display: block; color: var(--text-3); font-size: 12px; }
.browser-pop-ic { width: 36px; height: 36px; flex: 0 0 auto; border-radius: 11px; display: grid; place-items: center; color: var(--text-2); background: var(--tile); }
.browser-pop-ic.ok { color: #16a34a; background: rgba(34, 197, 94, .15); }
.browser-pop p { margin: 0 0 12px; font-size: 12.5px; line-height: 1.55; color: var(--text-2); }
.browser-pop .row { display: flex; flex-wrap: wrap; gap: 6px; }

/* bookmarks bar */
.browser-bookmarks { display: none; flex: 0 0 auto; height: 34px; align-items: center; gap: 2px; padding: 0 8px; overflow-x: auto; overflow-y: hidden; scrollbar-width: none;
  background: var(--surface); border-bottom: 1px solid var(--line); }
.browser-bookmarks::-webkit-scrollbar { display: none; }
.browser-bookmarks.on { display: flex; }
.browser-bm { flex: 0 0 auto; max-width: 180px; height: 26px; padding: 0 9px 0 7px; border: 0; border-radius: 8px; display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; font-weight: 600; color: var(--text-2); background: none; }
.browser-bm:hover { background: var(--hover); color: var(--text); }
.browser-bm > span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.browser-bm-ic { width: 16px; height: 16px; flex: 0 0 auto; display: grid; place-items: center; color: var(--accent); }
.browser-bm-ic img { width: 16px; height: 16px; border-radius: 3px; object-fit: contain; }

/* "this page left the proxy" bar */
.browser-leftbar { position: absolute; left: 12px; right: 12px; top: 10px; z-index: 5; display: flex; align-items: center; gap: 10px; padding: 7px 8px 7px 12px; border-radius: 12px;
  font-size: 12.5px; color: var(--text); background: var(--surface-2); box-shadow: 0 10px 30px -10px rgba(0, 0, 0, .4), inset 0 0 0 1px var(--line-2); animation: browser-fade .2s; }
.browser-leftbar > span:first-child { color: var(--accent); display: grid; }
.browser-leftbar-text { flex: 1; min-width: 0; }
.browser-leftbar .icon-btn { width: 28px; height: 28px; }

/* no-server explanation */
.browser-explain .browser-notice-card { max-width: 480px; }
.browser-explain-how { font-size: 12.5px !important; }
.browser-explain code { font-family: var(--mono); font-size: 12px; padding: 1px 6px; border-radius: 6px; background: var(--tile); color: var(--text); white-space: nowrap; }
.browser-linkbtn { border: 0; padding: 0; background: none; color: var(--accent); font: inherit; font-weight: 600; cursor: pointer; }
.browser-linkbtn:hover { text-decoration: underline; }
.browser-start-foot { flex-wrap: wrap; justify-content: center; }
.browser-start-foot > span:first-child { display: grid; }

/* search results page */
.browser-search { position: absolute; inset: 0; overflow: auto; background: var(--surface); }
.browser-search-inner { width: min(720px, 100%); margin: 0 auto; padding: 22px 24px 40px; }
.browser-search-box { margin: 0 0 14px; height: 48px; }
.browser-search-input { flex: 1; min-width: 0; height: 100%; border: 0; outline: none; background: none; font-size: 15.5px; color: var(--text); }
.browser-search-input::-webkit-search-cancel-button { display: none; }
.browser-search-meta { display: flex; align-items: center; gap: 8px; min-height: 22px; margin: 0 4px 10px; font-size: 12.5px; color: var(--text-3); }
.browser-results { display: flex; flex-direction: column; gap: 4px; }
.browser-result { padding: 12px 14px; border-radius: 14px; transition: background .12s; }
.browser-result:hover { background: var(--hover); }
.browser-result-site { display: flex; align-items: center; gap: 7px; min-width: 0; font-size: 12.5px; color: var(--text-2); }
.browser-result-site > span:nth-child(2) { font-weight: 600; white-space: nowrap; }
.browser-result-path { min-width: 0; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.browser-result-fav { width: 18px; height: 18px; flex: 0 0 auto; border-radius: 5px; display: grid; place-items: center; background: var(--tile); color: var(--text-3); overflow: hidden; }
.browser-result-fav img { width: 14px; height: 14px; object-fit: contain; }
.browser-result-title { display: inline-block; margin-top: 4px; font-size: 17px; font-weight: 600; line-height: 1.35; color: var(--accent); text-decoration: none; }
.browser-result-title:hover { text-decoration: underline; }
.browser-result-snippet { margin: 4px 0 0; font-size: 13.5px; line-height: 1.55; color: var(--text-2); display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.browser-result.skeleton { display: flex; flex-direction: column; gap: 8px; }
.browser-result.skeleton i { display: block; height: 11px; border-radius: 6px; background: var(--tile); animation: browser-pulse 1.2s ease-in-out infinite; }
.browser-result.skeleton i:nth-child(1) { width: 30%; }
.browser-result.skeleton i:nth-child(2) { width: 62%; height: 16px; }
.browser-result.skeleton i:nth-child(3) { width: 90%; }
@keyframes browser-pulse { 50% { opacity: .45; } }
.browser-results-more { display: block; margin: 16px auto 0; }
.browser-results-empty { padding: 50px 20px; display: flex; flex-direction: column; align-items: center; gap: 8px; text-align: center; color: var(--text-2); }
.browser-results-empty .row { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; margin-top: 8px; }

/* history page */
.browser-hist { position: absolute; inset: 0; overflow: auto; background: var(--surface); }
.browser-hist-inner { width: min(760px, 100%); margin: 0 auto; padding: 28px 24px 40px; }
.browser-hist-head { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.browser-hist-head h1 { margin: 0; font-family: var(--font-display); font-size: 28px; font-weight: 600; }
.browser-hist-search { width: 100%; margin-bottom: 10px; }
.browser-hist-day { margin: 18px 0 6px; }
.browser-hist-row { display: flex; align-items: center; gap: 12px; height: 42px; padding: 0 6px 0 10px; border-radius: 10px; cursor: default; }
.browser-hist-row:hover, .browser-hist-row:focus-visible { background: var(--hover); outline: none; }
.browser-hist-time { width: 52px; flex: 0 0 auto; font-size: 12px; color: var(--text-3); font-variant-numeric: tabular-nums; }
.browser-hist-ic { width: 18px; height: 18px; flex: 0 0 auto; display: grid; place-items: center; color: var(--text-2); }
.browser-hist-ic img { width: 16px; height: 16px; border-radius: 3px; object-fit: contain; }
.browser-hist-title { flex: 1 1 auto; min-width: 0; font-size: 13.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.browser-hist-host { flex: 0 1 auto; max-width: 34%; font-size: 12.5px; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.browser-hist-x { width: 30px; height: 30px; opacity: 0; }
.browser-hist-row:hover .browser-hist-x, .browser-hist-row:focus-within .browser-hist-x { opacity: 1; }
.browser-hist-empty { padding: 60px 20px; display: flex; flex-direction: column; align-items: center; gap: 8px; text-align: center; color: var(--text-2); }

/* compact */
[data-layout="mobile"] .browser-home, [data-layout="mobile"] .browser-toolbar .browser-ext { display: none; }
[data-layout="mobile"] .browser-tab { width: 150px; }
[data-layout="mobile"] .browser-clock { font-size: 60px; }
[data-layout="mobile"] .browser-start-inner { padding-top: 36px; }
[data-layout="mobile"] .browser-hist-time, [data-layout="mobile"] .browser-hist-host { display: none; }
[data-layout="mobile"] .browser-hist-x { opacity: 1; }
[data-layout="mobile"] .browser-hist-inner { padding: 18px 14px 30px; }
[data-layout="mobile"] .browser-search-inner { padding: 14px 10px 30px; }
[data-layout="mobile"] .browser-result { padding: 10px 8px; }
@media (hover: none) { .browser-hist-x { opacity: 1; } }
