* { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: var(--font-main);
    background: var(--color-bg);
    height: 100vh;
    color: var(--color-text-primary);
    overflow: hidden;
}

body.dark {
    --color-bg: #1a1a1a;
    --color-surface: #242424;
    --color-resizer: #2a2a2a;
    --color-border: #3a3a3a;
    --color-border-subtle: #2e2e2e;
    --color-text-primary: #f0f0f0;
    --color-text-secondary: #aaaaaa;
    --color-text-muted: #555555;
    --color-icon-inactive: #666666;
    --color-icon-active: #ffffff;
    --icon-opacity-inactive: 0.4;
    --icon-opacity-hover: 0.8;
    --icon-filter: invert(1);

    --preview-default-bar: #2e2e2e;
    --preview-default-surface: #1a1a1a;
    --preview-default-border: #3a3a3a;
}

.main-frame { display: flex; flex-direction: column; min-height: 100vh; }

.section-wrapper {
    display: flex;
    flex-direction: column;
    background: var(--color-bg);
    width: 100%;
    border: 1px solid var(--color-border);
    position: relative;
}

header, footer {
    padding: 6px 12px;
    flex-shrink: 0;
    text-align: center; 
    font-weight: 500;
    font-size: 0.875rem;
    background: var(--color-surface);
}

/* 1. LOGO BAR */
.logo-bar {
    height: 6vh;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 12px;
    border-bottom: 1px solid var(--color-border);
    z-index: 70;
    background: var(--color-bg);
}

/* DRAWERS */
.drawer {
    position: absolute; left: 0; width: 100%; background: var(--color-bg);
    border-bottom: 1px solid var(--color-border); max-height: 0; overflow: hidden;
    transition: max-height 0.3s ease; z-index: 60;
}

#dwelSwitcher { top: 44px; }
#notifDrawer { top: 44px; background: var(--color-surface); }
#appsDrawer { top: 90px; z-index: 50; }

#dwelSwitcher.open { max-height: 50vh; overflow-y: auto; }
#notifDrawer.open { max-height: 50vh; overflow-y: auto; }
#appsDrawer.open { max-height: 50vh; overflow-y: auto; }

/* Icon & Row Styling */
#dwelLogo { cursor: pointer; transition: opacity 0.2s; }
#dwelLogo:hover { opacity: 0.7; }
#dwelNotifications { cursor: pointer; padding: 5px; }

.switcher-row { height: 5vh; padding: 0 12px; display: flex; align-items: center; gap: 10px; border-bottom: 1px solid var(--color-border-subtle); cursor: pointer; font-size: 0.8rem; }
.notif-row { padding: 10px 15px; border-bottom: 1px solid var(--color-border); font-size: 0.875rem; color: var(--color-text-secondary); }

.icon-nav-container { height: 6vh; display: flex; align-items: center; justify-content: space-around; background: var(--color-bg); z-index: 55; border-bottom: 1px solid var(--color-border); }
.nav-icon-box { color: var(--color-icon-inactive); cursor: pointer; width: 35px; display: flex; justify-content: center; }
.nav-icon-box.active { color: var(--color-icon-active); }

/* --- ICON NAVIGATION STYLES --- */

/* 1. Default (Inactive) State */
.nav-icon-box img, 
#dwelNotifications img {
    width: 22px;
    height: 22px;
    opacity: var(--icon-opacity-inactive);
    filter: grayscale(100%) var(--icon-filter);
    transition: all 0.2s ease;
}

/* 2. Hover State */
.nav-icon-box:hover img, 
#dwelNotifications:hover img {
    opacity: var(--icon-opacity-hover);
    filter: grayscale(0%) var(--icon-filter);
}

/* 3. Active State */
.nav-icon-box.active img {
    opacity: 1;
    filter: grayscale(0%) var(--icon-filter);
    transform: scale(1.1);
}

/* Container styling */
.nav-icon-box {
    cursor: pointer;
    width: 35px;
    display: flex;
    justify-content: center;
    align-items: center;
}

.app-icon-box {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    cursor: pointer;
    font-size: 0.75rem;
    color: var(--color-text-secondary);
}

.app-icon-box img {
    width: 22px;
    height: 22px;
    opacity: var(--icon-opacity-inactive);
    filter: grayscale(100%) var(--icon-filter);
    transition: all 0.2s ease;
}

.app-icon-box:hover img {
    opacity: var(--icon-opacity-hover);
    filter: grayscale(0%) var(--icon-filter);
}

.app-icon-box.active img {
    opacity: 1;
    filter: grayscale(0%) var(--icon-filter);
    transform: scale(1.1);
}

.app-icon-box.active {
    color: var(--color-text-primary);
    font-weight: 500;
}

#dwelLogo, .mini-logo { width: 30px; height: 30px; border-radius: var(--radius-logo); border: 1px solid var(--color-border); flex-shrink: 0; overflow: hidden; }

.settings-tabs {
    display: flex;
    flex-direction: column;
    width: 100%;
    align-self: flex-start;
}

