/* Altech Launcher. Tokens first (same pattern as the Altech UI kit); the
   dark palette matches the Business Hub. */
:root {
  --gap: 14px; --pad: 16px; --radius: 12px; --bar: 56px;
  --bg: #f6f7f9; --surface: #fff; --text: #1d2330; --muted: #667085;
  --line: #e3e6eb; --accent: #2563eb; --danger: #dc2626; --shadow: #0002;
  --tile: 104px; --ico: 64px;
}
:root[data-size="small"] { --tile: 84px; --ico: 48px; }
:root[data-size="large"] { --tile: 128px; --ico: 80px; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) { --bg: #071226; --surface: #0f1b33; --text: #e6ebf5; --muted: #94a3b8; --line: #1e2c4a; --shadow: #0008; }
}
:root[data-theme="dark"] { --bg: #071226; --surface: #0f1b33; --text: #e6ebf5; --muted: #94a3b8; --line: #1e2c4a; --shadow: #0008; }

* { box-sizing: border-box; }
html, body { min-height: 100%; margin: 0; }
body { background: var(--bg); color: var(--text); font: 15px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif; }
[hidden] { display: none !important; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

input, select, button, textarea { font: inherit; color: inherit; }
input[type="text"], input[type="email"], input[type="password"], input[type="url"], input[type="search"], select {
  background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; min-height: 36px;
}
select { cursor: pointer; }

.btn { border: 1px solid var(--line); background: var(--surface); border-radius: 8px; padding: 8px 14px; cursor: pointer; font-weight: 600; min-height: 36px; }
.btn.small { padding: 4px 10px; min-height: 28px; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover:not(:disabled) { filter: brightness(1.1); }
.btn.dark { background: #0f172a; border-color: #0f172a; color: #fff; }
:root[data-theme="dark"] .btn.dark, .auth .btn.dark { background: #e2e8f0; border-color: #e2e8f0; color: #0f172a; }
.btn.danger { color: var(--danger); }
.btn.wide { width: 100%; margin-top: 10px; padding: 12px 14px; border-radius: 12px; }
.btn:disabled { opacity: .7; cursor: default; }
.link-btn { background: none; border: 0; color: var(--muted); font-weight: 700; cursor: pointer; padding: 4px; }
.link-btn:hover { color: var(--accent); }

/* Top bar */
.topbar { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 10px; min-height: var(--bar);
  padding: 8px var(--pad); background: var(--surface); border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 800; letter-spacing: .01em; }
.brand img { border-radius: 6px; }
.search { flex: 1 1 200px; min-width: 120px; max-width: 520px; margin: 0 auto 0 8px; }
.sort-wrap select { max-width: 190px; }
.icon-btn { border: 1px solid var(--line); background: var(--surface); border-radius: 8px; height: 36px; min-width: 36px; padding: 0 10px; cursor: pointer; font-size: 18px; line-height: 1; }
.icon-btn:hover { border-color: var(--accent); }
.icon-btn.info { border-radius: 50%; font-style: italic; font-weight: 700; font-family: Georgia, serif; }
.status { font-size: 12px; color: var(--muted); white-space: nowrap; }
.status[data-state="local"] { color: #d97706; }

.idle-warning { position: sticky; top: var(--bar); z-index: 4; display: flex; gap: 12px; align-items: center; justify-content: center;
  padding: 8px var(--pad); background: #fef3c7; color: #78350f; font-weight: 600; border-bottom: 1px solid #fcd34d; }

/* Grid of tiles */
.main { padding: var(--pad); max-width: 1400px; margin: 0 auto; }
.meta { display: flex; justify-content: space-between; gap: 12px; color: var(--muted); font-size: 13px; margin-bottom: 8px; }
.row-tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(var(--tile), 1fr)); gap: var(--gap); }
.group { margin: 18px 0 8px; font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.group:first-child { margin-top: 0; }
.tile { position: relative; display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 12px 6px 10px; text-decoration: none; color: var(--text);
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); cursor: pointer; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
.tile:hover { border-color: var(--accent); box-shadow: 0 4px 16px var(--shadow); }
.can-drag .tile[data-id] { cursor: grab; }
.tile .ico { width: var(--ico); height: var(--ico); border-radius: 18%; display: grid; place-items: center; color: #fff; box-shadow: inset 0 -3px 0 #0003; }
.tile .ico svg { width: 56%; height: 56%; }
.tile .ico.has-logo { background: #fff !important; box-shadow: inset 0 0 0 1px #0001, inset 0 -3px 0 #0001; overflow: hidden; }
.tile .ico.logo-full { background: transparent !important; box-shadow: 0 0 0 1px #0002; }
.tile .ico.logo-round { background: transparent !important; box-shadow: none; border-radius: 50%; }
.tile .ico.logo-round img { width: 100%; height: 100%; object-fit: contain; }
.tile .ico.logo-full img { width: 100%; height: 100%; object-fit: cover; }
.tile .ico img { width: 70%; height: 70%; object-fit: contain; pointer-events: none; }
.tile .name { max-width: 100%; text-align: center; font-weight: 600; font-size: 13px; line-height: 1.25; overflow-wrap: anywhere; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.tile-menu { position: absolute; top: 2px; right: 2px; width: 28px; height: 28px; border: 0; border-radius: 6px; background: transparent; color: var(--muted); cursor: pointer; font-size: 18px; line-height: 1; opacity: 0; }
.tile:hover .tile-menu, .tile:focus-within .tile-menu { opacity: 1; }
@media (hover: none) { .tile-menu { opacity: .7; } }
.tile-menu:hover { background: var(--bg); color: var(--text); }
.tile.add { border-style: dashed; background: transparent; color: var(--muted); font: inherit; }
.tile.add .ico { background: var(--bg); color: var(--muted); font-size: 32px; box-shadow: none; }
.tile.ghost { opacity: .35; }
.tile.chosen { box-shadow: 0 8px 24px var(--shadow); }
.empty { text-align: center; color: var(--muted); padding: 48px 0; }

/* Drawers */
.scrim { position: fixed; inset: 0; background: #0006; z-index: 9; }
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(380px, 100vw); background: var(--surface); border-left: 1px solid var(--line); box-shadow: -8px 0 24px var(--shadow); z-index: 10; overflow-y: auto; }
.drawer-head { display: flex; justify-content: space-between; align-items: center; padding: var(--pad); border-bottom: 1px solid var(--line); }
.drawer-body { padding: var(--pad); }
.drawer-body p { margin: 0 0 12px; }
.row { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 12px; }
.row.stack { flex-direction: column; align-items: stretch; }
.muted { color: var(--muted); font-size: 13px; }
hr { border: 0; border-top: 1px solid var(--line); margin: 16px 0; }
kbd { background: var(--bg); border: 1px solid var(--line); border-radius: 4px; padding: 0 5px; font-size: 12px; }

/* Editor dialog */
.editor { width: min(440px, 94vw); border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); color: var(--text); padding: 20px; }
.editor::backdrop { background: #0007; }
.editor h2 { margin: 0 0 8px; font-size: 18px; }
.editor label, .editor .lbl { display: block; margin: 12px 0 4px; font-size: 13px; font-weight: 700; color: var(--muted); }
.editor input[type="text"], .editor input[type="url"] { width: 100%; }
.editor label.check { display: flex; gap: 8px; align-items: center; font-weight: 600; color: var(--text); }
.swatches, .glyphs { display: flex; flex-wrap: wrap; gap: 8px; }
.swatch { width: 28px; height: 28px; border-radius: 50%; border: 2px solid transparent; cursor: pointer; }
.swatch.on { border-color: var(--text); box-shadow: 0 0 0 2px var(--surface) inset; }
.glyph { width: 40px; height: 40px; border-radius: 10px; border: 1px solid var(--line); background: var(--bg); color: var(--text); cursor: pointer; padding: 8px; }
.glyph.on { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 15%, var(--bg)); }
.glyph svg { width: 100%; height: 100%; }
.editor-actions { display: flex; gap: 8px; align-items: center; margin-top: 18px; }
.grow { flex: 1; }

/* Sign-in (matches the Hub's card) */
.auth { min-height: 100dvh; display: flex; align-items: center; justify-content: center; padding: 24px 16px; }
.auth-card { width: 100%; max-width: 448px; background: var(--surface); border: 1px solid var(--line); border-radius: 24px; padding: 32px; box-shadow: 0 20px 50px var(--shadow); }
.auth-logo { display: flex; justify-content: center; margin-bottom: 20px; }
.auth-logo img { width: 160px; max-width: 60%; border-radius: 16px; border: 1px solid var(--line); }
.auth-card h1 { margin: 0 0 6px; text-align: center; font-size: 24px; font-weight: 900; }
.auth-sub { margin: 0 0 24px; text-align: center; color: var(--muted); }
.auth-form label { display: block; margin: 14px 0 6px; font-size: 13px; font-weight: 700; color: var(--muted); }
.auth-form input { width: 100%; padding: 12px; border-radius: 12px; }
.auth-toggle { text-align: right; }
.auth-help { font-size: 12px; color: var(--muted); }
.auth-error { margin: 12px 0 0; padding: 10px 12px; border-radius: 12px; background: #fef2f2; color: #b91c1c; border: 1px solid #fecaca; font-weight: 700; font-size: 14px; }
.auth-notice { margin: 0 0 16px; padding: 10px 12px; border-radius: 12px; background: #fffbeb; color: #92400e; border: 1px solid #fde68a; font-weight: 700; font-size: 14px; }
.auth-foot { margin-top: 20px; text-align: center; font-size: 12px; font-weight: 700; color: var(--muted); }
.auth-foot p { margin: 0; }

@media (max-width: 640px) {
  .brand span { display: none; }
  .topbar { gap: 6px; flex-wrap: wrap; }
  .search { order: 5; flex-basis: 100%; max-width: none; margin: 0; }
  .status { display: none; }
  .sort-wrap select { max-width: 130px; }
  .auth-card { padding: 24px; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

/* Countdown digits keep a fixed width so the button beside them does not wobble. */
.idle-warning strong { display: inline-block; min-width: 2ch; text-align: right; font-variant-numeric: tabular-nums; }
