:root {
  --accent: #ff6900;
  --accent-hover: #ed5f00;
  --text: #1d1f26;
  --text-dim: #6d727c;
  --border: #e6e8ec;
  --bg: #eef0f4;
  --panel: #e7eaef;
  --card: #fff;
  --font: "Noto Sans JP", system-ui, -apple-system, "Segoe UI", sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  max-width: 100%;
  overflow-x: hidden;
}

html:not(.portal-ready),
html:not(.portal-ready) body {
  height: 100%;
  overflow: hidden;
}

html.portal-ready,
html.portal-ready body {
  height: auto;
  overflow-x: hidden;
  overflow-y: auto;
}

body {
  font-family: var(--font);
  color: var(--text);
  background: var(--bg);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a {
  color: inherit;
  text-decoration: none;
}

img {
  display: block;
  max-width: 100%;
}

button,
input {
  font: inherit;
}

#boot[hidden],
#root[hidden],
#portal[hidden] {
  display: none !important;
}

html.portal-ready #boot,
html.portal-ready #root {
  display: none !important;
}

#portal {
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  overflow-x: hidden;
  background: var(--bg);
}

.auth-gate {
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

#boot.auth-gate {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 0;
  height: auto;
  width: auto;
  margin: 0;
  padding: 0;
  background: var(--bg);
}

html:not(.portal-ready) #root {
  height: 100%;
}

#root .auth-gate {
  min-height: 0;
  height: 100%;
}

.auth-gate__brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

.auth-gate__brand-icon {
  display: block;
  width: 64px;
  height: 64px;
  flex: none;
  margin: 0 auto;
  border-radius: 16px;
  object-fit: cover;
}

.auth-gate__brand-wordmark {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  line-height: 1.05;
  font-size: 18px;
  font-weight: 800;
  letter-spacing: 0.06em;
  color: #1a2744;
}

.auth-gate__loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  width: max-content;
  max-width: 100%;
  margin: 0 auto;
  color: var(--text-dim);
  text-align: center;
}

.auth-gate__loading p {
  margin: 0;
  font-size: 14px;
  font-weight: 700;
}

.auth-gate .auth-gate__spinner {
  display: block;
  flex: none;
  width: 28px;
  height: 28px;
  margin: 0 auto;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  transform-origin: 50% 50%;
}

.auth-gate__card[hidden] {
  display: none !important;
}

.auth-gate__loading[hidden] {
  display: none !important;
}

.auth-gate__card {
  max-width: 400px;
  width: 100%;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 24px;
  text-align: center;
}

.auth-gate__title {
  margin: 0 0 8px;
  font-size: 15px;
  font-weight: 700;
}

.auth-gate__error {
  margin: 0 0 16px;
  font-size: 12px;
  color: var(--text-dim);
  word-break: break-word;
  white-space: pre-wrap;
  text-align: left;
}

.auth-gate__button {
  border: none;
  border-radius: 20px;
  background: var(--accent);
  color: #fff;
  font-size: 14px;
  font-weight: 700;
  padding: 10px 18px;
  cursor: pointer;
}

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

.topbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  column-gap: 12px;
  position: sticky;
  top: 0;
  z-index: 20;
  box-sizing: border-box;
  width: 100%;
  min-width: 0;
  min-height: 56px;
  padding: 0 28px;
  border-bottom: 1px solid var(--border);
  background: #fff;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  flex: 1 1 auto;
}

.brand img {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  object-fit: cover;
}

.brand b {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 14px;
  font-weight: 800;
  letter-spacing: 0.04em;
  color: #1a2744;
}

/* タイトルの右に薄く出すバージョン */
.brand-version {
  flex: none;
  font-size: 11px;
  font-weight: 500;
  color: var(--text-dim);
  opacity: 0.75;
  font-variant-numeric: tabular-nums;
}

.brand-version:empty {
  display: none;
}

.topbar-auth {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  justify-self: end;
  max-width: 100%;
}

.topbar-auth[hidden] {
  display: none !important;
}

.auth-user {
  min-width: 0;
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-dim);
}

.auth-user[hidden] {
  display: none !important;
}

.auth-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
  min-height: 36px;
  padding: 0 16px;
  border: 1px solid transparent;
  border-radius: 20px;
  background: var(--accent);
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
  cursor: pointer;
}

.auth-btn:hover,
.auth-btn:focus-visible {
  background: var(--accent-hover);
  outline: none;
}

.auth-btn[hidden] {
  display: none !important;
}

.auth-btn--ghost {
  background: #fff;
  color: var(--accent);
  border-color: var(--accent);
}

.auth-btn--ghost:hover,
.auth-btn--ghost:focus-visible {
  background: var(--accent);
  color: #fff;
}

