:root {
  color-scheme: light;
  --shell-bg: #f5f5f5;
  --card-bg: #ffffff;
  --card-fg: #111827;
  --accent: #ec640f;
  --muted: #6b7280;
  --divider: #e5e7eb;
  --link: #013fc1;
  --error: #ef4444;
}

/* Dark is a choice (the theme button in the header), not the system setting. */
:root[data-theme="dark"] {
  color-scheme: dark;
  --shell-bg: #0a0a0a;
  --card-bg: #141414;
  --card-fg: #e5e7eb;
  --muted: #9ca3af;
  --divider: #2a2a2a;
  --link: #34dff4;
}

* { box-sizing: border-box; }

html, body { height: 100%; margin: 0; }

body {
  display: flex;
  flex-direction: column;
  background: var(--shell-bg);
  color: var(--card-fg);
  font: 14px/1.45 'Space Grotesk', 'Segoe UI', system-ui, -apple-system, Roboto, sans-serif;
}

a { color: var(--link); }

.bar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 10px 16px;
  background: var(--card-bg);
  border-bottom: 1px solid var(--divider);
}
.theme {
  font: inherit; font-size: 13px; color: var(--muted); cursor: pointer;
  background: none; border: 1px solid var(--divider); border-radius: 6px; padding: 4px 10px;
}
.theme:hover, .theme:focus-visible { color: var(--link); border-color: var(--link); outline: none; }
.bar .brand { width: 22px; height: 22px; flex: none; }
.bar h1 { margin: 0; font-size: 16px; font-weight: 600; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.back, .signout { text-decoration: none; white-space: nowrap; }
.signout { font-size: 13px; color: var(--muted); }
.signout:hover, .signout:focus-visible { color: var(--link); }

button.primary {
  margin-top: 16px; padding: 8px 20px; font: inherit; font-weight: 600; cursor: pointer;
  color: #fff; background: var(--accent); border: 0; border-radius: 6px;
}

.banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 16px;
  background: var(--error);
  color: #fff;
}
.banner[hidden], .back[hidden] { display: none; }
.banner button {
  background: none; border: 0; color: inherit; font-size: 20px; line-height: 1; cursor: pointer;
}
.banner .banner-action {
  margin-left: auto; padding: 4px 12px; font-size: 14px; font-weight: 600;
  border: 1px solid currentColor; border-radius: 6px;
}
.banner .banner-action[hidden] { display: none; }
.banner.ok { background: #10b981; }

main { flex: 1; min-height: 0; overflow: auto; }

/* Home */
.home { max-width: 1100px; margin: 0 auto; padding: 16px; }
.home h2 { margin: 24px 0 12px; font-size: 14px; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); }
.home h2:first-child { margin-top: 0; }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; }
.tile {
  display: block;
  padding: 14px 16px;
  background: var(--card-bg);
  color: inherit;
  text-decoration: none;
  border: 1px solid var(--divider);
  border-radius: 8px;
}
.tile:hover, .tile:focus-visible { border-color: var(--accent); outline: none; }
.tile[aria-disabled="true"] { opacity: .55; pointer-events: none; }
.tile .name { font-weight: 600; }
.tile .desc { margin-top: 4px; color: var(--muted); }
.tile .cat { margin-top: 8px; font-size: 12px; color: var(--accent); }
.empty, .message { max-width: 560px; margin: 64px auto; padding: 0 16px; text-align: center; color: var(--muted); }
.message h2 { color: var(--card-fg); }

/* App host */
.host { height: 100%; }
.host iframe { display: block; width: 100%; height: 100%; border: 0; background: var(--shell-bg); }

.message .detail { font-family: ui-monospace, Consolas, monospace; font-size: 12px; color: var(--muted); word-break: break-word; }
