/* Original Android-era Roboto bundled with the project. */
@font-face {
    font-family: 'Roboto Classic';
    src: url('/Roboto-Regular.ttf') format('truetype');
    font-weight: 400;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: 'Roboto Classic';
    src: url('/Roboto-Light.ttf') format('truetype');
    font-weight: 300;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: 'Roboto Classic';
    src: url('/Roboto-Medium.ttf') format('truetype');
    font-weight: 500;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: 'Roboto Classic';
    src: url('/Roboto-Bold.ttf') format('truetype');
    font-weight: 700;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: 'Roboto Classic';
    src: url('/Roboto-Black.ttf') format('truetype');
    font-weight: 900;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: 'Roboto Classic';
    src: url('/Roboto-Italic.ttf') format('truetype');
    font-weight: 400;
    font-style: italic;
    font-display: swap;
}

@font-face {
    font-family: 'Roboto Classic Condensed';
    src: url('/Roboto-Condensed.ttf') format('truetype');
    font-weight: 400;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: 'Roboto Classic Condensed';
    src: url('/Roboto-BoldCondensed.ttf') format('truetype');
    font-weight: 700;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: 'Roboto Classic Condensed';
    src: url('/Roboto-CondensedItalic.ttf') format('truetype');
    font-weight: 400;
    font-style: italic;
    font-display: swap;
}

:root {
    --holo-gray: #9e9e9e;
    --holo-blue: var(--holo-gray);
    --holo-dark: #1a1a1a;
    --status-bar-height: 24px;
    --nav-bar-height: 48px;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
    font-family: 'Roboto Classic', sans-serif;
}

body {
    background: #000;
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
}

#phone-frame {
    position: relative;
    flex: none;
    /* Fit the full 9:16 device into either viewport dimension. */
    width: min(100vw, 56.25vh);
    width: min(100vw, 56.25dvh);
    aspect-ratio: 9 / 16;
    isolation: isolate;
}

.phone-frame-shell {
    position: absolute;
    inset: 0;
    z-index: 0;
    background: url('/port_back.webp') center / 100% 100% no-repeat;
    pointer-events: none;
}

#phone-container {
    position: absolute;
    /* Keep the display at 9:16 inside the responsive device frame. */
    left: 10.5109489%;
    top: 8.1081081%;
    width: 78.8321168%;
    height: 78.8321168%;
    max-width: none;
    max-height: none;
    z-index: 1;
    background: #000;
    overflow: hidden;
    container: phone-screen / size;
    transition: max-width 0.5s ease, max-height 0.5s ease;
}

#phone-container.desktop-mode {
    /* Fully responsive desktop sizing: fill available viewport with padding */
    max-width: none;
    max-height: none;
    width: calc(100vw - 40px) !important;
    height: calc(100vh - 80px) !important;
    max-width: calc(100vw - 40px);
    max-height: calc(100vh - 80px);
}

#screen {
    width: 100%;
    height: 100%;
    background-image: url('/7457202010_da723cdb64 (2).jpg');
    background-size: cover;
    background-position: center;
    display: flex;
    flex-direction: column;
    position: relative;
}

/* Status Bar */
#status-bar {
    height: var(--status-bar-height);
    background: linear-gradient(to bottom, rgba(0, 0, 0, 0.82), rgba(0, 0, 0, 0));
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 8px;
    color: #fff;
    font-size: 12px;
    z-index: 100;
}

.status-right {
    display: flex;
    align-items: center;
    gap: 6px;
}

.status-icons {
    display: flex;
    gap: 4px;
}

.icon-signal, .icon-battery {
    width: 14px;
    height: 14px;
    background: #fff;
    opacity: 0.95;
}

.icon-signal {
    clip-path: polygon(0% 100%, 100% 100%, 100% 0%);
}

.icon-battery {
    width: 8px;
    height: 14px;
    border: 1px solid #fff;
    position: relative;
}

.icon-battery::after {
    content: '';
    position: absolute;
    top: -3px;
    left: 1px;
    width: 4px;
    height: 2px;
    background: #fff;
}

/* Navigation Bar */
#nav-bar {
    height: var(--nav-bar-height);
    background: transparent;
    position: relative;
    z-index: 100;
    overflow: hidden;
}

.kitkat-nav-art {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

.nav-button {
    position: absolute;
    top: 0;
    width: 33.333%;
    height: var(--nav-bar-height);
    padding: 0;
    border: 0;
    background: transparent;
    cursor: pointer;
}

#nav-back { left: 0; }
#nav-home { left: 33.333%; }
#nav-recent { right: 0; }

.nav-button:active {
    background-color: rgba(255, 255, 255, 0.1);
}

/* Main Views */
#main-view {
    flex: 1;
    position: relative;
    overflow: hidden;
}

.view {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: none;
}

.view.active {
    display: flex;
    flex-direction: column;
}

/* Home Screen */
#google-search {
    padding: 15px;
    margin-top: 10px;
}

.search-bar {
    background: rgba(255, 255, 255, 0.15);
    height: 44px;
    border-radius: 2px;
    display: flex;
    align-items: center;
    padding: 0 15px;
    backdrop-filter: blur(5px);
}

.g-logo {
    color: #fff;
    font-weight: bold;
    font-size: 18px;
}

.app-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    grid-gap: 10px;
    padding: 20px;
}

.app-icon {
    display: flex;
    flex-direction: column;
    align-items: center;
    cursor: pointer;
    transition: transform 0.1s;
    user-select: none;
}

.app-icon.dragging {
    opacity: 0.5;
    transform: scale(1.1);
}

.app-icon.drag-over {
    background: rgba(158, 158, 158, 0.2);
    border-radius: 8px;
    box-shadow: 0 0 10px var(--holo-blue);
}

.app-icon img {
    width: 56px;
    height: 56px;
    margin-bottom: 5px;
}

.app-icon span {
    color: #fff;
    font-size: 12px;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.8);
    text-align: center;
}

#dock {
    position: absolute;
    bottom: 0;
    width: 100%;
    padding-bottom: 10px;
}

.dock-inner {
    display: flex;
    justify-content: space-evenly;
    align-items: center;
    background: rgba(0,0,0,0.2);
    padding: 10px 0;
}

#drawer-button img {
    width: 50px;
    height: 50px;
}

#drawer-button:active img {
    content: url('/ic_allapps_pressed.png');
}

/* App Drawer */
#app-drawer {
    background: rgba(0, 0, 0, 0.72);
    backdrop-filter: blur(6px);
    z-index: 50;
}

.drawer-pane {
    display: none;
    flex: 1;
    overflow-y: auto;
}

.drawer-pane.active {
    display: block;
}

.widget-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
    padding: 20px;
}

.widget-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    cursor: grab;
}

.widget-item.dragging {
    opacity: 0.6;
    transform: scale(1.03);
}

.widget-item.drag-over {
    outline: 1px dashed var(--holo-blue);
    border-radius: 4px;
    background: rgba(158, 158, 158, 0.08);
}

.widget-preview {
    width: 100%;
    aspect-ratio: 1.5;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid #333;
    margin-bottom: 8px;
}

.widget-item span {
    color: #aaa;
    font-size: 11px;
}

/* Generic App Window Style */
.app-window {
    background: #000;
    z-index: 60;
}

.app-toolbar {
    height: 50px;
    background: #333;
    display: flex;
    align-items: center;
    padding: 0 10px;
}

.browser-toolbar {
    background: #222;
    border-bottom: 2px solid #333;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0 8px;
}

.browser-nav-btns {
    display: flex;
    color: #888;
    font-size: 24px;
    gap: 10px;
}

.url-bar-container {
    background: #fff;
    flex: 1;
    height: 34px;
    border-radius: 2px;
    display: flex;
    align-items: center;
    padding: 0 8px;
    box-shadow: inset 0 1px 2px rgba(0,0,0,0.2);
}

.url-input {
    border: none;
    background: transparent;
    width: 100%;
    outline: none;
    font-size: 14px;
    color: #333;
}

