/* Login, top bar, launcher, dock, windows, dialogs, toasts, menus. */

/* app tiles (launcher, dock, window title) */
.tile {
  --t1: #6366f1; --t2: #4338ca;
  width: 52px; height: 52px; border-radius: 14px; flex: none; display: grid; place-items: center; position: relative;
  background: linear-gradient(145deg, var(--t1), var(--t2)); color: #fff; overflow: hidden;
  box-shadow: 0 6px 16px -6px color-mix(in srgb, var(--t2) 70%, transparent), inset 0 1px 0 rgba(255, 255, 255, .28), inset 0 -1px 0 rgba(0, 0, 0, .12);
}
.tile::after { content: ""; position: absolute; inset: 0; background: linear-gradient(180deg, rgba(255, 255, 255, .22), transparent 50%); pointer-events: none; }
.tile .i { width: 46%; height: 46%; stroke-width: 1.9; filter: drop-shadow(0 1px 1px rgba(0, 0, 0, .18)); }
.tile img { width: 100%; height: 100%; object-fit: cover; }
.tile.img { background: var(--surface); }
.tile.img::after { display: none; }
.tile.sm { width: 22px; height: 22px; border-radius: 6px; box-shadow: none; }
.tile.md { width: 36px; height: 36px; border-radius: 10px; }
.tile.xl { width: 64px; height: 64px; border-radius: 18px; }

/* login */
.login { height: 100%; display: grid; place-items: center; padding: 20px; }
.login .card {
  width: min(380px, 100%); padding: 32px 28px 26px; border-radius: var(--r-xl);
  background: var(--glass-strong); backdrop-filter: blur(24px) saturate(1.6); -webkit-backdrop-filter: blur(24px) saturate(1.6);
  border: 1px solid var(--glass-line); box-shadow: var(--sh-win); animation: card-in .5s var(--ease) both;
}
.login .brand { display: flex; flex-direction: column; align-items: center; gap: 12px; margin-bottom: 20px; text-align: center; }
.login h1 { margin: 0; font-size: 20px; font-weight: 650; letter-spacing: -.02em; }
.login .brand p { margin: 0; color: var(--text-2); }
.login .field { margin: 10px 0; }
.login input { height: 40px; }
.login .btn.block { margin-top: 14px; }
@keyframes card-in { from { opacity: 0; transform: translateY(12px) scale(.98); } }

/* shell */
#desk { height: 100%; display: flex; flex-direction: column; animation: fade-in .4s var(--ease); }
#topbar {
  height: 34px; flex: none; display: flex; align-items: center; gap: 6px; padding: 0 10px; z-index: 1000;
  background: var(--glass); backdrop-filter: blur(20px) saturate(1.6); -webkit-backdrop-filter: blur(20px) saturate(1.6);
  border-bottom: 1px solid var(--line);
}
.tb-btn { display: inline-flex; align-items: center; gap: 7px; height: 26px; padding: 0 9px; border: 0; border-radius: 7px;
  background: transparent; cursor: pointer; font-weight: 600; transition: background var(--t-fast); }
.tb-btn:hover { background: var(--surface-3); }
.tb-btn .logo { width: 18px; height: 18px; border-radius: 5px; background: linear-gradient(145deg, var(--accent-2), var(--accent)); display: grid; place-items: center; color: #fff; }
.tb-btn .logo .i { width: 12px; height: 12px; stroke-width: 2.4; }
.tb-pill { display: inline-flex; align-items: center; gap: 7px; height: 24px; padding: 0 10px; border-radius: 99px;
  font-size: 12px; color: var(--text-2); background: var(--surface-3); }
.tb-pill .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 0 3px var(--ok-soft); }
.tb-pill .dot.off { background: var(--text-3); box-shadow: none; }
#clock { font-variant-numeric: tabular-nums; font-weight: 550; font-size: 12.5px; color: var(--text-2); padding: 0 4px; }
#workspace { position: relative; flex: 1; overflow: hidden; }