.settings-tab {
    padding: 12px 16px;
    font-size: 0.875rem;
    color: var(--color-text-secondary);
    border-bottom: 1px solid var(--color-border);
    cursor: pointer;
    transition: background 0.15s ease;
}

.settings-tab:hover {
    background: var(--color-surface);
    color: var(--color-text-primary);
}

.settings-tab.active {
    color: var(--color-text-primary);
    font-weight: 500;
    background: var(--color-surface);
    border-left: 3px solid var(--color-icon-active);
    padding-left: 13px;
}

.logo-identity {
    display: flex;
    align-items: center;
    gap: 10px;
}

#dwelName {
    font-weight: 600;
}

#localDateTime {
    font-size: 0.875rem;
    color: var(--color-text-secondary);
}

.apps-drawer-row {
    display: flex;
    justify-content: space-around;
    width: 100%;
    align-items: center;
    padding: 8px 0;
}

#dwelLogo img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

#caretToggle {
    color: var(--color-text-primary);
}

/* SVG replacement sizing */
.icon { width: 22px; height: 22px; }

.content { flex-grow: 1; overflow-y: auto; }

.app-panel-content {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    justify-content: flex-start;
    font-size: 0.8rem;
    color: var(--color-text-muted);
}

.workspace-panel-content {
    flex-grow: 1;
    overflow-y: auto;
}

.panel-themes {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100%;
    padding: 16px;
}

.theme-picker {
    display: flex;
    flex-direction: column;
    gap: 12px;
    width: 100%;
    max-width: 320px;
}

.theme-option,
.layout-option {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 12px;
    border: 1px solid var(--color-border);
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.15s ease;
    font-size: 0.875rem;
    color: var(--color-text-primary);
}

.theme-option:hover,
.layout-option:hover {
    background: var(--color-surface);
}

.theme-option.active,
.layout-option.active {
    border-color: var(--color-icon-active);
    font-weight: 500;
}

.theme-picker-label {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--color-text-muted);
    padding: 14px 0 6px;
}

.colour-row {
    display: flex;
    gap: 8px;
}

.colour-option {
    flex: 1;
    padding: 9px;
    text-align: center;
    border: 1px solid var(--color-border);
    border-radius: 8px;
    font-size: 0.875rem;
    cursor: pointer;
    color: var(--color-text-secondary);
    transition: background 0.15s ease;
}

.colour-option:hover { background: var(--color-surface); }

.colour-option.active {
    border-color: var(--color-icon-active);
    color: var(--color-text-primary);
    font-weight: 500;
}

.theme-preview {
    width: 64px;
    height: 44px;
    border-radius: 4px;
    border: 1px solid var(--color-border);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
}

.theme-preview-bar { height: 35%; }
.theme-preview-nav { height: 25%; }
.theme-preview-content { flex-grow: 1; }

.theme-preview-default .theme-preview-bar { background: var(--preview-default-bar); border-bottom: 1px solid var(--preview-default-border); }
.theme-preview-default .theme-preview-nav { background: var(--preview-default-bar); border-bottom: 1px solid var(--preview-default-border); }
.theme-preview-default .theme-preview-content { background: var(--preview-default-surface); }

.theme-preview-dark .theme-preview-bar { background: var(--preview-dark-bar); border-bottom: 1px solid var(--preview-dark-border); }
.theme-preview-dark .theme-preview-nav { background: var(--preview-dark-bar); border-bottom: 1px solid var(--preview-dark-border); }
.theme-preview-dark .theme-preview-content { background: var(--preview-dark-surface); }

/* SECTION FOOTERS */
footer.section-footer {
    height: 34px;
    display: flex;
    align-items: center;
    padding: 0 8px;
    text-align: unset;
    font-weight: unset;
    border-top: 1px solid var(--color-border);
    gap: 8px;
}