.browser-refresh {
    width: 16px;
    height: 16px;
    border: 2px solid #666;
    border-top-color: transparent;
    border-radius: 50%;
    margin-left: 5px;
    cursor: pointer;
}

.browser-nav-btns span {
    cursor: pointer;
    padding: 0 4px;
}

.browser-nav-btns span:active {
    color: var(--holo-blue);
}

.browser-tabs-btn {
    width: 28px;
    height: 28px;
    border: 2px solid #888;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #888;
    font-weight: bold;
    font-size: 12px;
}

.app-content {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.virtual-master-content {
    margin: 0;
    padding: 0;
    background: #000;
}

.virtual-master-frame {
    width: 100%;
    height: 100%;
    border: 0;
    background: #000;
}

.placeholder-msg {
    margin: auto;
    color: #555;
}

/* Calculator specific */
#app-calculator {
    background: #111;
}

.calc-display {
    height: 120px;
    background: #222;
    color: #fff;
    display: flex;
    align-items: flex-end;
    justify-content: flex-end;
    padding: 20px;
    font-size: 48px;
    font-weight: 300;
}

.calc-keys {
    flex: 1;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
}

.calc-keys div {
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 24px;
    border: 0.5px solid #222;
}

.calc-keys div.op {
    background: #2c2c2c;
    color: var(--holo-gray);
}

.calc-keys div.eq {
    background: var(--holo-gray);
    color: #fff;
}

/* Market specific */
.market-header {
    background: #222;
    color: #fff;
    padding: 0 15px;
    height: 56px;
    font-weight: 500;
    border-bottom: 2px solid #a4c639;
    text-transform: uppercase;
    letter-spacing: 1px;
    font-size: 14px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.market-header-left {
    display: flex;
    align-items: center;
}

.market-plus-btn {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 30px;
    color: #fff;
    cursor: pointer;
    border-radius: 50%;
    transition: background 0.2s;
}

.market-plus-btn:active {
    background: rgba(255, 255, 255, 0.1);
}

.market-hero {
    height: 150px;
    background: #7cb342;
    margin: 10px;
}

.market-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    padding: 10px;
}

.market-item {
    height: 100px;
    background: #eee;
}

/* Settings specific */
.settings-header {
    background: #333;
    color: #fff;
    padding: 15px;
    font-size: 18px;
}

.settings-list {
    padding: 0;
    /* make the settings list fill available space and scroll when content overflows */
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.settings-item {
    padding: 15px 20px;
    color: #ccc;
    border-bottom: 1px solid #222;
}

.settings-link {
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
}

.settings-link:focus-visible,
.ringtone-option:focus-visible {
    outline: 2px solid var(--holo-blue);
    outline-offset: -2px;
}

.setting-summary {
    color: #888;
    font-size: 14px;
}

.sound-toggle-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
}

.sound-toggle-row input {
    appearance: none;
    width: 42px;
    height: 20px;
    border: 0;
    border-radius: 12px;
    background: #444;
    cursor: pointer;
    position: relative;
    transition: background 0.16s ease;
}

.sound-toggle-row input::after {
    content: '';
    position: absolute;
    top: 3px;
    left: 3px;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: #ddd;
    transition: transform 0.16s ease;
}

.sound-toggle-row input:checked {
    background: var(--holo-blue);
}

.sound-toggle-row input:checked::after {
    transform: translateX(22px);
}

.ringtone-option {
    width: 100%;
    min-height: 52px;
    padding: 0 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border: 0;
    border-bottom: 1px solid #222;
    background: transparent;
    color: #ccc;
    font: inherit;
    text-align: left;
    cursor: pointer;
}

.ringtone-option.selected {
    color: #fff;
    background: rgba(51, 181, 229, 0.12);
}

.ringtone-check {
    color: var(--holo-blue);
    font-size: 19px;
    opacity: 0;
}

.ringtone-option.selected .ringtone-check {
    opacity: 1;
}

.settings-divider {
    background: #222;
    color: var(--holo-blue);
    padding: 5px 20px;
    font-size: 12px;
    font-weight: bold;
}