/* launcher (home) */
#home { position: absolute; inset: 0; overflow: auto; padding: 28px 28px 110px; }
.home-section { margin-bottom: 26px; }
.home-section h2 { margin: 0 0 12px 6px; font-size: 12px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--text-2); }
.launcher { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, 92px); gap: 10px; }
.launcher button {
  width: 92px; padding: 10px 4px 8px; border: 0; background: transparent; border-radius: var(--r); cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 8px; color: var(--text);
  transition: background var(--t-fast), transform var(--t) var(--ease-spring); animation: rise-in .4s var(--ease) both;
}
.launcher li:nth-child(2) button { animation-delay: 30ms; } .launcher li:nth-child(3) button { animation-delay: 60ms; }
.launcher li:nth-child(4) button { animation-delay: 90ms; } .launcher li:nth-child(5) button { animation-delay: 120ms; }
.launcher li:nth-child(6) button { animation-delay: 150ms; } .launcher li:nth-child(n+7) button { animation-delay: 180ms; }
.launcher button:hover { background: var(--glass); transform: translateY(-2px); }
.launcher button:active { transform: scale(.95); }
.launcher button:hover .tile { transform: scale(1.04); }
.launcher .tile { transition: transform var(--t) var(--ease-spring); }
.launcher .nm { font-size: 12px; font-weight: 500; text-align: center; line-height: 1.25; max-width: 100%;
  overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow-wrap: anywhere; }
.launcher .sub { font-size: 10.5px; color: var(--text-2); margin-top: -6px; }

/* dock */
#dock {
  position: absolute; left: 50%; bottom: 12px; transform: translateX(-50%); z-index: 900;
  display: flex; align-items: flex-end; gap: 6px; padding: 7px; border-radius: 20px; max-width: calc(100vw - 24px); overflow-x: auto;
  background: var(--glass); backdrop-filter: blur(24px) saturate(1.8); -webkit-backdrop-filter: blur(24px) saturate(1.8);
  border: 1px solid var(--glass-line); box-shadow: 0 10px 30px -10px rgba(15, 23, 42, .3), 0 0 0 1px var(--line);
  animation: dock-in .5s var(--ease) both;
}
@keyframes dock-in { from { opacity: 0; transform: translate(-50%, 20px); } }
.dock-item { position: relative; border: 0; background: transparent; padding: 0; cursor: pointer; border-radius: 13px;
  transition: transform var(--t) var(--ease-spring); }
.dock-item .tile { width: 44px; height: 44px; border-radius: 12px; }
.dock-item:hover { transform: translateY(-5px) scale(1.08); }
.dock-item:active { transform: translateY(-2px) scale(.96); }
.dock-item .run { position: absolute; left: 50%; bottom: -5px; width: 4px; height: 4px; margin-left: -2px; border-radius: 50%;
  background: var(--text-2); opacity: 0; transition: opacity var(--t); }
.dock-item.open .run { opacity: 1; }
.dock-item.active .run { background: var(--accent); width: 14px; margin-left: -7px; border-radius: 3px; }
.dock-item[data-tip]::before {
  content: attr(data-tip); position: absolute; bottom: calc(100% + 12px); left: 50%; transform: translate(-50%, 4px);
  padding: 4px 9px; border-radius: 7px; font-size: 12px; font-weight: 500; white-space: nowrap; pointer-events: none;
  background: var(--text); color: var(--surface); opacity: 0; transition: opacity var(--t-fast), transform var(--t-fast) var(--ease);
}
.dock-item:hover::before, .dock-item:focus-visible::before { opacity: .92; transform: translate(-50%, 0); transition-delay: .25s; }
.dock-sep { width: 1px; align-self: stretch; margin: 6px 3px; background: var(--line-strong); }
/* windows */
.win {
  position: absolute; display: flex; flex-direction: column; overflow: hidden; min-width: 320px; min-height: 220px;
  background: var(--surface); border-radius: var(--r-lg); box-shadow: var(--sh-win-dim);
  transition: box-shadow var(--t) var(--ease); transform-origin: center 30%;
  animation: win-open var(--t-slow) var(--ease) both;
}
.win.focused { box-shadow: var(--sh-win); }
.win.closing { animation: win-close 160ms var(--ease) both; pointer-events: none; }
.win.maxed { inset: 0 !important; width: auto !important; height: auto !important; border-radius: 0; }
.win.animating { transition: left var(--t-slow) var(--ease), top var(--t-slow) var(--ease), width var(--t-slow) var(--ease),
  height var(--t-slow) var(--ease), inset var(--t-slow) var(--ease), border-radius var(--t-slow) var(--ease); }