.footer-icon {
    cursor: pointer;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.footer-icon img {
    width: 18px;
    height: 18px;
    opacity: var(--icon-opacity-inactive);
    filter: grayscale(100%) var(--icon-filter);
    transition: all 0.2s ease;
}

.footer-icon:hover img {
    opacity: var(--icon-opacity-hover);
    filter: grayscale(0%) var(--icon-filter);
}

.footer-prompt {
    flex: 1;
    font-size: 0.75rem;
    color: var(--color-text-secondary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    text-align: center;
}

/* UPWARD FOOTER DRAWERS */
.footer-drawer {
    position: absolute;
    bottom: 34px;
    left: 0;
    width: 100%;
    background: var(--color-surface);
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
    z-index: 20;
}

.footer-drawer.open {
    max-height: 40vh;
    overflow-y: auto;
    border-top: 1px solid var(--color-border);
}

/* SETTINGS OVERLAY */
.settings-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
}

.settings-overlay.hidden { display: none; }

.settings-canvas {
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: 8px;
    width: min(400px, 90vw);
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.settings-canvas-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    border-bottom: 1px solid var(--color-border);
    flex-shrink: 0;
}

.settings-canvas-title { font-weight: 600; font-size: 0.9rem; }

.settings-cancel-btn {
    background: none;
    border: 1px solid var(--color-border);
    color: var(--color-text-secondary);
    font-size: 0.8rem;
    padding: 4px 10px;
    border-radius: 4px;
    cursor: pointer;
    transition: background 0.15s;
}

.settings-cancel-btn:hover {
    background: var(--color-surface);
    color: var(--color-text-primary);
}

.settings-canvas-body {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    min-height: 120px;
}

.settings-placeholder-label {
    font-size: 0.75rem;
    color: var(--color-text-secondary);
    margin-bottom: 12px;
    font-style: italic;
}

.settings-placeholder-row,
.drawer-placeholder-row {
    padding: 10px 12px;
    font-size: 0.8rem;
    color: var(--color-text-secondary);
    border-bottom: 1px solid var(--color-border);
    cursor: default;
}

/* DESKTOP LAYOUT */
@media (min-width: 768px) and (orientation: landscape) {
    .main-frame {
        display: grid;
        grid-template-columns: 1fr 8px 3fr;
        grid-template-rows: auto 1fr;
        grid-template-areas:
            "nav-panel   resizer   workspace-panel"
            "app-panel   resizer   workspace-panel";
        height: 100vh;
        overflow: hidden;
        padding: 8px;
        row-gap: 8px;
    }
    .sidebar-group      { display: contents; }
    .nav-panel          { grid-area: nav-panel; }
    .app-panel          { grid-area: app-panel; }
    .workspace-panel    { grid-area: workspace-panel; }
    .resizer            { grid-area: resizer; display: block; cursor: col-resize; background: var(--color-resizer); border-left: 1px solid var(--color-border); border-right: 1px solid var(--color-border); }
    .logo-bar           { height: 5vh; }
    .icon-nav-container { height: 5vh; }
    .icon { width: 22px; height: 22px; }
    #dwelSwitcher { top: 5vh; }
    #notifDrawer { top: 5vh; }
    #appsDrawer { top: 10vh; }
}

/* LAYOUT THEME PREVIEWS */
.theme-preview-nav-left,
.theme-preview-panels-right,
.theme-preview-nav-top,
.theme-preview-nav-bottom { display: flex; overflow: hidden; }

.theme-preview-nav-left                  { flex-direction: row; }
.theme-preview-nav-left .tpnl-sidebar    { width: 36%; display: flex; flex-direction: column; background: var(--preview-default-bar); border-right: 1px solid var(--preview-default-border); }
.theme-preview-nav-left .tpnl-top        { height: 42%; background: var(--preview-default-bar); border-bottom: 1px solid var(--preview-default-border); }
.theme-preview-nav-left .tpnl-bottom     { flex: 1; background: var(--preview-default-surface); }
.theme-preview-nav-left .tpnl-workspace  { flex: 1; background: var(--preview-default-surface); }

.theme-preview-panels-right             { flex-direction: row; }
.theme-preview-panels-right .tpr-workspace { flex: 1; background: var(--preview-default-surface); }
.theme-preview-panels-right .tpr-sidebar   { width: 35%; display: flex; flex-direction: column; border-left: 1px solid var(--preview-default-border); }
.theme-preview-panels-right .tpr-nav       { height: 40%; background: var(--preview-default-bar); border-bottom: 1px solid var(--preview-default-border); }
.theme-preview-panels-right .tpr-app       { flex: 1; background: var(--preview-default-surface); }

.theme-preview-nav-top                  { flex-direction: column; }
.theme-preview-nav-top .tpnt-nav        { height: 30%; background: var(--preview-default-bar); border-bottom: 1px solid var(--preview-default-border); }
.theme-preview-nav-top .tpnt-bottom     { flex: 1; display: flex; }
.theme-preview-nav-top .tpnt-app        { width: 35%; background: var(--preview-default-surface); border-right: 1px solid var(--preview-default-border); }
.theme-preview-nav-top .tpnt-workspace  { flex: 1; background: var(--preview-default-surface); }

.theme-preview-nav-bottom                  { flex-direction: column; }
.theme-preview-nav-bottom .tpnb-top        { flex: 1; display: flex; }
.theme-preview-nav-bottom .tpnb-app        { width: 35%; background: var(--preview-default-surface); border-right: 1px solid var(--preview-default-border); }
.theme-preview-nav-bottom .tpnb-workspace  { flex: 1; background: var(--preview-default-surface); }
.theme-preview-nav-bottom .tpnb-nav        { height: 30%; background: var(--preview-default-bar); border-top: 1px solid var(--preview-default-border); }

/* MOBILE: hide side-panel layouts — only nav-top makes sense stacked */
@media (max-width: 767px), (orientation: portrait) {
    .layout-option[data-layout="theme-nav-left"],
    .layout-option[data-layout="theme-nav-right"] { display: none; }
}