/* Clock App */
#app-clock { background: #000; color: #fff; }
.clock-app-view {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding-top: 60px;
}
.clock-big-time { font-size: 72px; font-weight: 300; }
.clock-date { font-size: 14px; color: var(--holo-blue); letter-spacing: 2px; margin-bottom: 40px; }
.alarm-list { width: 100%; padding: 0 20px; }
.alarm-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 0;
    border-bottom: 1px solid #222;
}
.toggle-on, .toggle-off {
    width: 40px;
    height: 15px;
    border-radius: 10px;
    position: relative;
}
.toggle-on { background: var(--holo-blue); }
.toggle-on::after { content: ''; position: absolute; right: 0; top: -5px; width: 25px; height: 25px; background: #fff; border-radius: 50%; }
.toggle-off { background: #333; }
.toggle-off::after { content: ''; position: absolute; left: 0; top: -5px; width: 25px; height: 25px; background: #666; border-radius: 50%; }

/* Maps App */
#app-maps { background: #eee; }
#map-container { flex: 1; width: 100%; height: 100%; }
.map-search-overlay {
    position: absolute;
    top: 10px;
    left: 10px;
    right: 10px;
    z-index: 1000;
}
.map-search-overlay input {
    width: 100%;
    height: 44px;
    border: none;
    border-radius: 2px;
    padding: 0 15px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
    font-size: 16px;
}

/* AI Creator App */
#app-ai-creator { background: #f1f1f1; }
.ai-creator-content { padding: 20px; color: #333; }
.ai-hero h3 { color: #7cb342; font-weight: 300; font-size: 24px; margin-bottom: 10px; }
.ai-hero p { color: #666; font-size: 14px; margin-bottom: 30px; }
.ai-input-area { display: flex; flex-direction: column; gap: 15px; }
#ai-prompt-input {
    background: #fff;
    border: 1px solid #ccc;
    border-radius: 4px;
    color: #333;
    padding: 15px;
    height: 120px;
    font-size: 16px;
    resize: none;
    outline: none;
    box-shadow: inset 0 1px 3px rgba(0,0,0,0.1);
}
#ai-prompt-input:focus { border-color: #a4c639; }
#ai-generate-btn {
    background: #a4c639;
    color: #fff;
    border: none;
    padding: 15px;
    font-weight: bold;
    font-size: 14px;
    border-radius: 2px;
    cursor: pointer;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}
.ai-status { margin-top: 20px; font-size: 14px; color: #aaa; text-align: center; font-style: italic; }

.generated-toolbar {
    background: #000;
    border-bottom: 1px solid #333;
    display: flex;
    align-items: center;
    gap: 15px;
}
.back-to-home-btn {
    font-size: 24px;
    color: #888;
    cursor: pointer;
    padding: 0 10px;
}
.generated-app-title { font-weight: 400; color: #fff; flex: 1; }

/* Music App */
#app-music { background: #111; }
.music-header { background: #222; }
.music-tabs { display: flex; padding: 0 20px; }
.music-tabs span {
    padding: 15px;
    color: #888;
    font-size: 13px;
    font-weight: bold;
    cursor: pointer;
}
.music-tabs span.active { color: var(--holo-blue); border-bottom: 2px solid var(--holo-blue); }
.music-list { padding: 10px; }
.song-item {
    display: flex;
    align-items: center;
    padding: 12px;
    border-bottom: 1px solid #222;
}
.song-art { width: 48px; height: 48px; background: #333; margin-right: 15px; border-radius: 2px; }
.song-title { color: #fff; font-size: 15px; }
.song-artist { color: #888; font-size: 12px; }

/* Camera App */
.camera-ui {
    flex: 1;
    background: #000;
    display: flex;
    flex-direction: column;
}

.camera-preview-container {
    flex: 1;
    position: relative;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

#camera-video, #camera-last-shot {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.camera-controls {
    height: 100px;
    background: rgba(0,0,0,0.8);
    display: flex;
    align-items: center;
    justify-content: space-around;
    padding: 0 20px;
}

.camera-thumb-preview {
    width: 50px;
    height: 50px;
    background: #222;
    border: 2px solid #fff;
    border-radius: 2px;
    background-size: cover;
}

#camera-shutter {
    width: 70px;
    height: 70px;
    border: 4px solid #fff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.shutter-inner {
    width: 50px;
    height: 50px;
    background: #fff;
    border-radius: 50%;
}

#camera-shutter:active .shutter-inner {
    transform: scale(0.9);
    background: var(--holo-blue);
}

.camera-mode-toggle {
    font-size: 24px;
    color: #fff;
}

/* Email App */
.email-toolbar {
    justify-content: space-between;
}

.email-action-btn {
    font-size: 28px;
    color: var(--holo-blue);
    cursor: pointer;
    padding: 0 10px;
}

.email-view-container {
    flex: 1;
    position: relative;
    background: #fff;
}

.email-list {
    height: 100%;
    overflow-y: auto;
}

.email-item {
    padding: 15px;
    border-bottom: 1px solid #eee;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.email-item-header {
    display: flex;
    justify-content: space-between;
    font-size: 14px;
}

.email-item-from {
    font-weight: bold;
    color: #333;
}

.email-item-time {
    color: #999;
    font-size: 11px;
}

.email-item-body {
    color: #666;
    font-size: 13px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.email-compose-view {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: #fff;
    z-index: 10;
    display: flex;
    flex-direction: column;
    padding: 15px;
}

.compose-header {
    display: flex;
    align-items: center;
    border-bottom: 1px solid #eee;
    margin-bottom: 15px;
}

#email-to-input {
    flex: 1;
    border: none;
    padding: 10px 0;
    font-size: 16px;
    outline: none;
}

.compose-header {
    position: relative;
}

.email-autocomplete-list {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: #fff;
    border: 1px solid #ddd;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    z-index: 100;
    display: none;
    max-height: 200px;
    overflow-y: auto;
}

.autocomplete-item {
    padding: 10px 15px;
    border-bottom: 1px solid #eee;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 14px;
    color: #333;
}

.autocomplete-item:last-child {
    border-bottom: none;
}

.autocomplete-item:hover {
    background: #f0f7ff;
}

.autocomplete-avatar {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: #ccc;
}

#email-select-user-btn {
    padding: 10px;
    color: var(--holo-blue);
    font-size: 24px;
    cursor: pointer;
}

#email-body-input {
    flex: 1;
    border: none;
    resize: none;
    font-size: 16px;
    outline: none;
}

.compose-footer {
    display: flex;
    gap: 10px;
    padding-top: 10px;
}

.compose-footer button {
    flex: 1;
    padding: 12px;
    border: none;
    font-weight: bold;
    border-radius: 2px;
    cursor: pointer;
}

#email-send-btn { background: var(--holo-blue); color: #fff; }
#email-cancel-btn { background: #eee; color: #666; }

.email-user-picker {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.9);
    z-index: 20;
    color: #fff;
    display: flex;
    flex-direction: column;
    padding: 20px;
}

.picker-header {
    font-size: 18px;
    margin-bottom: 20px;
    color: var(--holo-blue);
}

.picker-list {
    flex: 1;
    overflow-y: auto;
}

.picker-user-item {
    padding: 15px;
    border-bottom: 1px solid #333;
    display: flex;
    align-items: center;
    gap: 12px;
}

.picker-user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: #444;
}

#close-picker-btn {
    margin-top: 10px;
    padding: 10px;
    background: #333;
    border: none;
    color: #fff;
}

/* Desktop Mode Styles */
.desktop-mode #nav-bar, .desktop-mode #status-bar {
    display: none !important;
}

/* TV Mode: fullscreen, large UI for viewing from a distance */
.tv-mode #phone-container, .tv-mode #screen, body.tv-mode #phone-container {
    width: 100vw !important;
    height: 100vh !important;
    max-width: 100vw !important;
    max-height: 100vh !important;
    border-radius: 0 !important;
}
.tv-mode .app-title, .tv-mode .market-header-left div, .tv-mode .now-playing-title {
    font-size: 1.6rem !important;
}
.tv-mode .app-content { font-size: 1.05rem; }

/* Laptop Mode: desktop-focused layout but optimized slightly for laptop proportions
   Navigation mirrors tablet/desktop style: hide mobile nav/status, hide bottom dock,
   and show desktop taskbar so laptop mode uses tablet-like navigation. */
.laptop-mode #phone-container {
    width: 90vw !important;
    height: 80vh !important;
    max-width: none !important;
    max-height: none !important;
    border-radius: 8px !important;
}

/* Hide mobile chrome and bottom dock to match tablet-style navigation */
.laptop-mode #nav-bar,
.laptop-mode #status-bar {
    display: none !important;
}

/* Hide the mobile dock and ensure desktop taskbar is visible */
.laptop-mode #dock {
    display: none !important;
}
.laptop-mode #desktop-taskbar {
    display: flex !important;
}

/* In laptop mode prefer tablet/phone-style navigation: apps open full-screen (non-windowed).
   Override windowed styling so .app-window behaves like a regular full app pane instead of a movable window. */
.laptop-mode .app-window {
    position: relative !important;
    top: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: calc(100% - 0px) !important;
    min-width: unset;
    min-height: unset;
    max-width: 100%;
    max-height: 100%;
    display: none; /* controlled by .active below */
    flex-direction: column;
    box-shadow: none;
    border: none;
    border-radius: 0;
    overflow: hidden;
    transform: none !important;
    opacity: 1 !important;
}

/* When an app-window is activated in laptop-mode, present it full-screen (like phone/tablet apps) */
.laptop-mode .app-window.active {
    display: flex !important;
    z-index: 500;
}

/* Ensure the app-drawer is also a positioned window/panel in laptop mode (not full-screen) */
.laptop-mode #app-drawer {
    position: absolute;
    bottom: 48px;
    left: 0;
    width: 320px;
    height: 400px;
    z-index: 2000;
    border-top-right-radius: 8px;
    box-shadow: 0 0 20px rgba(0,0,0,0.5);
    border: 1px solid #333;
    transform: translateY(10px);
    opacity: 0;
    display: none;
}

/* When active, drawer should behave like desktop-mode panel */
.laptop-mode #app-drawer.active {
    display: flex;
    opacity: 1;
    transform: translateY(0);
}

/* In laptop and desktop modes swap BACK and HOME icon positions so the layout shows HOME where BACK used to be.
   This affects both the bottom navigation buttons and the desktop taskbar icons to keep behavior consistent. */
.laptop-mode #nav-back { background-position: center; }
.laptop-mode #nav-home { background-position: left; }
.laptop-mode #nav-recent { background-position: right; }

.laptop-mode #taskbar-back { background-position: center; }
.laptop-mode #taskbar-home { background-position: left; }
.laptop-mode #taskbar-recent { background-position: right; }

/* Apply same swap for full desktop-mode so taskbar / nav icons remain consistent when using desktop UI */
.desktop-mode #nav-back { background-position: center; }
.desktop-mode #nav-home { background-position: left; }
.desktop-mode #nav-recent { background-position: right; }

.desktop-mode #taskbar-back { background-position: center; }
.desktop-mode #taskbar-home { background-position: left; }
.desktop-mode #taskbar-recent { background-position: right; }

/* Flip Phone Mode: tall narrow form factor with compact chrome */
.flip-mode #phone-container {
    width: 360px !important;
    height: 760px !important;
    max-width: 360px !important;
    max-height: 760px !important;
    border-radius: 18px !important;
    transform-origin: center top;
    box-shadow: 0 18px 48px rgba(0,0,0,0.5);
}
.flip-mode #dock { display: none !important; }
.flip-mode .nav-button { width: 44px; height: var(--nav-bar-height); }

