/**
 * Atelier by GallusTech - WebOS Window Manager & Contextual Menu Styles
 * Full theme adaptability across all WebOS windows, headers, taskbars, and menus.
 */

/* -------------------------------------------------------------
 * 1. WEBOS DESKTOP & WORKSPACE CONTAINER
 * ------------------------------------------------------------- */
#webosDesktop {
  position: relative;
  width: 100%;
  height: calc(100vh - 52px);
  min-height: calc(100vh - 52px);
  overflow: hidden;
}

/* -------------------------------------------------------------
 * 2. CONTEXTUAL APP MENU BAR (MACOS-STYLE)
 * ------------------------------------------------------------- */
.app-menu-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.45rem 1.25rem;
  background: var(--menu-bar-bg, rgba(15, 23, 42, 0.8));
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border-color, rgba(255, 255, 255, 0.08));
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
  z-index: 90;
  min-height: 44px;
  transition: background 0.25s ease, border-color 0.25s ease;
}

.app-menu-left,
.app-menu-right {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.app-menu-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.35rem 0.75rem;
  border-radius: 9999px;
  background: var(--bg-card, rgba(255, 255, 255, 0.06));
  border: 1px solid var(--border-color, rgba(255, 255, 255, 0.1));
  color: var(--text-main, #f8fafc);
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
  user-select: none;
}

.app-menu-pill:hover {
  background: var(--border-color-hover, rgba(99, 102, 241, 0.2));
  border-color: var(--accent-primary, #6366f1);
  transform: translateY(-1px);
}

.app-menu-pill.active {
  background: var(--accent-primary, #6366f1);
  border-color: transparent;
  color: #fff;
  box-shadow: 0 2px 10px rgba(99, 102, 241, 0.4);
}

.app-menu-separator {
  width: 1px;
  height: 20px;
  background: var(--border-color, rgba(255, 255, 255, 0.12));
  margin: 0 0.25rem;
}

/* -------------------------------------------------------------
 * 3. UNIVERSAL WEBOS WINDOWS
 * ------------------------------------------------------------- */
.webos-window {
  position: fixed;
  display: flex;
  flex-direction: column;
  background: var(--window-bg, rgba(15, 23, 42, 0.95));
  color: var(--text-main, #f8fafc);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border: 1px solid var(--border-color, rgba(255, 255, 255, 0.12));
  border-radius: 14px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5), 0 0 0 1px var(--border-color, rgba(255, 255, 255, 0.05));
  overflow: hidden;
  will-change: transform, width, height, left, top;
  touch-action: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.webos-window.is-active {
  border-color: var(--border-color-hover, rgba(99, 102, 241, 0.4));
  box-shadow: 0 25px 60px rgba(0, 0, 0, 0.65), 0 0 0 1px var(--accent-primary, rgba(99, 102, 241, 0.5));
}

.webos-window.is-dragging {
  opacity: 0.95;
  cursor: grabbing !important;
  user-select: none;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.85), 0 0 0 2px var(--accent-primary, #6366f1);
}

.webos-window.is-dragging iframe,
.webos-window.is-resizing iframe {
  pointer-events: none;
}

.webos-app-icon-img {
  width: 1.15em;
  height: 1.15em;
  object-fit: contain;
  vertical-align: -0.18em;
  border-radius: 22%;
  display: inline-block;
  flex-shrink: 0;
  user-select: none;
}

.app-launcher-icon .webos-app-icon-img {
  width: 24px;
  height: 24px;
  border-radius: 6px;
  vertical-align: middle;
}

.window-icon .webos-app-icon-img,
.taskbar-icon .webos-app-icon-img,
.app-menu-pill .webos-app-icon-img,
.explorer-open-with-item .webos-app-icon-img,
.inspector-open-with-btn .webos-app-icon-img {
  width: 18px;
  height: 18px;
  border-radius: 4px;
  vertical-align: middle;
}

.desktop-shortcut-icon .webos-app-icon-img,
.preview-big-icon .webos-app-icon-img {
  width: 44px;
  height: 44px;
  border-radius: 11px;
  vertical-align: middle;
}

.webos-window .window-body:has(.webapp-iframe-host) {
  overflow: hidden;
  padding: 0;
}

.webapp-iframe-host {
  flex: 1 1 auto;
  min-height: 0;
  min-width: 0;
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #19191c;
}

.webapp-iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
  display: block;
}

.webapp-boot-overlay {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.85rem;
  padding: 1.5rem;
  text-align: center;
  background: rgba(15, 23, 42, 0.92);
  color: #f8fafc;
  backdrop-filter: blur(8px);
  transition: opacity 0.25s ease;
}

.webapp-boot-overlay.is-hidden {
  opacity: 0;
  pointer-events: none;
}

.webapp-boot-icon {
  font-size: 2.8rem;
  line-height: 1;
}

.webapp-boot-icon .webos-app-icon-img {
  width: 56px;
  height: 56px;
  border-radius: 14px;
}

.webapp-boot-spinner {
  width: 28px;
  height: 28px;
  border: 3px solid rgba(255, 255, 255, 0.16);
  border-top-color: var(--accent-primary, #6366f1);
  border-radius: 50%;
  animation: webappSpin 0.85s linear infinite;
}

@keyframes webappSpin {
  to { transform: rotate(360deg); }
}

.webapp-boot-title {
  font-size: 0.95rem;
  font-weight: 600;
}

.webapp-boot-hint {
  max-width: 440px;
  font-size: 0.82rem;
  color: #94a3b8;
  line-height: 1.45;
}

.webapp-boot-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.5rem;
  margin-top: 0.25rem;
}

.webapp-boot-btn {
  padding: 0.42rem 0.85rem;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: rgba(255, 255, 255, 0.08);
  color: #f8fafc;
  font-size: 0.8rem;
  cursor: pointer;
  transition: background 0.15s ease;
}

.webapp-boot-btn:hover {
  background: rgba(99, 102, 241, 0.35);
}

.explorer-open-with-menu {
  position: fixed;
  z-index: 10050;
  min-width: 210px;
  padding: 6px;
  border-radius: 10px;
  background: var(--window-bg, #1e293b);
  border: 1px solid var(--border-color, rgba(255, 255, 255, 0.14));
  box-shadow: 0 14px 36px rgba(0, 0, 0, 0.35);
  backdrop-filter: blur(14px);
  color: var(--text-main, #f8fafc);
  font-size: 0.84rem;
}

.explorer-open-with-header {
  padding: 4px 10px 6px;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-muted, #94a3b8);
}

.explorer-open-with-sep {
  height: 1px;
  margin: 4px 0;
  background: var(--border-color, rgba(255, 255, 255, 0.1));
}

.explorer-open-with-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 7px 10px;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--text-main, inherit);
  cursor: pointer;
  text-align: left;
  font-size: 0.84rem;
  transition: background 0.12s ease;
}

.explorer-open-with-item:hover {
  background: var(--border-color, rgba(99, 102, 241, 0.22));
}

.inspector-open-with-section {
  margin: 0.75rem 0;
  padding-top: 0.6rem;
  border-top: 1px solid var(--border-color, rgba(255, 255, 255, 0.08));
}

/* Mounted Volumes & Shared Drives Strip (Explorer + Desktop) */
.vol-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid var(--border-color, rgba(148, 163, 184, 0.25));
  background: var(--bg-card, rgba(255, 255, 255, 0.05));
  color: var(--text-main, #f8fafc);
  font-size: 0.78rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.14s ease;
}

.vol-pill:hover {
  border-color: var(--accent, #6366f1);
  background: rgba(99, 102, 241, 0.14);
}

.vol-pill.active {
  background: var(--accent, #6366f1);
  border-color: var(--accent, #6366f1);
  color: #ffffff;
}

.vol-perm-badge {
  font-size: 0.64rem;
  font-weight: 700;
  padding: 1px 5px;
  border-radius: 4px;
  background: rgba(14, 165, 233, 0.22);
  color: #38bdf8;
}

.vol-perm-badge.is-rw {
  background: rgba(34, 197, 94, 0.22);
  color: #4ade80;
}

.vol-pill.active .vol-perm-badge {
  background: rgba(255, 255, 255, 0.25);
  color: #ffffff;
}

.inspector-open-with-title {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted, #94a3b8);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 0.45rem;
}

.inspector-open-with-list {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.inspector-open-with-btn {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  width: 100%;
  padding: 0.45rem 0.65rem;
  border-radius: 7px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-main, #f8fafc);
  cursor: pointer;
  font-size: 0.82rem;
  text-align: left;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.inspector-open-with-btn:hover {
  background: rgba(99, 102, 241, 0.22);
  border-color: rgba(99, 102, 241, 0.45);
}

.webos-window.is-maximized {
  border-radius: 0;
  border-left: none;
  border-right: none;
  box-shadow: none;
}

/* Window Header */
.webos-window .window-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.6rem 0.9rem;
  background: var(--header-bg, rgba(30, 41, 59, 0.85));
  border-bottom: 1px solid var(--border-color, rgba(255, 255, 255, 0.08));
  cursor: grab;
  user-select: none;
  color: var(--text-main, #f8fafc);
}

.webos-window.is-dragging .window-header {
  cursor: grabbing;
}

.window-traffic-lights {
  display: flex;
  align-items: center;
  gap: 0.45rem;
}

.win-btn {
  width: 13px;
  height: 13px;
  border-radius: 50%;
  border: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 8px;
  font-weight: 900;
  color: transparent;
  cursor: pointer;
  transition: all 0.15s ease;
  line-height: 1;
  padding: 0;
}

.window-header:hover .win-btn {
  color: rgba(0, 0, 0, 0.6);
}

.win-btn.win-close {
  background: #ff5f56;
  border: 1px solid #e0443e;
}
.win-btn.win-minimize {
  background: #ffbd2e;
  border: 1px solid #dea123;
}
.win-btn.win-maximize {
  background: #27c93f;
  border: 1px solid #1aab29;
}

.win-btn:hover {
  filter: brightness(1.15);
  transform: scale(1.1);
}

.window-title-group {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  color: var(--text-main, #f8fafc);
  font-size: 0.85rem;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 60%;
}

.window-icon {
  font-size: 1rem;
}

.window-header-actions {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

/* Window Body */
.webos-window .window-body {
  flex: 1;
  position: relative;
  overflow: auto;
  display: flex;
  flex-direction: column;
  color: var(--text-main, #f8fafc);
}

/* -------------------------------------------------------------
 * 4. RESIZE HANDLES (8-DIRECTIONS)
 * ------------------------------------------------------------- */
.win-resize-handle {
  position: absolute;
  z-index: 50;
}

.win-resize-handle.res-n { top: 0; left: 8px; right: 8px; height: 6px; cursor: n-resize; }
.win-resize-handle.res-s { bottom: 0; left: 8px; right: 8px; height: 6px; cursor: s-resize; }
.win-resize-handle.res-e { top: 8px; right: 0; bottom: 8px; width: 6px; cursor: e-resize; }
.win-resize-handle.res-w { top: 8px; left: 0; bottom: 8px; width: 6px; cursor: w-resize; }
.win-resize-handle.res-ne { top: 0; right: 0; width: 12px; height: 12px; cursor: ne-resize; }
.win-resize-handle.res-nw { top: 0; left: 0; width: 12px; height: 12px; cursor: nw-resize; }
.win-resize-handle.res-se { bottom: 0; right: 0; width: 12px; height: 12px; cursor: se-resize; }
.win-resize-handle.res-sw { bottom: 0; left: 0; width: 12px; height: 12px; cursor: sw-resize; }

.webos-window.is-maximized .win-resize-handle {
  display: none !important;
}

/* -------------------------------------------------------------
 * 5. UNIFIED NEXT-GEN TASKBAR & INTEGRATED FOOTER
 * ------------------------------------------------------------- */
.webos-taskbar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  width: 100vw;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0 0.75rem;
  margin: 0;
  background: var(--menu-bar-bg, rgba(15, 23, 42, 0.92));
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border-top: 1px solid var(--border-color, rgba(255, 255, 255, 0.12));
  border-radius: 0;
  box-shadow: none;
  z-index: 10000;
  user-select: none;
}

/* Left Zone: Brand link & Cookie Settings */
.taskbar-left-zone {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.78rem;
  color: var(--text-muted, #94a3b8);
  flex-shrink: 0;
}

.taskbar-brand-link {
  color: var(--text-main, #f8fafc);
  text-decoration: none;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  transition: opacity 0.15s ease;
}

.taskbar-brand-link:hover {
  opacity: 0.85;
}

.taskbar-tech {
  opacity: 0.65;
  font-size: 0.72rem;
}

.taskbar-separator {
  opacity: 0.3;
}

.taskbar-cookie-btn {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 6px;
  color: var(--text-main, #f8fafc);
  font-size: 0.72rem;
  padding: 0.2rem 0.5rem;
  cursor: pointer;
  transition: all 0.15s ease;
}

.taskbar-cookie-btn:hover {
  background: rgba(255, 255, 255, 0.12);
  border-color: var(--accent-primary, #6366f1);
}

/* Center Zone: Running Apps */
.taskbar-apps-container {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  overflow-x: auto;
  scrollbar-width: none;
  flex: 1;
  max-width: 60vw;
}

.taskbar-apps-container::-webkit-scrollbar {
  display: none;
}

.taskbar-item {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.32rem 0.75rem 0.48rem;
  border-radius: 8px;
  background: var(--bg-card, rgba(255, 255, 255, 0.05));
  border: 1px solid var(--border-color, rgba(255, 255, 255, 0.08));
  color: var(--text-main, #f8fafc);
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.18s cubic-bezier(0.16, 1, 0.3, 1);
  white-space: nowrap;
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.taskbar-item:hover {
  background: var(--border-color-hover, rgba(255, 255, 255, 0.15));
  transform: translateY(-2px);
}

.taskbar-item .taskbar-icon {
  font-size: 1.05rem;
  flex-shrink: 0;
}

.taskbar-item .taskbar-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.taskbar-indicator {
  position: absolute;
  bottom: 2px;
  left: 25%;
  right: 25%;
  height: 3px;
  border-radius: 3px;
  background: var(--border-color, rgba(255, 255, 255, 0.3));
  transition: all 0.2s ease;
}

.taskbar-item.active {
  background: var(--border-color-hover, rgba(255, 255, 255, 0.12));
  color: #fff;
}

.taskbar-item.active .taskbar-indicator {
  background: var(--accent-primary, #6366f1);
  left: 15%;
  right: 15%;
  box-shadow: 0 0 8px var(--accent-primary, #6366f1);
}

.taskbar-item.minimized {
  opacity: 0.65;
}

.taskbar-item.minimized .taskbar-indicator {
  background: transparent;
  border-bottom: 2px dotted var(--text-muted, #94a3b8);
}

/* System Tray in Taskbar */
.taskbar-tray-container {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding-left: 0.5rem;
  border-left: 1px solid var(--border-color, rgba(255, 255, 255, 0.12));
  flex-shrink: 0;
}

.taskbar-tray-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.3rem 0.55rem;
  background: var(--bg-card, rgba(255, 255, 255, 0.05));
  border: 1px solid var(--border-color, rgba(255, 255, 255, 0.08));
  border-radius: 8px;
  color: var(--text-main, #f8fafc);
  font-size: 0.78rem;
  cursor: pointer;
  transition: all 0.15s ease;
}

.taskbar-tray-btn:hover {
  background: var(--border-color-hover, rgba(255, 255, 255, 0.12));
}

.taskbar-tray-pill {
  font-size: 0.7rem;
  font-weight: 700;
  color: #22c55e;
  font-variant-numeric: tabular-nums;
}

.taskbar-clock-btn {
  display: inline-flex;
  flex-direction: column;
  align-items: flex-end;
  justify-content: center;
  padding: 0.2rem 0.5rem;
  background: transparent;
  border: none;
  border-radius: 8px;
  color: var(--text-main, #f8fafc);
  cursor: pointer;
  transition: all 0.15s ease;
  line-height: 1.15;
}

.taskbar-clock-btn:hover {
  background: var(--border-color-hover, rgba(255, 255, 255, 0.08));
}

.taskbar-clock-time {
  font-size: 0.8rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.taskbar-clock-date {
  font-size: 0.65rem;
  color: var(--text-muted, #94a3b8);
}

.taskbar-show-desktop {
  width: 6px;
  height: 28px;
  border-radius: 3px;
  background: var(--border-color, rgba(255, 255, 255, 0.2));
  border: none;
  cursor: pointer;
  transition: all 0.15s ease;
  margin-left: 2px;
}

.taskbar-show-desktop:hover {
  background: var(--accent-primary, #6366f1);
  box-shadow: 0 0 8px var(--accent-primary, #6366f1);
}

/* Floating Window Peeking Preview Card */
.taskbar-preview-card {
  position: fixed;
  width: 220px;
  background: var(--header-bg, var(--menu-bar-bg, rgba(15, 23, 42, 0.95)));
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--border-color, rgba(255, 255, 255, 0.15));
  border-radius: 12px;
  box-shadow: 0 14px 35px rgba(0, 0, 0, 0.6);
  z-index: 10005;
  overflow: hidden;
  animation: taskbarPreviewFade 0.18s cubic-bezier(0.16, 1, 0.3, 1);
  cursor: pointer;
}

@keyframes taskbarPreviewFade {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.taskbar-preview-card .preview-header {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 10px;
  background: var(--bg-card, rgba(255, 255, 255, 0.04));
  border-bottom: 1px solid var(--border-color, rgba(255, 255, 255, 0.08));
}

.taskbar-preview-card .preview-icon {
  font-size: 1rem;
}

.taskbar-preview-card .preview-title {
  flex: 1;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-main, #ffffff);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.taskbar-preview-card .preview-close-btn {
  background: transparent;
  border: none;
  color: var(--text-muted, #94a3b8);
  font-size: 0.8rem;
  cursor: pointer;
  border-radius: 4px;
  padding: 2px 5px;
}

.taskbar-preview-card .preview-close-btn:hover {
  background: rgba(239, 68, 68, 0.2);
  color: #ef4444;
}

.taskbar-preview-card .preview-body {
  padding: 12px;
}

.taskbar-preview-card .preview-snapshot {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.2);
  border-radius: 8px;
  padding: 14px 8px;
  border: 1px solid var(--border-color, rgba(255, 255, 255, 0.05));
  text-align: center;
}

/* Mini Calendar Popover */
.taskbar-calendar-popover {
  position: fixed;
  bottom: 50px;
  right: 12px;
  width: 250px;
  background: var(--window-bg, var(--menu-bar-bg, rgba(15, 23, 42, 0.95)));
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border: 1px solid var(--border-color, rgba(255, 255, 255, 0.15));
  border-radius: 14px;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.6);
  z-index: 10005;
  padding: 12px;
  animation: taskbarPreviewFade 0.18s ease;
}

.cal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 8px;
  margin-bottom: 8px;
  border-bottom: 1px solid var(--border-color, rgba(255, 255, 255, 0.1));
}

.cal-title {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-main, #ffffff);
}

.cal-time {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--accent-primary, #6366f1);
  font-variant-numeric: tabular-nums;
}

.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
  text-align: center;
}

.cal-day-name {
  font-size: 0.68rem;
  font-weight: 700;
  color: var(--text-muted, #94a3b8);
  padding: 3px 0;
}

.cal-day {
  font-size: 0.75rem;
  padding: 5px 0;
  border-radius: 6px;
  color: var(--text-main, #e2e8f0);
}

.cal-day.today {
  background: var(--accent-primary, #6366f1);
  color: #ffffff;
  font-weight: 800;
  box-shadow: 0 2px 8px rgba(99, 102, 241, 0.4);
}

.cal-day.empty {
  visibility: hidden;
}

/* App Explorer Window Customization */
.webos-window.app-explorer {
  background: var(--window-bg, var(--bg-main, #0f172a));
}

.webos-window.app-explorer .window-body {
  overflow: hidden;
  height: 100%;
}

/* ==========================================================================
   DEDICATED CENTERED AUTHENTICATION & ACCOUNT OVERLAY (FROSTED BACKDROP)
   ========================================================================== */
#webosDesktop.atelier-auth-blur-active,
.app-header.atelier-auth-blur-active {
  filter: blur(11px) brightness(0.82);
  transition: filter 0.24s ease;
  pointer-events: none;
  user-select: none;
}

.atelier-auth-overlay {
  position: fixed;
  inset: 0;
  z-index: 100200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(9, 13, 24, 0.56);
  backdrop-filter: blur(18px) saturate(140%);
  -webkit-backdrop-filter: blur(18px) saturate(140%);
  opacity: 0;
  transition: opacity 0.22s ease;
}

.atelier-auth-overlay.open {
  opacity: 1;
}

.atelier-auth-box {
  position: relative;
  width: 440px;
  max-width: 96vw;
  max-height: 92vh;
  overflow-y: auto;
  padding: 26px 26px 22px;
  border-radius: 20px;
  background: var(--window-bg, rgba(15, 23, 42, 0.94));
  color: var(--text-main, #f8fafc);
  border: 1px solid var(--border-color, rgba(255, 255, 255, 0.14));
  box-shadow: 0 30px 70px rgba(0, 0, 0, 0.55), 0 0 0 1px rgba(255, 255, 255, 0.06);
  transform: translateY(10px) scale(0.97);
  transition: transform 0.24s cubic-bezier(0.16, 1, 0.3, 1);
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.atelier-auth-overlay.open .atelier-auth-box {
  transform: translateY(0) scale(1);
}

.atelier-auth-close {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 30px;
  height: 30px;
  border-radius: 99px;
  border: 1px solid var(--border-color, rgba(255, 255, 255, 0.12));
  background: transparent;
  color: var(--text-muted, #94a3b8);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
  transition: background 0.15s ease, color 0.15s ease;
}

.atelier-auth-close:hover {
  background: rgba(148, 163, 184, 0.18);
  color: var(--text-main, #fff);
}

.atelier-auth-brand {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding-right: 26px;
}

.atelier-auth-logo {
  width: 46px;
  height: 46px;
  border-radius: 13px;
  background: linear-gradient(135deg, #4f46e5, #2563eb);
  color: #ffffff;
  font-weight: 800;
  font-size: 1.4rem;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 10px 24px rgba(79, 70, 229, 0.35);
  flex-shrink: 0;
}

.atelier-auth-brand-row {
  display: flex;
  align-items: baseline;
  gap: 6px;
}

.atelier-auth-brand-name {
  font-weight: 800;
  font-size: 0.95rem;
  letter-spacing: -0.01em;
}

.atelier-auth-brand-sub {
  font-size: 0.75rem;
  color: var(--text-muted, #94a3b8);
}

.atelier-auth-heading {
  margin: 2px 0 3px;
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--text-main, #f8fafc);
}

.atelier-auth-subtitle {
  margin: 0;
  font-size: 0.8rem;
  color: var(--text-muted, #94a3b8);
  line-height: 1.4;
}

.atelier-auth-mode-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  padding: 4px;
  border-radius: 11px;
  background: rgba(148, 163, 184, 0.12);
  margin-bottom: 14px;
}

.atelier-auth-mode-tab {
  border: none;
  background: transparent;
  color: var(--text-muted, #94a3b8);
  padding: 7px 10px;
  border-radius: 8px;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.atelier-auth-mode-tab.active {
  background: var(--bg-card, rgba(30, 41, 59, 0.95));
  color: var(--text-main, #fff);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.18);
}

.atelier-auth-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.atelier-auth-field {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.atelier-auth-field label {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-muted, #94a3b8);
}

.atelier-auth-input-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 11px;
  border-radius: 10px;
  border: 1px solid var(--border-color, rgba(255, 255, 255, 0.14));
  background: var(--bg-card, rgba(0, 0, 0, 0.24));
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.atelier-auth-input-wrap:focus-within {
  border-color: var(--accent-primary, #6366f1);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.22);
}

.atelier-auth-input-wrap input {
  flex: 1;
  min-width: 0;
  border: none;
  background: transparent;
  color: var(--text-main, #f8fafc);
  padding: 10px 0;
  font-size: 0.9rem;
  outline: none;
}

.atelier-auth-input-icon {
  font-size: 0.9rem;
  opacity: 0.78;
}

.atelier-auth-eye-btn {
  border: none;
  background: transparent;
  color: var(--text-muted, #94a3b8);
  cursor: pointer;
  padding: 4px;
  font-size: 0.9rem;
}

.atelier-auth-totp-slot {
  border: 1px dashed var(--border-color, rgba(255, 255, 255, 0.16));
  border-radius: 10px;
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.atelier-auth-totp-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
  border: none;
  background: transparent;
  color: var(--text-muted, #94a3b8);
  font-size: 0.79rem;
  font-weight: 600;
  cursor: pointer;
  padding: 0;
}

.atelier-auth-soon-pill {
  font-size: 0.67rem;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 99px;
  background: rgba(99, 102, 241, 0.16);
  color: var(--accent-primary, #818cf8);
}

.atelier-auth-options {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding-top: 2px;
}

.atelier-auth-checkbox {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 0.8rem;
  color: var(--text-muted, #94a3b8);
  cursor: pointer;
}

.atelier-auth-error {
  padding: 9px 11px;
  border-radius: 9px;
  background: rgba(239, 68, 68, 0.14);
  border: 1px solid rgba(239, 68, 68, 0.35);
  color: #f87171;
  font-size: 0.82rem;
}

.atelier-auth-submit-btn {
  width: 100%;
  padding: 11px 16px;
  border: none;
  border-radius: 11px;
  background: linear-gradient(135deg, #4f46e5, #2563eb);
  color: #ffffff;
  font-size: 0.92rem;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  box-shadow: 0 10px 24px rgba(79, 70, 229, 0.32);
  transition: transform 0.14s ease, opacity 0.14s ease;
}

.atelier-auth-submit-btn:hover:not(:disabled) {
  transform: translateY(-1px);
}

.atelier-auth-submit-btn:disabled {
  opacity: 0.65;
  cursor: wait;
}

.atelier-auth-hint {
  font-size: 0.74rem;
  color: var(--text-muted, #94a3b8);
  text-align: center;
  line-height: 1.4;
}

.atelier-auth-qr-panel {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 10px;
  padding: 12px 6px 6px;
}

.atelier-auth-qr-frame {
  position: relative;
  padding: 16px;
  border-radius: 16px;
  border: 1px dashed var(--border-color, rgba(255, 255, 255, 0.18));
  background: var(--bg-card, rgba(0, 0, 0, 0.2));
  color: var(--text-main, #e2e8f0);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.atelier-auth-qr-title {
  font-weight: 700;
  font-size: 0.94rem;
}

.atelier-auth-qr-desc {
  margin: 0;
  font-size: 0.8rem;
  color: var(--text-muted, #94a3b8);
  line-height: 1.45;
  max-width: 340px;
}

.atelier-auth-account-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px;
  border-radius: 14px;
  background: var(--bg-card, rgba(255, 255, 255, 0.04));
  border: 1px solid var(--border-color, rgba(255, 255, 255, 0.1));
}

.atelier-auth-avatar {
  width: 48px;
  height: 48px;
  border-radius: 14px;
  background: rgba(99, 102, 241, 0.18);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  flex-shrink: 0;
}

.atelier-auth-displayname {
  font-weight: 700;
  font-size: 1rem;
  color: var(--text-main, #f8fafc);
}

.atelier-auth-rolebadge {
  font-size: 0.78rem;
  color: #22c55e;
  font-weight: 600;
  margin-top: 2px;
}

.atelier-auth-quick-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 12px;
}

.atelier-auth-action-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 14px;
  border-radius: 11px;
  border: 1px solid var(--border-color, rgba(255, 255, 255, 0.12));
  background: var(--bg-card, rgba(255, 255, 255, 0.04));
  color: var(--text-main, #f8fafc);
  font-size: 0.86rem;
  font-weight: 600;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.atelier-auth-action-btn:hover {
  border-color: var(--accent-primary, #6366f1);
  background: rgba(99, 102, 241, 0.12);
}

.atelier-auth-action-btn.primary {
  background: linear-gradient(135deg, #4f46e5, #2563eb);
  border-color: transparent;
  color: #ffffff;
}

.atelier-auth-volumes-section {
  margin-top: 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.atelier-auth-section-label {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-muted, #94a3b8);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.atelier-auth-volumes-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.atelier-auth-vol-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  border-radius: 99px;
  border: 1px solid var(--border-color, rgba(255, 255, 255, 0.12));
  background: var(--bg-card, rgba(255, 255, 255, 0.04));
  color: var(--text-main, #f8fafc);
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
}

.atelier-auth-vol-chip:hover {
  border-color: var(--accent-primary, #6366f1);
}

.atelier-auth-perm-tag {
  font-size: 0.65rem;
  font-weight: 800;
  padding: 1px 5px;
  border-radius: 5px;
  background: rgba(99, 102, 241, 0.22);
}

.atelier-auth-footer-actions {
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px solid var(--border-color, rgba(255, 255, 255, 0.1));
}

.atelier-auth-logout-btn {
  width: 100%;
  padding: 9px 14px;
  border-radius: 10px;
  border: 1px solid rgba(239, 68, 68, 0.35);
  background: rgba(239, 68, 68, 0.12);
  color: #ef4444;
  font-size: 0.86rem;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.atelier-auth-logout-btn:hover {
  background: rgba(239, 68, 68, 0.22);
}

/* Light-theme high-contrast overrides for Auth Overlay */
body[data-theme*="light"] .atelier-auth-overlay,
:root[data-theme*="light"] .atelier-auth-overlay {
  background: rgba(15, 23, 42, 0.32);
}

body[data-theme*="light"] .atelier-auth-box,
:root[data-theme*="light"] .atelier-auth-box {
  background: rgba(255, 255, 255, 0.96);
  color: #0f172a;
  border-color: rgba(15, 23, 42, 0.12);
  box-shadow: 0 24px 60px rgba(15, 23, 42, 0.22);
}

body[data-theme*="light"] .atelier-auth-input-wrap,
:root[data-theme*="light"] .atelier-auth-input-wrap,
body[data-theme*="light"] .atelier-auth-account-card,
:root[data-theme*="light"] .atelier-auth-account-card,
body[data-theme*="light"] .atelier-auth-action-btn:not(.primary),
:root[data-theme*="light"] .atelier-auth-action-btn:not(.primary),
body[data-theme*="light"] .atelier-auth-vol-chip,
:root[data-theme*="light"] .atelier-auth-vol-chip,
body[data-theme*="light"] .atelier-auth-qr-frame,
:root[data-theme*="light"] .atelier-auth-qr-frame {
  background: #f8fafc;
  color: #0f172a;
  border-color: rgba(15, 23, 42, 0.14);
}

body[data-theme*="light"] .atelier-auth-mode-tab.active,
:root[data-theme*="light"] .atelier-auth-mode-tab.active {
  background: #ffffff;
  color: #0f172a;
}

body[data-theme*="light"] .atelier-auth-input-wrap input,
:root[data-theme*="light"] .atelier-auth-input-wrap input,
body[data-theme*="light"] .atelier-auth-heading,
:root[data-theme*="light"] .atelier-auth-heading,
body[data-theme*="light"] .atelier-auth-displayname,
:root[data-theme*="light"] .atelier-auth-displayname {
  color: #0f172a;
}

/* Phase A.2 — Registration, Verification, 2FA Setup & Recovery Codes */
.atelier-auth-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.atelier-auth-link-btn {
  border: none;
  background: transparent;
  color: var(--accent-primary, #818cf8);
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  padding: 2px 0;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.atelier-auth-link-btn:hover {
  opacity: 0.85;
}

.atelier-auth-strength-track {
  height: 4px;
  border-radius: 99px;
  background: rgba(148, 163, 184, 0.2);
  overflow: hidden;
  margin-top: 2px;
}

.atelier-auth-strength-fill {
  height: 100%;
  width: 0%;
  transition: width 0.2s ease, background 0.2s ease;
}

.atelier-auth-status-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 10px;
  padding: 12px 6px;
}

.atelier-auth-status-icon {
  font-size: 2.3rem;
  line-height: 1;
}

.atelier-auth-status-text {
  margin: 0;
  font-size: 0.88rem;
  line-height: 1.5;
  color: var(--text-main, #e2e8f0);
}

.atelier-auth-email-line {
  font-size: 0.76rem;
  color: var(--text-muted, #94a3b8);
  margin-top: 2px;
}

.atelier-auth-security-card {
  padding: 11px 13px;
  border-radius: 12px;
  border: 1px solid var(--border-color, rgba(255, 255, 255, 0.12));
  background: var(--bg-card, rgba(255, 255, 255, 0.04));
  margin-bottom: 12px;
}

.atelier-auth-security-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.atelier-auth-security-title {
  font-size: 0.84rem;
  font-weight: 700;
}

.atelier-auth-security-sub {
  font-size: 0.75rem;
  margin-top: 2px;
}

.atelier-auth-badge-ok {
  color: #22c55e;
  font-weight: 600;
}

.atelier-auth-badge-muted {
  color: var(--text-muted, #94a3b8);
}

.atelier-auth-mini-btn {
  padding: 5px 10px;
  border-radius: 8px;
  border: 1px solid var(--border-color, rgba(255, 255, 255, 0.16));
  background: transparent;
  color: var(--text-main, #f8fafc);
  font-size: 0.76rem;
  font-weight: 600;
  cursor: pointer;
}

.atelier-auth-mini-btn.primary {
  background: var(--accent-primary, #6366f1);
  border-color: transparent;
  color: #ffffff;
}

.atelier-auth-mini-btn.danger {
  border-color: rgba(239, 68, 68, 0.45);
  color: #ef4444;
}

.atelier-auth-totp-setup {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.atelier-auth-qr-live-box {
  width: 176px;
  height: 176px;
  padding: 8px;
  border-radius: 14px;
  background: #ffffff;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
  display: flex;
  align-items: center;
  justify-content: center;
}

.atelier-auth-qr-live-box svg {
  width: 100%;
  height: 100%;
  display: block;
}

.atelier-auth-secret-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: center;
}

.atelier-auth-secret-code {
  padding: 5px 10px;
  border-radius: 8px;
  background: rgba(148, 163, 184, 0.14);
  font-family: monospace;
  font-size: 0.78rem;
  letter-spacing: 0.06em;
  word-break: break-all;
}

.atelier-auth-recovery-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  width: 100%;
}

.atelier-auth-recovery-chip {
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid var(--border-color, rgba(255, 255, 255, 0.14));
  background: rgba(148, 163, 184, 0.12);
  font-family: monospace;
  font-size: 0.85rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-align: center;
}

body[data-theme*="light"] .atelier-auth-security-card,
:root[data-theme*="light"] .atelier-auth-security-card {
  background: #f8fafc;
  color: #0f172a;
  border-color: rgba(15, 23, 42, 0.14);
}

body[data-theme*="light"] .atelier-auth-status-text,
:root[data-theme*="light"] .atelier-auth-status-text,
body[data-theme*="light"] .atelier-auth-mini-btn:not(.primary):not(.danger),
:root[data-theme*="light"] .atelier-auth-mini-btn:not(.primary):not(.danger) {
  color: #0f172a;
}