@keyframes win-open { from { opacity: 0; transform: scale(.94) translateY(8px); } }
@keyframes win-close { to { opacity: 0; transform: scale(.95) translateY(4px); } }
.win-head {
  flex: none; height: 42px; display: flex; align-items: center; gap: 10px; padding: 0 6px 0 12px;
  background: var(--surface-2); border-bottom: 1px solid var(--line); user-select: none; touch-action: none; cursor: default;
}
.win-title { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; font-size: 13px; }
.win:not(.focused) .win-title, .win:not(.focused) .win-head .tile { opacity: .55; }
.win-ctl { display: flex; gap: 2px; }
.win-ctl button { width: 30px; height: 28px; display: grid; place-items: center; border: 0; background: transparent; border-radius: 7px;
  cursor: pointer; color: var(--text-2); transition: background var(--t-fast), color var(--t-fast); }
.win-ctl button:hover { background: var(--surface-3); color: var(--text); }
.win-ctl button.close:hover { background: var(--danger); color: #fff; }
.win-ctl .i { width: 15px; height: 15px; }
.win-body { flex: 1; min-height: 0; overflow: auto; position: relative; }
.win-resize { position: absolute; right: 0; bottom: 0; width: 18px; height: 18px; cursor: nwse-resize; touch-action: none; }
.win-resize::after { content: ""; position: absolute; right: 5px; bottom: 5px; width: 6px; height: 6px;
  border-right: 2px solid var(--line-strong); border-bottom: 2px solid var(--line-strong); border-radius: 0 0 2px 0; }

/* dialogs */
dialog {
  border: 0; padding: 22px; width: min(460px, calc(100vw - 24px)); max-height: calc(100dvh - 40px); overflow: auto;
  border-radius: var(--r-xl); background: var(--surface); color: var(--text); box-shadow: var(--sh-win);
}
dialog[open] { animation: dlg-in var(--t-slow) var(--ease-spring) both; }
dialog.closing { animation: dlg-out 150ms var(--ease) both; }
dialog::backdrop { background: rgba(15, 23, 42, .32); backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px); animation: fade-in var(--t) var(--ease); }
dialog.closing::backdrop { opacity: 0; transition: opacity 150ms; }
@keyframes dlg-in { from { opacity: 0; transform: translateY(10px) scale(.96); } }
@keyframes dlg-out { to { opacity: 0; transform: translateY(6px) scale(.97); } }
.dlg-head { display: flex; gap: 12px; align-items: flex-start; margin-bottom: 6px; }
.dlg-icon { width: 36px; height: 36px; border-radius: 11px; display: grid; place-items: center; flex: none; background: var(--accent-soft); color: var(--accent); }
.dlg-icon.danger { background: var(--danger-soft); color: var(--danger); }
.dlg-icon .i { width: 18px; height: 18px; }
dialog h2 { margin: 6px 0 2px; font-size: 16px; font-weight: 650; letter-spacing: -.01em; }
dialog p { margin: 6px 0; color: var(--text-2); }
dialog .acts { display: flex; gap: 8px; justify-content: flex-end; margin-top: 20px; flex-wrap: wrap; }
.target { display: flex; gap: 8px; align-items: center; margin: 12px 0 4px; padding: 9px 12px; border-radius: var(--r-sm);
  background: var(--surface-2); border: 1px solid var(--line); font: 12.5px/1.45 var(--mono); overflow-wrap: anywhere; }

/* popover menu */
.menu { position: fixed; z-index: 4000; min-width: 180px; padding: 5px; border-radius: var(--r); background: var(--glass-strong);
  backdrop-filter: blur(20px) saturate(1.6); -webkit-backdrop-filter: blur(20px) saturate(1.6);
  border: 1px solid var(--line); box-shadow: var(--sh-win); animation: menu-in 140ms var(--ease) both; transform-origin: top right; }
@keyframes menu-in { from { opacity: 0; transform: scale(.95) translateY(-4px); } }
.menu button { display: flex; width: 100%; align-items: center; gap: 10px; height: 34px; padding: 0 10px; border: 0; border-radius: 7px;
  background: transparent; cursor: pointer; text-align: left; }
.menu button:hover, .menu button:focus-visible { background: var(--accent-soft); color: var(--accent); outline: none; }
.menu button.danger { color: var(--danger); }
.menu button.danger:hover { background: var(--danger-soft); color: var(--danger); }
.menu hr { border: 0; border-top: 1px solid var(--line); margin: 4px 2px; }