/* Small visual hinge cue for flip-mode (non-interactive) */
.flip-mode #screen::after {
    content: '';
    position: absolute;
    left: 50%;
    top: 6px;
    transform: translateX(-50%);
    width: 56px;
    height: 6px;
    background: linear-gradient(90deg, rgba(255,255,255,0.04), rgba(255,255,255,0.02));
    border-radius: 6px;
    pointer-events: none;
}

.desktop-mode #home-screen {
    display: flex !important;
    opacity: 1 !important;
    transform: none !important;
    pointer-events: auto !important;
    z-index: 5;
}

.desktop-mode #app-drawer {
    position: absolute !important;
    bottom: 48px;
    left: 0;
    width: 320px;
    height: 400px;
    z-index: 2000;
    border-top-right-radius: 8px;
    box-shadow: 0 0 20px rgba(0,0,0,0.5);
    border: 1px solid #333;
    transform: translateY(10px);
    opacity: 0;
    display: none;
}

/* Hide the bottom dock when in desktop (horizontal) mode so its apps are shown on the taskbar instead */
.desktop-mode #dock {
    display: none !important;
}

.desktop-mode #app-drawer.active {
    display: flex;
    opacity: 1;
    transform: translateY(0);
}

#desktop-taskbar {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 48px;
    background: #000;
    border-top: 1px solid #333;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 10px;
    z-index: 1000;
}

.taskbar-left, .taskbar-right {
    display: flex;
    align-items: center;
    gap: 15px;
}

.taskbar-center {
    flex: 1;
    display: flex;
    justify-content: center;
    gap: 10px;
    overflow-x: auto;
}

.taskbar-icon {
    width: 32px;
    height: 32px;
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    opacity: 0.8;
}

#taskbar-back { background-image: url('/images.png'); background-size: 300%; background-position: left; }
#taskbar-home { background-image: url('/images.png'); background-size: 300%; background-position: center; }
#taskbar-recent { background-image: url('/images.png'); background-size: 300%; background-position: right; }
#taskbar-drawer { background-image: url('/Drawer.png'); background-size: contain; }

.taskbar-app-item {
    width: 36px;
    height: 36px;
    padding: 4px;
    border-bottom: 2px solid transparent;
}

.taskbar-app-item.active {
    border-bottom-color: var(--holo-blue);
    background: rgba(158, 158, 158, 0.1);
}

.taskbar-app-item img {
    width: 100%;
    height: 100%;
}

.taskbar-status {
    display: flex;
    align-items: center;
    gap: 8px;
    color: #fff;
    font-size: 14px;
}

/* Windowed App Styles */
.desktop-mode .app-window {
    position: absolute !important;
    top: 40px;
    left: 20px;
    /* Responsive windowed app size for desktop: scale with container */
    width: calc(48% - 40px);
    height: calc(68% - 60px);
    min-width: 360px;
    min-height: 320px;
    max-width: calc(100% - 40px);
    max-height: calc(100% - 100px);
    display: none; /* Controlled by script */
    flex-direction: column;
    box-shadow: 0 12px 36px rgba(0,0,0,0.55);
    border: 1px solid #444;
    border-radius: 6px;
    overflow: hidden;
    transform: none !important;
    opacity: 1 !important;
}

.desktop-mode .app-window.active {
    display: flex;
    z-index: 500;
}

.window-title-bar {
    height: 36px;
    background: #222;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 10px;
    cursor: move;
    user-select: none;
    border-bottom: 1px solid #333;
}

.window-title {
    color: #eee;
    font-size: 13px;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Resize handles for desktop windowed apps */
.resize-handle {
    position: absolute;
    width: 12px;
    height: 12px;
    background: transparent;
    z-index: 9999;
    opacity: 0.8;
    filter: drop-shadow(0 1px 1px rgba(0,0,0,0.6));
}
.resize-handle.resize-se {
    right: 6px;
    bottom: 6px;
    cursor: se-resize;
    border-radius: 2px;
    box-shadow: inset 0 0 0 2px rgba(255,255,255,0.06);
}
.resize-handle.resize-e {
    right: 6px;
    bottom: 50%;
    transform: translateY(50%);
    width: 10px;
    height: 28px;
    cursor: e-resize;
}
.resize-handle.resize-s {
    bottom: 6px;
    left: 50%;
    transform: translateX(-50%);
    width: 28px;
    height: 10px;
    cursor: s-resize;
}

.window-title img {
    width: 18px;
    height: 18px;
}

/* Window control buttons styling */
.window-controls .window-btn {
    width: 26px;
    height: 22px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #888;
    font-size: 14px;
    cursor: pointer;
    margin-left: 6px;
    border-radius: 3px;
}
.window-controls .window-btn:hover { background: rgba(255,255,255,0.02); color: #fff; }

/* Minimized window state: hidden from view but stays on taskbar */
.desktop-mode .app-window.minimized {
    display: none !important;
}

/* Maximized window fills most of container while remaining a window */
.desktop-mode .app-window.maximized {
    top: 10px !important;
    left: 10px !important;
    width: calc(100% - 20px) !important;
    height: calc(100% - 80px) !important;
    min-width: unset;
    min-height: unset;
}

/* Fullscreen container state: hide the taskbar and expand fullscreen window */
.desktop-mode.window-fullscreen #desktop-taskbar {
    display: none !important;
}

/* App window in fullscreen state */
.desktop-mode .app-window.fullscreen {
    top: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: 100% !important;
    border-radius: 0 !important;
    box-shadow: none !important;
}

/* Make sure fullscreen window appears above everything */
.desktop-mode .app-window.fullscreen {
    z-index: 9999 !important;
}

.window-controls {
    display: flex;
    gap: 10px;
}

.window-btn {
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #888;
    font-size: 18px;
    cursor: pointer;
}

.window-btn:hover {
    color: #fff;
}

.window-close:hover {
    color: #ff4444;
}

/* Overlay View (Recents) */
.overlay-view {
    background: rgba(0, 0, 0, 0.7);
    z-index: 200;
    backdrop-filter: blur(2px);
}

.recent-apps-list {
    display: flex;
    flex-direction: column;
    padding: 20px;
    gap: 15px;
    overflow-y: auto;
    height: 100%;
}

.recent-app-card {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    animation: slideInRecent 0.3s cubic-bezier(0.1, 0.9, 0.2, 1);
}

.recent-app-thumb {
    width: 180px;
    height: 110px;
    background: #111;
    border: 1px solid #444;
    border-radius: 2px;
    box-shadow: 0 4px 10px rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
}

.recent-app-label {
    display: flex;
    align-items: center;
    gap: 8px;
    color: #fff;
    font-size: 14px;
}

.recent-app-label img {
    width: 24px;
    height: 24px;
}

@keyframes slideInRecent {
    from { transform: translateX(-50px); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

/* Animations & Transitions */
.view {
    transition: transform 0.25s cubic-bezier(0.4, 0.0, 0.2, 1), opacity 0.25s ease;
    transform: scale(0.9);
    opacity: 0;
    pointer-events: none;
}

.view.active {
    opacity: 1;
    transform: scale(1);
    pointer-events: auto;
}

/* Home Screen is special, no zoom when active by default */
#home-screen.view {
    transform: scale(1);
    opacity: 1;
    pointer-events: auto;
    transition: transform 0.32s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.25s ease;
}

#home-screen.view:not(.active) {
    transform: scale(0.82);
    opacity: 0.3;
    filter: saturate(0.6);
    pointer-events: none;
}

/* Drawer zooms out (big -> small) and fades in on open */
#app-drawer {
    transform: scale(1.22);
    opacity: 0;
    background: rgba(0,0,0,0.72);
    backdrop-filter: blur(10px);
    transition: transform 0.32s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.25s ease;
}

#app-drawer.active {
    transform: scale(1);
    opacity: 1;
}

/* On close the drawer zooms in (small -> big) and fades out */
#app-drawer.active.closing {
    transform: scale(1.16);
    opacity: 0;
}