.catalog {
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr);
  gap: 32px;
  width: 100%;
  max-width: 1280px;
  min-width: 0;
  margin: 0 auto;
  padding: 28px 28px 48px;
  flex: 1;
}

.side {
  min-width: 0;
}

.search {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 40px;
  padding: 0 12px;
  margin-bottom: 16px;
  border: 1px solid #d5d9e0;
  border-radius: 8px;
  background: #fff;
  color: var(--text-dim);
}

.search input {
  width: 100%;
  border: 0;
  outline: none;
  background: transparent;
  font-size: 13px;
  color: var(--text);
}

.menu {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.menu-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  min-width: 0;
  overflow: hidden;
  text-align: left;
  border: 0;
  background: transparent;
  color: var(--text);
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  line-height: 1.35;
}

.menu-item:hover,
.menu-item:focus-visible {
  background: var(--panel);
  outline: none;
}

.menu-item.is-active {
  background: #fff;
  font-weight: 800;
  box-shadow: 0 0 0 1px #d5d9e0;
}

.menu-sub {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 2px 0 8px 12px;
}

.menu-item--sub {
  font-weight: 500;
  color: #4b5160;
}

.menu-label {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 10px 0 0;
  padding: 12px 12px 4px;
  border-top: 1px solid var(--border);
  font-size: 13px;
  font-weight: 600;
  line-height: 1.35;
  color: var(--text-dim);
}

.menu-ico {
  width: 16px;
  height: 16px;
  flex: none;
  display: block;
}

a.menu-item {
  display: flex;
}

.content h1 {
  margin: 0 0 6px;
  font-size: 28px;
  font-weight: 800;
  letter-spacing: -0.03em;
}

.content-lead {
  margin: 0 0 22px;
  font-size: 14px;
  color: var(--text-dim);
}

.group {
  margin: 0 0 28px;
}

.group:last-child {
  margin-bottom: 0;
}

.group[hidden] {
  display: none !important;
}

.group-title {
  display: none;
  margin: 0 0 12px;
  font-size: 16px;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.is-grouped .group-title {
  display: block;
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
  align-items: stretch;
}

.card {
  display: flex;
  flex-direction: column;
  min-height: 280px;
  padding: 20px 20px 18px;
  background: var(--card);
  border: 1px solid #d5d9e0;
  border-radius: 12px;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.06), 0 8px 20px rgba(15, 23, 42, 0.06);
}

.card[hidden] {
  display: none !important;
}

.card-icon {
  width: 48px;
  height: 48px;
  border-radius: 10px;
  object-fit: cover;
  margin-bottom: 14px;
}

.card h2 {
  margin: 0 0 8px;
  font-size: 18px;
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.35;
}

.card > p {
  margin: 0 0 16px;
  font-size: 13px;
  color: var(--text-dim);
  line-height: 1.65;
  flex: 1;
}

.card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: auto;
}

.card-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  align-self: flex-start;
  min-height: 36px;
  padding: 0 16px;
  border-radius: 20px;
  border: 1px solid transparent;
  background: var(--accent);
  color: #fff;
  font-size: 13px;
  font-weight: 700;
}

.card-actions .card-btn {
  align-self: auto;
}

.card-btn:hover,
.card-btn:focus-visible {
  background: var(--accent-hover);
  outline: none;
}

.card-btn--ghost {
  background: #fff;
  color: var(--accent);
  border-color: var(--accent);
}

.card-btn--ghost:hover,
.card-btn--ghost:focus-visible {
  background: var(--accent);
  color: #fff;
}

.empty {
  margin: 8px 0 0;
  font-size: 14px;
  color: var(--text-dim);
}

.foot {
  border-top: 1px solid var(--border);
  padding: 14px 28px;
  background: #fff;
}

.foot p {
  margin: 0;
  text-align: center;
  font-size: 11px;
  color: #94a3b8;
}

@media (max-width: 1100px) {
  .card-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 800px) {
  .catalog {
    grid-template-columns: 1fr;
    padding: 20px 16px 40px;
    gap: 18px;
  }

  .menu {
    display: flex;
    flex-direction: column;
  }

  .menu-sub {
    display: flex;
    flex-direction: column;
    padding-left: 12px;
  }

  .menu-label {
    grid-column: 1 / -1;
    margin-top: 4px;
  }

  .card-grid {
    grid-template-columns: 1fr;
  }

  .topbar {
    padding: 0 16px;
  }

  .brand b {
    font-size: 13px;
    letter-spacing: 0.02em;
  }

  .auth-btn {
    min-height: 32px;
    padding: 0 12px;
  }

  .auth-user {
    max-width: 96px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .auth-gate .auth-gate__spinner {
    animation: none;
  }
}
