/* Browser overlay chrome. Sits above the homepage; the page never navigates. */

/* The project has no global border-box, so widths here would otherwise grow by
   their own padding and borders. */
.browser,
.browser *,
.browser *::before,
.browser *::after {
    box-sizing: border-box;
}

.browser {
    position: fixed;
    inset: 0;
    z-index: 324898;
    display: flex;
    flex-direction: column;
    background: var(--bg);
}

.browser[hidden] {
    display: none;
}

body.browser-open {
    overflow: hidden;
}

/* ---- toolbar ---- */

.browser-toolbar {
    display: flex;
    flex: 0 0 auto;
    align-items: center;
    gap: 8px;
    height: 46px;
    padding: 0 8px;
    border-bottom: 1px solid var(--border);
    background: var(--bg-1);
}

.browser-nav,
.browser-actions {
    display: flex;
    flex: 0 0 auto;
    align-items: center;
    gap: 2px;
}

.browser-btn {
    display: grid;
    width: 30px;
    height: 30px;
    place-items: center;
    padding: 0;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: var(--accent-muted);
    font-size: 0.8rem;
    cursor: pointer;
    transition: background-color 130ms ease, color 130ms ease;
}

.browser-btn:hover {
    background: var(--bg-3);
    color: var(--text-bright);
}

.browser-btn:disabled {
    opacity: 0.35;
    cursor: default;
}

.browser-omnibox {
    display: flex;
    flex: 1;
    min-width: 0;
    align-items: center;
    gap: 8px;
    height: 30px;
    padding: 0 10px;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--bg-3);
    transition: border-color 130ms ease;
}

.browser-omnibox:focus-within {
    border-color: var(--border-3);
}

.browser-omnibox-icon {
    flex: 0 0 auto;
    color: var(--accent-muted);
    font-size: 0.68rem;
}

.browser-url {
    min-width: 0;
    flex: 1;
    border: 0;
    outline: 0;
    background: transparent;
    color: var(--text-bright);
    font-size: 0.78rem;
    font-family: inherit;
}

.browser-url::placeholder {
    color: var(--accent-muted);
}

.browser-spinner {
    width: 12px;
    height: 12px;
    flex: 0 0 auto;
    border: 1.5px solid var(--border-3);
    border-top-color: var(--text-bright);
    border-radius: 50%;
    animation: browser-spin 700ms linear infinite;
}

.browser-spinner[hidden] {
    display: none;
}

@keyframes browser-spin {
    to { transform: rotate(360deg); }
}

/* ---- body ---- */

.browser-body {
    display: flex;
    flex: 1;
    min-height: 0;
}

.browser-sidebar {
    display: flex;
    width: 176px;
    flex: 0 0 auto;
    flex-direction: column;
    gap: 4px;
    padding: 8px 6px;
    border-right: 1px solid var(--border);
    background: var(--bg-1);
    transition: width 160ms ease;
}

.browser-sidebar.is-collapsed {
    width: 48px;
}

.browser-newtab {
    display: flex;
    flex: 0 0 auto;
    align-items: center;
    gap: 8px;
    height: 32px;
    padding: 0 9px;
    border: 0;
    border-radius: 9px;
    background: transparent;
    color: var(--accent-muted);
    font-family: inherit;
    font-size: 0.74rem;
    cursor: pointer;
    transition: background-color 130ms ease, color 130ms ease;
}

.browser-newtab:hover {
    background: var(--bg-3);
    color: var(--text-bright);
}

.browser-sidebar.is-collapsed .browser-newtab,
.browser-sidebar.is-collapsed .browser-tab,
.browser-sidebar.is-collapsed .browser-collapse {
    width: 34px;
    height: 34px;
    justify-content: center;
    padding: 0;
    margin-inline: auto;
}

.browser-sidebar.is-collapsed .browser-newtab-label,
.browser-sidebar.is-collapsed .browser-tab-label,
.browser-sidebar.is-collapsed .browser-tab-close {
    display: none;
}

.browser-tabs {
    display: flex;
    flex: 1;
    min-height: 0;
    flex-direction: column;
    gap: 2px;
    overflow-y: auto;
    scrollbar-width: none;
}

.browser-tabs::-webkit-scrollbar {
    display: none;
}

.browser-tab {
    display: flex;
    height: 30px;
    flex: 0 0 auto;
    align-items: center;
    gap: 8px;
    padding: 0 8px;
    border-radius: 9px;
    color: var(--accent-muted);
    font-size: 0.72rem;
    cursor: default;
    transition: background-color 130ms ease, color 130ms ease;
}

.browser-tab:hover {
    background: var(--bg-2);
    color: var(--text);
}

.browser-tab.is-active {
    background: var(--bg-4);
    color: var(--text-bright);
}

.browser-tab-icon {
    display: grid;
    width: 16px;
    height: 16px;
    flex: 0 0 auto;
    place-items: center;
    font-size: 0.66rem;
}

.browser-tab-icon img {
    width: 16px;
    height: 16px;
    object-fit: contain;
}

.browser-tab-label {
    flex: 1;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.browser-tab-close {
    display: grid;
    width: 18px;
    height: 18px;
    flex: 0 0 auto;
    place-items: center;
    padding: 0;
    border: 0;
    border-radius: 6px;
    background: transparent;
    color: inherit;
    font-size: 0.62rem;
    opacity: 0;
    cursor: pointer;
    transition: opacity 130ms ease, background-color 130ms ease;
}

.browser-tab:hover .browser-tab-close {
    opacity: 0.7;
}

.browser-tab-close:hover {
    background: var(--bg-1);
    opacity: 1;
}

.browser-collapse {
    flex: 0 0 auto;
    align-self: flex-start;
}

.browser-sidebar.is-collapsed .browser-collapse {
    align-self: center;
}

/* ---- frames ---- */

.browser-frames {
    position: relative;
    flex: 1;
    min-width: 0;
    background: var(--bg);
}

.browser-pane {
    position: absolute;
    inset: 0;
    display: none;
    overflow: auto;
}

.browser-pane.is-active {
    display: block;
}

/* An internal tab renders the homepage, which centres itself in the pane. */
.browser-pane > .homecontent,
.browser-pane .search-shell {
    margin-inline: auto;
}

.browser-iframe {
    width: 100%;
    height: 100%;
    border: 0;
    background: #fff;
}

/* ---- error ---- */

.browser-error {
    position: absolute;
    left: 50%;
    bottom: 22px;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    border: 1px solid var(--border-2);
    border-radius: 12px;
    background: var(--bg-3);
    transform: translateX(-50%);
}

.browser-error[hidden] {
    display: none;
}

.browser-error-text {
    margin: 0;
    color: var(--text);
    font-size: 0.76rem;
}

.browser-retry {
    padding: 5px 12px;
    border: 1px solid var(--border-2);
    border-radius: 8px;
    background: var(--bg-1);
    color: var(--text-bright);
    font-family: inherit;
    font-size: 0.72rem;
    cursor: pointer;
}

.browser-retry:hover {
    border-color: var(--border-4);
}

@media (max-width: 540px) {
    .browser-sidebar {
        width: 48px;
    }

    .browser-newtab-label,
    .browser-tab-label,
    .browser-tab-close {
        display: none;
    }

    .browser-newtab,
    .browser-tab,
    .browser-collapse {
        width: 34px;
        height: 34px;
        justify-content: center;
        padding: 0;
        margin-inline: auto;
    }
}