/* Closing animation */
.view.closing {
    transform: scale(0.85);
    opacity: 0;
}

/* Multitasking view specifics */
#recent-apps-view {
    transform: scale(1.05);
    background: rgba(0,0,0,0.8);
    backdrop-filter: blur(4px);
}

#recent-apps-view.active {
    transform: scale(1);
}

/* Market Improvements */
.market-scrollable {
    overflow-y: auto;
    background: #f1f1f1;
}

.market-hero {
    background: linear-gradient(135deg, #a4c639, #7cb342);
    color: white;
    padding: 30px 20px;
    font-size: 24px;
    font-weight: 300;
}

.market-list {
    padding: 10px;
}

.market-app-item {
    display: flex;
    align-items: center;
    background: white;
    padding: 12px;
    margin-bottom: 2px;
    box-shadow: 0 1px 2px rgba(0,0,0,0.1);
}

.market-app-item img {
    width: 48px;
    height: 48px;
    margin-right: 15px;
}

.market-app-info {
    flex: 1;
}

.market-app-name {
    font-weight: 500;
    color: #333;
    font-size: 15px;
}

.market-app-desc {
    font-size: 12px;
    color: #888;
}

.install-btn {
    background: #a4c639;
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 2px;
    font-size: 12px;
    font-weight: bold;
    cursor: pointer;
}

.install-btn.installed {
    background: #eee;
    color: #999;
}

/* Recent App Card Swiping */
.recent-app-card {
    transition: transform 0.2s ease, opacity 0.2s ease;
    cursor: grab;
}

.recent-app-card:active {
    cursor: grabbing;
}

.swipe-hint {
    font-size: 10px;
    color: #444;
    text-transform: uppercase;
    letter-spacing: 1px;
    opacity: 0.5;
}

/* Folder Styles */
.folder-icon {
    width: 56px;
    height: 56px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 4px;
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    padding: 4px;
    gap: 2px;
}

.folder-icon img {
    width: 100% !important;
    height: 100% !important;
    margin: 0 !important;
}

.folder-view-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.8);
    z-index: 150;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s;
}

.folder-view-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

.folder-container {
    background: #222;
    border: 1px solid #444;
    width: 80%;
    border-radius: 4px;
    padding: 20px;
}

.folder-title {
    color: var(--holo-blue);
    font-size: 18px;
    margin-bottom: 20px;
    border-bottom: 1px solid #333;
    padding-bottom: 10px;
}

.folder-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 15px;
}

/* New Apps Styles */
.app-title {
    color: #fff;
    font-size: 18px;
    font-weight: 400;
}

/* Icon gravity & drag styles
   When the grid has .gravity-enabled, icons become positioned elements
   that can fall and be dragged. */
#home-grid.gravity-enabled, #drawer-grid.gravity-enabled {
    position: relative;
    min-height: 220px; /* ensure space for absolute icons */
}
#home-grid.gravity-enabled .app-icon, #drawer-grid.gravity-enabled .app-icon {
    position: absolute;
    width: 72px;
    text-align: center;
    margin: 0;
    transition: transform 120ms linear;
    touch-action: none;
    will-change: transform, left, top;
    user-select: none;
}
#home-grid.gravity-enabled .app-icon img, #drawer-grid.gravity-enabled .app-icon img {
    width: 56px;
    height: 56px;
    margin-bottom: 6px;
}
#home-grid.gravity-enabled .app-icon span, #drawer-grid.gravity-enabled .app-icon span {
    display: block;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    width: 72px;
    font-size: 11px;
}

/* Visual while dragging */
.app-icon.dragging-pointer {
    transform: scale(1.08) !important;
    z-index: 9999 !important;
    box-shadow: 0 18px 32px rgba(0,0,0,0.45);
    transition: transform 60ms linear;
}

.dialer-view {
    padding: 20px;
    display: flex;
    flex-direction: column;
    height: 100%;
}

.dialer-display {
    height: 60px;
    background: #111;
    border-bottom: 2px solid #333;
    margin-bottom: 20px;
    color: #fff;
    font-size: 32px;
    display: flex;
    align-items: center;
    padding: 0 10px;
}

.dialer-pad {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1px;
    background: #333;
}

.dialer-pad div {
    height: 70px;
    background: #000;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
}

.dial-btn-container {
    margin-top: auto;
    display: flex;
    justify-content: center;
    padding: 20px;
}

.dial-btn {
    width: 60px;
    height: 60px;
    background: #a4c639;
    border-radius: 50%;
    position: relative;
}

.dial-btn::after {
    content: '📞';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 24px;
}

.people-list, .msg-list {
    flex: 1;
    overflow-y: auto;
}

.people-item, .msg-item {
    display: flex;
    padding: 15px;
    border-bottom: 1px solid #222;
    align-items: center;
}

.people-avatar, .msg-avatar {
    width: 40px;
    height: 40px;
    background: var(--holo-gray);
    margin-right: 15px;
}

.people-name, .msg-name {
    color: #fff;
    font-size: 16px;
}

.msg-text {
    color: #888;
    font-size: 14px;
}

/* Movie Studio App */
#app-movie-studio {
    background: #111;
}

.movie-studio-toolbar {
    background: #222;
    border-bottom: 1px solid #333;
    justify-content: space-between;
}

#movie-export-btn {
    background: var(--holo-gray);
    color: white;
    border: none;
    padding: 6px 12px;
    font-size: 12px;
    font-weight: bold;
    border-radius: 2px;
    cursor: pointer;
}

.movie-studio-editor {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.movie-preview-area {
    flex: 1;
    background: #000;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: relative;
    border-bottom: 2px solid #222;
}

#movie-viewer {
    width: 90%;
    aspect-ratio: 16/9;
    background: #0a0a0a;
    border: 1px solid #333;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.movie-viewer-placeholder {
    color: #444;
    font-size: 14px;
    text-transform: uppercase;
}

.movie-playback-controls {
    padding: 10px;
}

#movie-play-pause {
    background: transparent;
    color: var(--holo-gray);
    border: 1px solid var(--holo-gray);
    width: 40px;
    height: 40px;
    border-radius: 50%;
    font-size: 18px;
    cursor: pointer;
}

.movie-timeline {
    height: 200px;
    background: #1a1a1a;
    display: flex;
    flex-direction: column;
    border-top: 1px solid #333;
}

.timeline-ruler {
    height: 20px;
    background: #222;
    border-bottom: 1px solid #333;
}

.timeline-tracks {
    flex: 1;
    overflow-x: auto;
    overflow-y: hidden;
    display: flex;
    flex-direction: column;
}

.timeline-track {
    display: flex;
    height: 60px;
    border-bottom: 1px solid #222;
    align-items: center;
}

.track-label {
    width: 50px;
    font-size: 10px;
    color: #666;
    padding-left: 5px;
    flex-shrink: 0;
}

.track-content {
    flex: 1;
    display: flex;
    gap: 2px;
    padding: 5px;
    min-width: 1000px;
}

.movie-clip {
    height: 50px;
    width: 80px;
    background: #333;
    border: 1px solid #444;
    border-radius: 2px;
    position: relative;
    overflow: hidden;
    flex-shrink: 0;
}

.movie-clip img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.movie-clip-close {
    position: absolute;
    top: 2px;
    right: 2px;
    background: rgba(255,0,0,0.7);
    color: white;
    font-size: 8px;
    width: 12px;
    height: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    cursor: pointer;
}

.audio-clip-placeholder {
    height: 30px;
    background: var(--holo-gray);
    opacity: 0.3;
    border-radius: 2px;
    width: 300px;
    font-size: 10px;
    color: #fff;
    display: flex;
    align-items: center;
    padding-left: 10px;
}

.movie-add-controls {
    padding: 10px;
    background: #111;
    display: flex;
    justify-content: center;
}

