:root {
  color-scheme: dark;
  --background: #191a1e;
  --chrome: #16171b;
  --surface: #232328;
  --surface-raised: #292a30;
  --foreground: #eeeff3;
  --muted: #929ba8;
  --faint: #69727e;
  --primary: #9ba9b9;
  --border: #353740;
  --border-soft: #2b2d34;
  --danger: #e47a70;
  --radius: 13px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Hiragino Sans", "Noto Sans JP", sans-serif;
}

* { box-sizing: border-box; }
html, body { min-height: 100%; background: var(--background); }
body { margin: 0; color: var(--foreground); }
button, input, select, textarea { font: inherit; }
button, a, select { -webkit-tap-highlight-color: transparent; }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

.topbar {
  position: sticky; top: 0; z-index: 10; height: 64px;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 clamp(18px, 4vw, 48px); border-bottom: 1px solid var(--border-soft);
  background: rgba(22, 23, 27, .94); backdrop-filter: blur(18px);
}
.brand { display: flex; align-items: center; gap: 10px; color: inherit; text-decoration: none; }
.brand-logo { width: 32px; height: 32px; border-radius: 5px; }
.brand strong, .brand small { display: block; line-height: 1; }
.brand strong { font-size: 14px; font-weight: 700; letter-spacing: -.02em; }
.brand small { margin-top: 4px; color: var(--muted); font-size: 8px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; }
.topbar-actions { display: flex; align-items: center; gap: 10px; }
.organization-switcher select, .role-select, .add-member {
  height: 34px; padding: 0 30px 0 10px; border: 1px solid var(--border); border-radius: 8px;
  background: #202127; color: var(--foreground); font-size: 11px; font-weight: 600;
}
.organization-switcher select { min-width: 160px; }
.sign-out { color: var(--muted); font-size: 10px; text-decoration: none; }
.sign-out:hover { color: var(--foreground); }
.avatar, .member-avatar {
  display: grid; place-items: center; border: 1px solid var(--border); border-radius: 50%;
  background: var(--surface-raised); color: var(--primary); font-weight: 750;
}
.avatar { width: 32px; height: 32px; font-size: 9px; }

