:root {
  --ink: #0f172a;
  --ink-soft: #64748b;
  --paper: #ffffff;
  --surface: #f8fafc;
  --line: #e2e8f0;
  --accent: #0f766e;
  --l1-h: 44px;
  --l2-h: 44px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--surface);
  color: var(--ink);
  font-family: "Plus Jakarta Sans", "Hiragino Sans", sans-serif;
  -webkit-font-smoothing: antialiased;
}

body {
  display: flex;
  flex-direction: column;
}

#suite-bar-root {
  flex: 0 0 auto;
  min-height: var(--l1-h);
  z-index: 200;
}

#suite-bar-root[hidden] {
  display: none !important;
}

.auth-gate {
  position: fixed;
  inset: 0;
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(160deg, #f0fdfa 0%, #f8fafc 45%, #e2e8f0 100%);
}

.auth-gate[hidden] {
  display: none !important;
}

.auth-gate-card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 2rem 2.25rem;
  width: min(420px, 92vw);
  text-align: center;
}

.brand-mark {
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.brand-sub {
  margin-top: 0.2rem;
  font-size: 0.7rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--accent);
  font-weight: 700;
}

.auth-gate-status {
  margin: 1.25rem 0 0.35rem;
  font-size: 0.95rem;
}

.auth-gate-hint {
  margin: 0;
  font-size: 0.8rem;
  color: var(--ink-soft);
  line-height: 1.45;
}

.auth-gate-retry {
  margin-top: 1.25rem;
  appearance: none;
  border: 0;
  background: var(--accent);
  color: #fff;
  font-weight: 600;
  font-size: 0.9rem;
  padding: 0.65rem 1.1rem;
  border-radius: 8px;
  cursor: pointer;
}

/* フルビューポート: L1 の下を L2 + 工場で埋める */
.app {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  width: 100%;
  max-width: none;
}

.app[hidden] {
  display: none !important;
}

/* L2: OMS 同様の薄いコンテキストバー */
.l2-bar {
  flex: 0 0 var(--l2-h);
  height: var(--l2-h);
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0 0.85rem 0 1rem;
  background: var(--paper);
  border-bottom: 1px solid var(--line);
  z-index: 150;
}

.l2-bar[hidden] {
  display: none !important;
}

.l2-brand {
  display: flex;
  align-items: baseline;
  gap: 0.55rem;
  min-width: 0;
  flex-shrink: 1;
}

.l2-app {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--accent);
}

.l2-context {
  font-size: 0.78rem;
  color: var(--ink-soft);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.role-user {
  font-size: 0.72rem;
  color: var(--ink-soft);
  margin-left: auto;
  white-space: nowrap;
}

.context-switches {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 0.45rem;
}

.role-switch {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.65rem;
  color: var(--ink-soft);
  font-weight: 600;
  letter-spacing: 0.04em;
  white-space: nowrap;
}

.role-switch[hidden] {
  display: none !important;
}

.role-switch select {
  min-width: 7.5rem;
  max-width: 11rem;
  font: inherit;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0.28rem 0.45rem;
  background: var(--surface);
  height: 28px;
}

.l2-version {
  font-size: 0.65rem;
  color: #94a3b8;
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
}

/* 工場 UI: フル幅・フル残り高さ（サイドバーは iframe 内） */
.main,
.main.is-workspace {
  flex: 1;
  min-height: 0;
  width: 100%;
  max-width: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
}

.plant-frame {
  flex: 1;
  width: 100%;
  height: 100%;
  min-height: 0;
  border: 0;
  display: block;
  background: var(--paper);
}

@media (max-width: 900px) {
  .l2-bar {
    height: auto;
    min-height: var(--l2-h);
    flex-wrap: wrap;
    padding: 0.4rem 0.75rem;
    gap: 0.4rem;
  }

  .role-user {
    margin-left: 0;
    order: 3;
    width: 100%;
  }

  .context-switches {
    width: 100%;
    flex-wrap: wrap;
  }

  .role-switch select {
    min-width: 0;
    flex: 1;
  }
}