#movie-add-media-btn {
    background: #222;
    color: var(--holo-gray);
    border: 1px solid var(--holo-gray);
    padding: 8px 20px;
    border-radius: 2px;
    font-size: 12px;
    font-weight: bold;
    cursor: pointer;
}

#movie-add-media-btn:active {
    background: var(--holo-gray);
    color: white;
}

/* Gallery App */
.gallery-content { padding: 10px; display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.gallery-album { background: #1a1a1a; border: 1px solid #333; }
.album-thumb { height: 120px; background: var(--holo-gray); }
.album-info { padding: 8px; }
.album-name { color: #fff; font-size: 14px; }
.album-count { color: #888; font-size: 12px; }

/* Music Player */
.music-player-ui { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 20px; }
.now-playing-art { width: 200px; height: 200px; background: #222; border: 4px solid #333; margin-bottom: 30px; }
.now-playing-info { text-align: center; margin-bottom: 40px; }
.now-playing-title { color: #fff; font-size: 20px; margin-bottom: 5px; }
.now-playing-artist { color: var(--holo-blue); font-size: 14px; }
.music-controls { display: flex; gap: 30px; align-items: center; }
.music-controls button { background: none; border: none; color: #fff; font-size: 24px; cursor: pointer; }
.music-controls .play-main { font-size: 48px; color: var(--holo-blue); }

/* Books */
.books-shelf { padding: 20px; display: grid; grid-template-columns: repeat(3, 1fr); gap: 15px; }
.book-item { text-align: center; }
.book-cover { height: 120px; margin-bottom: 5px; box-shadow: 2px 2px 5px rgba(0,0,0,0.5); }

/* Downloads */
.downloads-list { flex: 1; display: flex; align-items: center; justify-content: center; }
.empty-downloads { color: #444; font-size: 14px; }

/* YouTube Android 4.0 Style */
#app-youtube { background: #e2e2e2; }
.yt-header { background: #fdfdfd; height: 48px; display: flex; align-items: center; justify-content: space-between; padding: 0 12px; border-bottom: 1px solid #ccc; }
.yt-logo { font-weight: bold; font-size: 18px; color: #333; letter-spacing: -1px; }
.yt-logo::before { content: ''; display: inline-block; width: 24px; height: 16px; background: #cc0000; vertical-align: middle; margin-right: 4px; border-radius: 4px; }
.yt-tabs { background: #f3f3f3; height: 40px; display: flex; border-bottom: 2px solid #ccc; }
.yt-tab { flex: 1; display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: bold; color: #666; cursor: pointer; }
.yt-tab.active { color: #cc0000; border-bottom: 3px solid #cc0000; }
.yt-content { flex: 1; overflow-y: auto; padding: 8px; }
.yt-video-card { background: #fff; border: 1px solid #ccc; margin-bottom: 8px; }
.yt-thumb { height: 180px; background: #000; position: relative; }
.yt-thumb video { width: 100%; height: 100%; display: block; object-fit: cover; }
.yt-video-duration-menu { position: absolute; right: 5px; bottom: 5px; z-index: 2; }
.yt-duration { display: block; padding: 2px 4px; border: 0; background: rgba(0,0,0,.78); color: #fff; font: inherit; font-size: 11px; font-weight: 700; line-height: 1; cursor: pointer; }
.yt-duration-popover { position: absolute; right: 0; bottom: 25px; width: 154px; padding: 8px; background: rgba(0,0,0,.9); box-shadow: 0 1px 3px rgba(0,0,0,.45); }
.yt-duration-popover label { display: block; color: #ddd; font-size: 9px; font-weight: 700; white-space: nowrap; }
.yt-duration-input-row { display: flex; align-items: center; gap: 5px; margin-top: 5px; color: #bbb; font-size: 9px; font-weight: 700; }
.yt-duration-input-row input { width: 62px; height: 20px; padding: 1px 3px; border: 1px solid #777; border-radius: 0; background: #fff; color: #111; font-size: 12px; }
.yt-info { padding: 8px; }
.yt-title { font-size: 14px; color: #333; font-weight: 500; margin-bottom: 4px; }
.yt-meta { font-size: 11px; color: #888; }
.yt-channel { display: flex; align-items: center; gap: 5px; margin-bottom: 3px; font-size: 11px; color: #555; }
.yt-channel img { width: 16px; height: 16px; object-fit: cover; }
.yt-description { margin: 7px 0 0; color: #666; font-size: 11px; line-height: 1.35; }

/* Export Modal */
.export-container { width: 90%; max-width: 400px; background: #222; border-radius: 4px; border: 1px solid #444; display: flex; flex-direction: column; overflow: hidden; }
.export-header { background: #333; padding: 15px; color: #fff; font-size: 18px; }
#export-player-root { width: 100%; aspect-ratio: 16/9; background: #000; }
.export-footer { padding: 10px; display: flex; justify-content: flex-end; border-top: 1px solid #333; }
#close-export-btn { background: var(--holo-blue); color: #fff; border: none; padding: 8px 16px; border-radius: 2px; cursor: pointer; }

/* Devil Store Modal */
.devil-modal {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0,0,0,0.6);
    z-index: 400;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.18s ease, transform 0.18s ease;
    transform: translateY(6px);
}

.devil-modal.active {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0);
}

.devil-modal-content {
    width: 86%;
    max-width: 360px;
    background: #111;
    border: 1px solid #333;
    border-radius: 6px;
    padding: 18px;
    color: #fff;
    box-shadow: 0 20px 40px rgba(0,0,0,0.6);
    display: flex;
    flex-direction: column;
    gap: 12px;
    text-align: center;
}

.devil-modal-header {
    display: flex;
    align-items: center;
    gap: 12px;
    justify-content: center;
}

.devil-modal-header img {
    width: 42px;
    height: 42px;
    border-radius: 6px;
}

.devil-modal-header h2 {
    font-size: 18px;
    margin: 0;
    color: #ff6666;
    letter-spacing: 0.5px;
}

.devil-modal-body {
    color: #ccc;
    font-size: 14px;
    margin: 0 6px 6px 6px;
}

.devil-modal-actions {
    display: flex;
    gap: 10px;
    justify-content: center;
    margin-top: 6px;
}

.devil-btn {
    padding: 10px 14px;
    border-radius: 4px;
    border: 1px solid #444;
    background: #1a1a1a;
    color: #ddd;
    cursor: pointer;
    font-weight: 600;
}

.devil-btn.primary {
    background: #ff4444;
    color: #fff;
    border-color: #ff4444;
}

.devil-btn:active { transform: translateY(1px); }

/* Red screen fade overlay used for special dialer code */
#red-overlay {
    position: absolute;
    inset: 0;
    background: rgba(255,0,0,0); /* starts transparent */
    transition: background 6s linear;
    pointer-events: none;
    z-index: 10000;
}

/* Smartwatch Mode Styles */
.watch-mode #phone-container,
.watch-mode #screen {
    border-radius: 50%;
    overflow: hidden;
}

/* Watch-mode close button - centered-top on circular face */
#watch-close-btn {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(0,0,0,0.6);
    color: #fff;
    border: 1px solid rgba(255,255,255,0.08);
    display: none; /* hidden by default; only shown in watch-mode */
    align-items: center;
    justify-content: center;
    z-index: 11000;
    font-size: 18px;
    cursor: pointer;
    box-shadow: 0 6px 18px rgba(0,0,0,0.6);
}

/* Watch-mode recents button (center-top) */
#watch-recents-btn {
    position: absolute;
    top: 12px;
    left: 50%;
    transform: translateX(-50%);
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(0,0,0,0.6);
    color: #fff;
    border: 1px solid rgba(255,255,255,0.08);
    display: none; /* shown only in watch-mode by script or via .watch-mode */
    align-items: center;
    justify-content: center;
    z-index: 11000;
    font-size: 18px;
    cursor: pointer;
    box-shadow: 0 6px 18px rgba(0,0,0,0.6);
}

/* Watch-mode apps overlay (circular-friendly grid) */
.watch-apps-overlay {
    position: absolute;
    inset: 0;
    display: none;
    z-index: 11050;
    align-items: center;
    justify-content: center;
    background: rgba(0,0,0,0.6);
    padding: 18px;
}
.watch-apps-overlay.active {
    display: flex;
}
.watch-apps-panel {
    width: 86%;
    max-width: 320px;
    max-height: 86%;
    background: rgba(10,10,10,0.95);
    border-radius: 12px;
    padding: 12px;
    overflow: auto;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    align-content: start;
}
.watch-apps-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    color: #fff;
    font-size: 11px;
    cursor: pointer;
    padding: 6px;
    border-radius: 8px;
    transition: background 0.12s, transform 0.12s;
}
.watch-apps-item img {
    width: 48px;
    height: 48px;
    border-radius: 6px;
    background: #222;
}
.watch-apps-item:active, .watch-apps-item:hover {
    background: rgba(255,255,255,0.04);
    transform: translateY(-3px);
}

/* Make the button slightly larger on touch devices */
@media (hover: none) {
    #watch-close-btn { width: 46px; height: 46px; font-size: 20px; top: 10px; right: 10px; }
}

/* Outer container adjustments when watch-mode class is applied to body */
.watch-mode #phone-container {
    width: 320px !important;
    height: 320px !important;
    max-width: 320px !important;
    max-height: 320px !important;
    box-shadow: 0 40px 80px rgba(0,0,0,0.6);
    border-radius: 50%;
    transform: scale(1);
    transition: width 0.25s ease, height 0.25s ease, border-radius 0.25s ease;
}

/* Show watch controls only when watch-mode is active */
.watch-mode #watch-close-btn {
    display: flex;
}

/* Small selector for watch shape */
#watch-shape-selector {
    position: absolute;
    top: 12px;
    left: 56px;
    display: none;
    gap: 6px;
    z-index: 11010;
}
.watch-mode #watch-shape-selector {
    display: flex;
}
.watch-shape-btn {
    width: 36px;
    height: 36px;
    border-radius: 6px;
    background: rgba(0,0,0,0.6);
    color: #fff;
    border: 1px solid rgba(255,255,255,0.06);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    cursor: pointer;
}
.watch-shape-btn[aria-pressed="true"] {
    background: rgba(255,255,255,0.06);
    box-shadow: 0 6px 16px rgba(0,0,0,0.5);
    color: #a4c639;
}

/* Square watch adjustments when selected */
.watch-mode.watch-shape-square #phone-container,
.watch-mode.watch-shape-square #screen {
    border-radius: 12px;
    overflow: hidden;
}

/* Adjust button positions slightly for square layout */
.watch-mode.watch-shape-square #watch-close-btn { right: 10px; top: 10px; }

/* Ensure circular default when not square */
.watch-mode:not(.watch-shape-square) #phone-container,
.watch-mode:not(.watch-shape-square) #screen {
    border-radius: 50%;
}

/* Make screen perfectly circular and center content */
.watch-mode #screen {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

/* Hide desktop-only chrome in watch-mode */
.watch-mode #nav-bar,
.watch-mode #status-bar,
.watch-mode #dock,
.watch-mode .market-header,
.watch-mode .app-toolbar,
.watch-mode .movie-studio-toolbar {
    display: none !important;
}

/* Keep minimal home view visible and centered */
.watch-mode #home-screen {
    padding: 18px;
    display: flex !important;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

/* Reduce app icon sizes for watch face */
.watch-mode .app-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    padding: 8px;
}

.watch-mode .app-icon img {
    width: 44px;
    height: 44px;
}

.watch-mode .app-icon span {
    font-size: 10px;
}

/* Taskbar hidden in watch-mode */
.watch-mode #desktop-taskbar {
    display: none !important;
}

/* Windowed apps should open full circular overlay (simple behavior) */
.watch-mode .app-window {
    position: absolute !important;
    top: 0;
    left: 0;
    width: 100% !important;
    height: 100% !important;
    border-radius: 50%;
    min-width: unset;
    min-height: unset;
    max-width: unset;
    max-height: unset;
    box-shadow: none;
    border: none;
    display: none;
}

.watch-mode .app-window.active {
    display: flex;
}

/* For readability, center typical app content */
.watch-mode .app-content {
    padding: 12px;
    overflow: auto;
    text-align: center;
}

/* Watch-mode specific browser toolbar (compact) */
.watch-browser-toolbar {
    display: none;
    height: 40px;
    background: rgba(0,0,0,0.6);
    align-items: center;
    justify-content: space-between;
    padding: 6px 8px;
    gap: 8px;
    color: #fff;
}
.watch-browser-toolbar .wb-left, .watch-browser-toolbar .wb-right {
    display: flex;
    align-items: center;
    gap: 8px;
}
.watch-browser-toolbar button {
    background: rgba(255,255,255,0.04);
    border: 1px solid rgba(255,255,255,0.06);
    color: #fff;
    padding: 6px 8px;
    border-radius: 6px;
    font-size: 14px;
    cursor: pointer;
}

/* Show the compact toolbar only in watch-mode and hide normal browser toolbar */
.watch-mode .watch-browser-toolbar { display: flex; }
.watch-mode .browser-toolbar { display: none !important; }

/* Make iframe fit nicely inside circular app window on watch */
.watch-mode #browser-iframe {
    border-radius: 8px;
    width: calc(100% - 20px);
    height: calc(100% - 56px);
    margin: 8px 10px 10px 10px;
    border: none;
}

/* Smaller camera shutter and controls */
.watch-mode #camera-shutter { width: 54px; height: 54px; border-width: 3px; }
.watch-mode .shutter-inner { width: 36px; height: 36px; }

/* Ensure overlay modals are centered on circular face */
.watch-mode .devil-modal-content,
.watch-mode .export-container {
    transform: scale(0.92);
}

/* Responsive fallback on very small viewports */
@media (max-width: 360px) {
    .watch-mode #phone-container { width: 280px !important; height: 280px !important; max-width: 280px !important; max-height: 280px !important; }
}

/* Freak Mode - distinctive chilled/freaky UI */
.freak-mode #screen {
    background: linear-gradient(180deg, #03121a 0%, #05202a 100%) !important;
    filter: grayscale(40%) contrast(90%);
}
.freak-mode body, .freak-mode .app-window, .freak-mode .app-content, .freak-mode .view {
    color: #dff6ff !important;
}
.freak-mode .status-right, .freak-mode .nav-button, .freak-mode .dock-inner {
    opacity: 0.9;
}
.freak-mode .app-icon span, .freak-mode .market-app-name {
    color: #c7eef8 !important;
}
.freak-mode .app-icon img, .freak-mode .watch-apps-item img {
    filter: hue-rotate(180deg) saturate(0.6) brightness(0.9);
    border-radius: 6px;
    transition: transform 180ms ease, filter 280ms ease, box-shadow 220ms ease;
    will-change: transform, filter;
    /* slight lift on hover/tap for feedback */
}
.freak-mode .market-hero { background: #07414e !important; }
.freak-mode .devil-modal-content { background: #021216; border-color: #07323a; }
.freak-mode .export-container { background: #021216; border-color: #07323a; }
.freak-mode .music-player-ui .now-playing-art { border-color: #07414e; }

/* Bounce animation for app icons */
.app-icon.bounce {
    animation: appBounce 640ms cubic-bezier(.2,.8,.2,1);
    transform-origin: 50% 50%;
    will-change: transform;
}

@keyframes appBounce {
    0%   { transform: translateY(0) scale(1); }
    20%  { transform: translateY(-12px) scale(1.06); }
    40%  { transform: translateY(0) scale(0.98); }
    60%  { transform: translateY(-6px) scale(1.02); }
    80%  { transform: translateY(0) scale(0.995); }
    100% { transform: translateY(0) scale(1); }
}

/* Temporary "messed" visual applied shortly after enabling Freak Mode */
.freak-mode.freak-mess #screen {
    animation: freakPulse 2.2s ease-in-out infinite;
    filter: hue-rotate(60deg) saturate(1.4) contrast(1.05) brightness(1.02);
}
.freak-mode.freak-mess .app-icon span,
.freak-mode.freak-mess .market-app-name,
.freak-mode.freak-mess .now-playing-title,
.freak-mode.freak-mess .now-playing-artist {
    animation: flickerText 1.6s linear infinite;
    color: #ffddcc !important;
    text-shadow: 0 0 8px rgba(255, 200, 150, 0.12);
}
.freak-mode.freak-mess .app-icon img,
.freak-mode.freak-mess .watch-apps-item img {
    transform: rotate(-2deg) scale(1.02);
    filter: hue-rotate(120deg) saturate(1.2) contrast(1.05);
    transition: transform 0.22s ease, filter 0.25s ease;
    /* add a slow continuous spin in addition to wobble & hue shift */
    animation: iconWobble 1.8s infinite linear, iconHueShift 3.6s infinite linear, iconSpin 6s linear infinite;
    box-shadow: 0 6px 18px rgba(255,200,150,0.06), inset 0 1px 0 rgba(255,255,255,0.02);
    transform-origin: 50% 50%;
    will-change: transform, filter;
}

/* Icon-specific keyframes for wobble and hue cycling */
@keyframes iconWobble {
    0% { transform: rotate(-2deg) scale(1.02); }
    12% { transform: rotate(3deg) scale(1.05); }
    25% { transform: rotate(-4deg) scale(0.98); }
    50% { transform: rotate(2deg) scale(1.03); }
    75% { transform: rotate(-1deg) scale(1.00); }
    100% { transform: rotate(-2deg) scale(1.02); }
}

@keyframes iconHueShift {
    0%   { filter: hue-rotate(120deg) saturate(1.2) contrast(1.05); }
    25%  { filter: hue-rotate(40deg) saturate(1.6) contrast(1.03); }
    50%  { filter: hue-rotate(200deg) saturate(0.9) contrast(1.1); }
    75%  { filter: hue-rotate(300deg) saturate(1.4) contrast(0.98); }
    100% { filter: hue-rotate(120deg) saturate(1.2) contrast(1.05); }
}

/* Slow continuous spin to complement wobble/hue animations */
@keyframes iconSpin {
    0% { transform: rotate(-2deg) scale(1.02); }
    50% { transform: rotate(178deg) scale(1.02); }
    100% { transform: rotate(-2deg) scale(1.02); }
}

/* Subtle keyframe animations for the messed effect */
@keyframes freakPulse {
    0% { transform: translateZ(0) scale(1); filter: hue-rotate(0deg) saturate(1) contrast(0.95); }
    50% { transform: translateZ(0) scale(1.01); filter: hue-rotate(80deg) saturate(1.6) contrast(1.05); }
    100% { transform: translateZ(0) scale(1); filter: hue-rotate(0deg) saturate(1) contrast(0.95); }
}

@keyframes flickerText {
    0% { opacity: 1; text-shadow: 0 0 6px rgba(255,255,255,0.0); transform: translateY(0); }
    30% { opacity: 0.85; text-shadow: 0 0 10px rgba(255,200,120,0.25); transform: translateY(-1px); }
    60% { opacity: 0.9; text-shadow: 0 0 4px rgba(255,120,200,0.08); transform: translateY(0); }
    100% { opacity: 1; text-shadow: 0 0 6px rgba(255,255,255,0.0); transform: translateY(0); }
}

/* Watch-mode: hide UI chrome when user toggles hide option */
.watch-mode.watch-hide-ui #watch-close-btn,
.watch-mode.watch-hide-ui #watch-recents-btn,
.watch-mode.watch-hide-ui #watch-shape-selector,
.watch-mode.watch-hide-ui .watch-browser-toolbar,
.watch-mode.watch-hide-ui .watch-apps-overlay,
.watch-mode.watch-hide-ui .watch-apps-panel,
.watch-mode.watch-hide-ui .watch-apps-item,
.watch-mode.watch-hide-ui .watch-apps-overlay.active {
    display: none !important;
    visibility: hidden !important;
}

/* Show the single "Show UI" button when the watch UI is hidden so users can restore it */
#watch-show-ui-btn {
    position: absolute;
    top: 12px;
    left: 50%;
    transform: translateX(-50%);
    width: 46px;
    height: 46px;
    border-radius: 50%;
    background: rgba(0,0,0,0.7);
    color: #fff;
    border: 1px solid rgba(255,255,255,0.06);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 12020;
    font-size: 18px;
    cursor: pointer;
    box-shadow: 0 6px 18px rgba(0,0,0,0.6);
}

/* When UI is hidden show the restore button */
.watch-mode.watch-hide-ui #watch-show-ui-btn {
    display: flex !important;
}

/* Also hide small status indicators and any extra overlays to keep face clean */
.watch-mode.watch-hide-ui .devil-modal,
.watch-mode.watch-hide-ui .devil-modal.active,
.watch-mode.watch-hide-ui .export-container,
.watch-mode.watch-hide-ui #recent-apps-view,
.watch-mode.watch-hide-ui #recent-apps-view.active {
    display: none !important;
    opacity: 0 !important;
    pointer-events: none !important;
}

/* Keep the wallpaper picker usable when its tiles exceed the available height. */
#app-wallpapers .app-content {
    min-height: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

/* Keep the launcher and app controls proportional on shorter phone displays. */
@container phone-screen (max-height: 620px) {
    #status-bar {
        height: 20px;
        min-height: 20px;
        font-size: 10px;
        padding-inline: 6px;
    }

    #nav-bar,
    .nav-button {
        height: 38px;
    }

    #google-search {
        padding: 10px 12px;
        margin-top: 6px;
    }

    .search-bar {
        height: 36px;
        padding-inline: 12px;
    }

    .g-logo { font-size: 16px; }

    .app-grid {
        gap: 7px;
        padding: 14px;
    }

    .app-icon img {
        width: 46px;
        height: 46px;
        margin-bottom: 3px;
    }

    .app-icon span { font-size: 11px; }

    #dock { padding-bottom: 6px; }

    .dock-inner { padding: 6px 0; }

    #drawer-button img {
        width: 42px;
        height: 42px;
    }

    .app-toolbar { height: 42px; }

    .settings-header {
        padding: 11px 13px;
        font-size: 16px;
    }

    .settings-item { padding: 11px 16px; }

    #app-wallpapers .app-content { padding: 8px !important; gap: 8px !important; }

    #app-wallpapers .app-content img { height: 56px !important; }
}

/* Android boot overlay */
#boot-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #000;
    z-index: 12000;
    pointer-events: none;
    opacity: 0;
    transition: none;
}
#boot-overlay.show {
    pointer-events: auto;
    opacity: 1;
    transition: none;
}
#boot-overlay .boot-inner {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}
#boot-overlay .boot-animation {
    display: block;
    width: min(100%, 450px);
    height: auto;
    object-fit: contain;
}

/* Fade-out quick helper */
#boot-overlay.fade-out {
    transition: opacity 800ms ease;
    opacity: 0;
    pointer-events: auto;
}

/* Content slots (third-party embedded content served inside the phone apps).
   Sized to the supported formats: horizontal, square, and vertical. */
.content-slot {
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
    background: transparent;
}
.content-slot .content-frame {
    display: block;
    border: 0;
    width: 100%;
    height: 100%;
    background: transparent;
}
.content-horizontal {
    width: 100%;
    height: 100px;
    flex: 0 0 auto;
}
.content-square {
    width: 100%;
    height: 250px;
    flex: 0 0 auto;
}
.content-vertical {
    width: 150px;
    height: 400px;
    margin: 0 auto;
    flex: 0 0 auto;
}
/* Padding so embedded content sits nicely against dark app chrome */
.content-slot + .content-slot,
.market-list .content-slot {
    margin-top: 6px;
}