/* toasts */
.toasts { position: fixed; left: 50%; bottom: 88px; transform: translateX(-50%); display: flex; flex-direction: column; align-items: center;
  gap: 8px; z-index: 5000; pointer-events: none; width: min(440px, calc(100vw - 24px)); }
.toast { display: flex; gap: 9px; align-items: center; padding: 10px 14px 10px 12px; border-radius: 12px; pointer-events: auto;
  background: var(--glass-strong); backdrop-filter: blur(20px) saturate(1.6); -webkit-backdrop-filter: blur(20px) saturate(1.6);
  border: 1px solid var(--line); box-shadow: var(--sh-win); font-weight: 500; animation: toast-in var(--t-slow) var(--ease-spring) both; }
.toast .i { color: var(--ok); }
.toast.err .i { color: var(--danger); }
.toast.warn .i { color: var(--warn); }
.toast.info .i { color: var(--accent); }
.toast.leaving { animation: toast-out 200ms var(--ease) both; }
@keyframes toast-in { from { opacity: 0; transform: translateY(12px) scale(.96); } }
@keyframes toast-out { to { opacity: 0; transform: translateY(6px) scale(.97); } }

/* switcher sheet (mobile) */
#switcher .list { margin: 8px -6px 0; }
.mobile-only { display: none; }

/* ---- mobile: one app at a time ---- */
@media (max-width: 760px), (pointer: coarse) and (max-width: 1024px) {
  .mobile-only { display: revert; }
  .desktop-only { display: none !important; }
  body { font-size: 15px; }
  #topbar { height: calc(48px + env(safe-area-inset-top)); padding: env(safe-area-inset-top) 6px 0; }
  #mobile-title { flex: 1; min-width: 0; font-weight: 650; font-size: 16px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-align: center; }
  .tb-btn { height: 36px; padding: 0 10px; }
  .tb-btn .tb-label { display: none; }
  #home { padding: 22px 16px calc(120px + env(safe-area-inset-bottom)); }
  .launcher { grid-template-columns: repeat(4, 1fr); gap: 14px 6px; }
  .launcher button { width: 100%; padding: 6px 0; }
  .launcher button:hover { background: transparent; transform: none; }
  .launcher .tile { width: 58px; height: 58px; border-radius: 16px; }
  #dock { bottom: calc(12px + env(safe-area-inset-bottom)); border-radius: 26px; padding: 9px; gap: 12px; }
  #dock.hidden-m { opacity: 0; pointer-events: none; transform: translate(-50%, 30px); transition: opacity var(--t), transform var(--t) var(--ease); }
  .dock-item .tile { width: 54px; height: 54px; border-radius: 15px; }
  .dock-item:hover { transform: none; }
  .dock-item[data-tip]::before { display: none; }
  .win { inset: 0 !important; width: auto !important; height: auto !important; border-radius: 0; box-shadow: none; min-width: 0;
    animation: win-open-m var(--t-slow) var(--ease) both; }
  .win:not(.focused) { display: none; }
  .win.closing { animation: win-close-m 200ms var(--ease) both; }
  @keyframes win-open-m { from { opacity: .4; transform: translateY(24px); } }
  @keyframes win-close-m { to { opacity: 0; transform: translateY(24px); } }
  .win-head { display: none; }
  .win-resize { display: none; }
  .btn { height: 40px; }
  .btn.icon { width: 40px; }
  .btn.sm { height: 34px; } .btn.sm.icon { width: 34px; }
  input, select, textarea { font-size: 16px; min-height: 42px; }
  .toasts { bottom: calc(100px + env(safe-area-inset-bottom)); }
  dialog.sheet, dialog { margin: auto 0 0; width: 100vw; max-width: 100vw; border-radius: 22px 22px 0 0; padding-bottom: calc(22px + env(safe-area-inset-bottom)); }
  dialog[open] { animation: sheet-in var(--t-slow) var(--ease) both; }
  dialog.closing { animation: sheet-out 200ms var(--ease) both; }
  @keyframes sheet-in { from { transform: translateY(100%); } }
  @keyframes sheet-out { to { transform: translateY(100%); } }
  dialog .acts .btn { flex: 1; }
}