main { width: min(1120px, calc(100% - 48px)); margin: 0 auto; padding: 52px 0 80px; }
.workspace-heading { display: flex; align-items: end; justify-content: space-between; gap: 24px; padding-bottom: 20px; border-bottom: 1px solid var(--border-soft); }
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 7px; font-size: 27px; font-weight: 670; letter-spacing: -.035em; }
#user-name { margin-bottom: 0; color: var(--muted); font-size: 11px; }
.tabs { display: flex; gap: 4px; }
.tab { padding: 8px 12px; border: 0; border-radius: 8px; background: transparent; color: var(--muted); font-size: 11px; font-weight: 650; cursor: pointer; }
.tab:hover { color: var(--foreground); background: var(--surface); }
.tab.active { color: var(--foreground); background: var(--surface-raised); }
.status { min-height: 44px; display: flex; align-items: center; gap: 9px; color: var(--muted); font-size: 11px; }
.status.ready { min-height: 28px; }
.status.error { margin: 12px 0; min-height: auto; padding: 10px 12px; border: 1px solid #6a3e3a; border-radius: 8px; color: #efaaa4; background: rgba(103, 51, 47, .2); }
.spinner { width: 13px; height: 13px; border: 1px solid var(--border); border-top-color: var(--primary); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.view { display: none; }
.view.active { display: block; }
.section-heading { min-height: 44px; display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 14px; }
.section-heading h2 { margin: 0; font-size: 14px; font-weight: 650; }
.count { min-width: 25px; padding: 4px 7px; border-radius: 999px; background: var(--surface); color: var(--muted); font-size: 9px; text-align: center; }
.primary-button { min-height: 32px; padding: 0 12px; border: 1px solid var(--primary); border-radius: 8px; background: var(--primary); color: #181a1e; font-size: 10px; font-weight: 750; cursor: pointer; }
.primary-button:hover { filter: brightness(1.1); }
.text-button { padding: 5px 7px; border: 0; background: transparent; color: var(--muted); font-size: 9px; cursor: pointer; }
.text-button:hover { color: var(--foreground); }
.text-button.danger:hover { color: var(--danger); }

.app-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.app-card { position: relative; min-height: 150px; display: flex; flex-direction: column; justify-content: space-between; padding: 20px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); color: inherit; text-decoration: none; transition: transform .18s ease, border-color .18s ease, background .18s ease; }
.app-card:hover { transform: translateY(-2px); border-color: #697685; background: var(--surface-raised); }
.app-icon { width: 42px; height: 42px; display: grid; place-items: center; border: 1px solid #4a5562; border-radius: 9px; background: #313943; color: #b5c0cc; font-size: 11px; font-weight: 780; }
.app-icon.board { background: #34373f; }
.app-icon.studio { background: #33353c; }
.app-card h3 { margin: 26px 32px 0 0; font-size: 14px; font-weight: 640; letter-spacing: -.01em; }
.launch { position: absolute; right: 20px; bottom: 18px; color: var(--faint); font-size: 14px; }
.app-card:hover .launch { color: var(--primary); }

.member-list { overflow: hidden; border: 1px solid var(--border-soft); border-radius: var(--radius); }
.member-row { min-height: 68px; display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 12px; padding: 12px 16px; background: var(--surface); border-bottom: 1px solid var(--border-soft); }
.member-row:last-child { border-bottom: 0; }
.member-avatar { width: 34px; height: 34px; font-size: 9px; }
.member-identity strong, .member-identity span { display: block; }
.member-identity strong { margin-bottom: 4px; font-size: 11px; font-weight: 650; }
.member-identity span { color: var(--muted); font-size: 9px; }
.member-controls { display: flex; align-items: center; gap: 8px; }
.role-select { min-width: 110px; }
.managed-badge { padding: 4px 7px; border: 1px solid var(--border); border-radius: 999px; color: var(--faint); font-size: 8px; }

.group-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.group-card { min-height: 220px; padding: 18px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.group-top { display: flex; align-items: start; justify-content: space-between; gap: 16px; }
.group-top h3 { margin-bottom: 6px; font-size: 13px; font-weight: 650; }
.group-top p { margin-bottom: 0; color: var(--muted); font-size: 9px; }
.group-members { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 22px; }
.member-chip { display: inline-flex; align-items: center; gap: 5px; padding: 5px 8px; border-radius: 999px; background: var(--surface-raised); color: var(--muted); font-size: 9px; }
.member-chip button { padding: 0; border: 0; background: none; color: var(--faint); cursor: pointer; }
.member-chip button:hover { color: var(--danger); }
.add-member { height: 27px; font-size: 9px; }
.group-access { display: grid; gap: 7px; margin-top: 18px; padding-top: 15px; border-top: 1px solid var(--border-soft); }
.group-access-heading { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.group-access-heading strong { font-size: 10px; font-weight: 680; }
.group-access-heading span { color: var(--faint); font-size: 8px; }
.access-row { min-height: 34px; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 6px 8px; border-radius: 8px; background: var(--surface-raised); }
.access-label strong, .access-label small { display: block; }
.access-label strong { font-size: 9px; font-weight: 650; }
.access-label small { margin-top: 2px; color: var(--muted); font-size: 8px; }
.grant-access { height: 32px; width: 100%; padding: 0 28px 0 9px; border: 1px dashed var(--border); border-radius: 8px; background: #202127; color: var(--muted); font-size: 9px; }
.empty-state { grid-column: 1 / -1; margin: 0; padding: 42px 20px; border: 1px dashed var(--border); border-radius: var(--radius); color: var(--faint); font-size: 11px; text-align: center; }

dialog { width: min(430px, calc(100% - 32px)); padding: 0; border: 1px solid var(--border); border-radius: 14px; background: var(--surface); color: var(--foreground); box-shadow: 0 30px 80px rgba(0, 0, 0, .45); }
dialog::backdrop { background: rgba(7, 8, 10, .72); backdrop-filter: blur(3px); }
.dialog-form { display: grid; gap: 16px; padding: 22px; }
.dialog-heading { display: flex; align-items: center; justify-content: space-between; }
.dialog-heading h2 { margin: 0; font-size: 16px; }
.icon-button { width: 28px; height: 28px; border: 0; background: transparent; color: var(--muted); font-size: 20px; cursor: pointer; }
.dialog-form label { display: grid; gap: 7px; color: var(--muted); font-size: 10px; }
.dialog-form input, .dialog-form select, .dialog-form textarea { width: 100%; padding: 9px 10px; border: 1px solid var(--border); border-radius: 8px; background: #1d1e23; color: var(--foreground); }
.dialog-form textarea { min-height: 90px; resize: vertical; }
.dialog-form .primary-button { justify-self: end; min-height: 36px; }

@media (max-width: 760px) {
  .app-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .group-grid { grid-template-columns: 1fr; }
  .sign-out { display: none; }
}
@media (max-width: 560px) {
  .topbar { padding: 0 14px; }
  .brand small { display: none; }
  .organization-switcher select { max-width: 145px; min-width: 120px; }
  main { width: calc(100% - 28px); padding-top: 34px; }
  .workspace-heading { display: block; }
  .tabs { margin-top: 20px; }
  .app-grid { grid-template-columns: 1fr; }
  .member-row { grid-template-columns: auto minmax(0, 1fr); }
  .member-controls { grid-column: 2; flex-wrap: wrap; }
}
