:root {
  --ink: #172a24;
  --muted: #66736e;
  --brand: #164f40;
  --brand-deep: #103d32;
  --brand-soft: #e6f2ed;
  --line: #dbe3df;
  --line-strong: #becdc6;
  --paper: #ffffff;
  --canvas: #f5f7f4;
  --blue: #2f6fe4;
  font-family: Inter, "Noto Sans JP", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--canvas);
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; background: radial-gradient(circle at 85% 8%, #e6f3ed 0, transparent 29rem), var(--canvas); }
button, select { font: inherit; }
button { cursor: pointer; }
.preview-warning { position: sticky; top: 0; z-index: 30; padding: 8px 20px; border-bottom: 1px solid #df9f92; color: #7e2f25; background: #ffd9d3; text-align: center; font-size: 12px; font-weight: 800; }
.workspace-shell { display: grid; grid-template-columns: 272px minmax(0, 1fr); min-height: 100vh; }
.portal-sidebar { position: sticky; top: 0; z-index: 21; display: flex; flex-direction: column; align-self: start; width: 272px; height: 100vh; padding: 19px 14px 16px; overflow-y: auto; color: #eef7f2; border-right: 1px solid #234b40; background: linear-gradient(160deg, #173e34 0%, #102e28 72%, #0b241f 100%); }
.site-header { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; justify-content: space-between; gap: 24px; min-height: 72px; padding: 12px clamp(18px, 4vw, 56px); border-bottom: 1px solid var(--line); background: rgba(255,255,255,.92); backdrop-filter: blur(16px); }
.preview-warning:not([hidden]) + .workspace-shell .portal-sidebar, .preview-warning:not([hidden]) + .workspace-shell .site-header { top: 33px; }
.preview-warning:not([hidden]) + .workspace-shell .portal-sidebar { height: calc(100vh - 33px); }
.workspace-main { min-width: 0; }
.brand { display: inline-flex; align-items: center; gap: 11px; padding: 0 7px; color: inherit; text-decoration: none; }
.brand-mark { display: grid; place-items: center; width: 42px; height: 42px; border-radius: 13px; color: var(--brand-deep); background: #f4cf68; font-weight: 900; }
.brand strong, .brand small { display: block; }
.brand strong { font-size: 16px; }
.brand small { margin-top: 2px; color: #b9cec4; font-size: 10px; letter-spacing: .08em; }
.portal-nav { display: grid; gap: 24px; margin-top: 34px; }
.nav-group { --group-accent: #d9ad4d; --group-heading-bg: rgba(255, 206, 103, .17); --group-heading-text: #ffe4a8; --group-item-bg: rgba(255, 206, 103, .09); display: grid; gap: 3px; margin: 0; padding-left: 6px; border-left: 2px solid var(--group-accent); }
.nav-group:nth-child(2) { --group-accent: #52bd91; --group-heading-bg: rgba(82, 189, 145, .18); --group-heading-text: #bdf0d9; --group-item-bg: rgba(82, 189, 145, .1); }
.nav-group:nth-child(3) { --group-accent: #74a8ef; --group-heading-bg: rgba(116, 168, 239, .18); --group-heading-text: #cfe2ff; --group-item-bg: rgba(116, 168, 239, .1); }
.nav-group-title { margin: 0 3px 7px -2px; padding: 8px 10px; border-radius: 8px; color: var(--group-heading-text); background: var(--group-heading-bg); font-size: 15px; font-weight: 900; letter-spacing: .02em; line-height: 1.45; }
.portal-nav-item { display: flex; align-items: center; min-height: 41px; padding: 8px 11px; border: 1px solid transparent; border-radius: 11px; color: #e1eee8; background: var(--group-item-bg); font-size: 14px; font-weight: 800; text-decoration: none; }
.portal-nav-item:hover, .portal-nav-item:focus-visible { border-color: rgba(255,255,255,.15); color: white; background: rgba(255,255,255,.07); outline: none; }
.portal-nav-item.active { border-color: transparent; color: #15382e; background: #f4fbf7; box-shadow: 0 8px 22px rgba(0,0,0,.14); }
.sidebar-note { margin: 26px 8px 0; padding-top: 14px; color: #91aca0; border-top: 1px solid rgba(255,255,255,.12); font-size: 9px; line-height: 1.65; }
.page-context strong, .page-context small { display: block; }
.page-context strong { font-size: 13px; }
.page-context small { margin-top: 3px; color: var(--muted); font-size: 9px; }
.identity { display: flex; align-items: center; gap: 12px; }
.identity span, .identity strong, .identity small { display: block; }
.identity strong { font-size: 11px; }
.identity small { color: var(--muted); font-size: 9px; }
#app { width: min(1500px, calc(100% - 32px)); margin: 0 auto; padding: 34px 0 110px; outline: none; }
.portal-shell { display: grid; gap: 18px; }
.portal-section { scroll-margin-top: 96px; }
.hero { display: flex; align-items: flex-end; justify-content: space-between; gap: 30px; padding: 8px 4px 14px; }
.hero h1 { margin: 5px 0 8px; font-size: clamp(26px, 4vw, 43px); line-height: 1.12; letter-spacing: -.045em; }
.hero p { max-width: 780px; margin: 0; color: var(--muted); line-height: 1.7; }
.eyebrow { color: #3d8b6e; font-size: 10px; font-weight: 900; letter-spacing: .14em; text-transform: uppercase; }
.hero-status { display: grid; gap: 8px; min-width: 180px; justify-items: end; }
.hero-status strong { font-size: 17px; }
.role-summary { display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 15px 18px; border: 1px solid #bfd6cc; border-radius: 16px; background: #f0f8f4; }
.role-summary strong, .role-summary span { display: block; }
.role-summary strong { font-size: 12px; }
.role-summary div > span { margin-top: 3px; color: var(--muted); font-size: 10px; }
.panel { overflow: hidden; border: 1px solid var(--line); border-radius: 20px; background: var(--paper); box-shadow: 0 14px 42px rgba(27, 52, 43, .06); }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 24px; padding: 18px 20px; border-bottom: 1px solid var(--line); }
.panel-head h2 { margin: 0; font-size: 17px; letter-spacing: -.02em; }
.panel-head p { margin: 5px 0 0; color: var(--muted); font-size: 10px; line-height: 1.6; }
.participant-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 10px; padding: 18px 20px 20px; }
.participant-card { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 10px; min-width: 0; padding: 13px; border: 1px solid var(--line); border-radius: 13px; background: #fafbfa; }
.participant-card.selected { border-color: #8fb9a8; background: #edf7f2; }
.participant-card input { width: 17px; height: 17px; accent-color: var(--brand); }
.participant-card strong, .participant-card small { display: block; }
.participant-card strong { font-size: 12px; }
.participant-card small { margin-top: 3px; color: var(--muted); font-size: 9px; }
.locked-check { display: grid; place-items: center; width: 22px; height: 22px; border-radius: 7px; color: white; background: var(--brand); font-weight: 900; }
.badge { display: inline-flex; align-items: center; min-height: 23px; border-radius: 999px; padding: 4px 8px; color: var(--muted); background: #edf0ee; font-size: 9px; font-style: normal; font-weight: 850; }
.badge.green { color: #1b684e; background: #dcefe6; }
.badge.blue { color: #2455ad; background: #e4edff; }
.schedule-scroll { overflow-x: auto; overscroll-behavior-inline: contain; padding: 18px 20px 22px; scrollbar-gutter: stable; }
.schedule-board { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(238px, 1fr); gap: 11px; min-width: max-content; }
.event-card { display: grid; grid-template-rows: auto auto auto auto minmax(28px, auto); gap: 7px; min-width: 238px; padding: 16px; border: 1px solid var(--line); border-radius: 15px; color: var(--ink); background: #fff; text-align: left; box-shadow: 0 8px 22px rgba(26,52,43,.05); }
.event-card:hover, .event-card:focus-visible { border-color: var(--brand); outline: 3px solid rgba(40,116,89,.12); transform: translateY(-1px); }
.event-date { color: var(--brand); font-size: 11px; font-weight: 900; }
.event-card > strong { font-size: 14px; }
.event-title { font-size: 12px; font-weight: 850; line-height: 1.45; }
.event-meta { color: var(--muted); font-size: 10px; }
.event-assigned { display: flex; flex-wrap: wrap; align-content: end; gap: 4px; color: #8a9691; font-size: 9px; }
.event-assigned i { border-radius: 999px; padding: 4px 7px; color: #15523e; background: #dcefe6; font-style: normal; font-weight: 800; }
.selection-list { display: grid; gap: 12px; padding: 18px 20px 22px; }
.selection-card { overflow: hidden; border: 1px solid var(--line); border-radius: 15px; }
.selection-card.target-excluded { opacity: .68; background: #f5f6f5; }
.selection-card.target-excluded select { cursor: not-allowed; }
.selection-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 13px 15px; background: #f7f9f7; }
.selection-head > div { display: flex; align-items: center; gap: 9px; }
.selection-head h3 { margin: 0; font-size: 13px; }
.selection-head > strong { color: var(--brand); font-size: 11px; }
.session-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; padding: 12px; }
.session-row { display: grid; grid-template-columns: 31px minmax(130px, .8fr) minmax(190px, 1.2fr); gap: 9px; align-items: center; min-width: 0; padding: 9px; border: 1px solid var(--line); border-radius: 11px; background: #fafbfa; }
.session-row.selected { border-color: #bdd9ce; background: #f0f8f4; }
.session-number { display: grid; place-items: center; width: 28px; height: 28px; border-radius: 9px; color: var(--brand); background: #e3efe9; font-size: 11px; font-weight: 900; }
.session-row strong, .session-row small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.session-row strong { font-size: 10px; }
.session-row small { margin-top: 3px; color: var(--muted); font-size: 8px; }
.session-row select { min-width: 0; width: 100%; border: 1px solid var(--line-strong); border-radius: 9px; padding: 9px 10px; color: var(--ink); background: white; font-size: 10px; }
.submit-bar { position: sticky; bottom: 16px; z-index: 15; display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 15px 18px; border: 1px solid rgba(255,255,255,.45); border-radius: 18px; color: white; background: rgba(17, 63, 51, .94); box-shadow: 0 18px 48px rgba(13,45,36,.22); backdrop-filter: blur(14px); }
.submit-bar > div { display: grid; grid-template-columns: auto auto; align-items: baseline; gap: 2px 8px; }
.submit-bar span { font-size: 10px; }
.submit-bar strong { font-size: 18px; }
.submit-bar small { grid-column: 1 / -1; color: #cce2d9; font-size: 9px; }
.confirmation { display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 18px; border: 1px solid #8fb9a8; border-radius: 17px; background: #eaf7f1; }
.confirmation > div { display: flex; align-items: center; gap: 13px; }
.confirmation-mark { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 50%; color: white; background: var(--brand); font-weight: 900; }
.confirmation h2 { margin: 0; font-size: 15px; }
.confirmation p { margin: 4px 0 0; color: var(--muted); font-size: 10px; }
.button { display: inline-flex; align-items: center; justify-content: center; border: 1px solid var(--line-strong); border-radius: 10px; padding: 9px 12px; color: var(--ink); background: white; font-size: 10px; font-weight: 850; text-decoration: none; }
.button.primary { border-color: var(--brand); color: white; background: var(--brand); }
.button.primary:hover { background: var(--brand-deep); }
.button.small { padding: 7px 10px; }
.button.large { min-height: 44px; padding: 10px 18px; font-size: 12px; }
.button:disabled { cursor: not-allowed; opacity: .45; }
.state-card { display: grid; place-items: center; gap: 10px; width: min(760px, 100%); min-height: 420px; margin: 7vh auto 0; padding: 34px; border: 1px solid var(--line); border-radius: 22px; background: white; text-align: center; box-shadow: 0 18px 54px rgba(27,52,43,.08); }
.state-card h1 { margin: 4px 0; font-size: 25px; }
.state-card p { max-width: 590px; margin: 0; color: var(--muted); line-height: 1.7; }
.state-icon { display: grid; place-items: center; width: 42px; height: 42px; border-radius: 50%; color: white; background: #b66150; font-weight: 900; }
.state-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 9px; margin-top: 12px; }
.auth-card { grid-template-columns: minmax(220px, .8fr) minmax(320px, 1.2fr); place-items: start stretch; text-align: left; }
.auth-card > div:first-child { padding: 26px 12px; }
.clerk-host { min-height: 430px; display: grid; place-items: start center; }
.loader { width: 34px; height: 34px; border: 4px solid #d7e5de; border-top-color: var(--brand); border-radius: 50%; animation: spin .8s linear infinite; }
.empty { padding: 36px; border: 1px dashed var(--line-strong); border-radius: 12px; color: var(--muted); text-align: center; }
#toast-root { position: fixed; right: 22px; bottom: 22px; z-index: 50; display: grid; gap: 8px; }
.toast { width: min(370px, calc(100vw - 44px)); border-radius: 13px; padding: 12px 14px; color: white; background: #173c32; box-shadow: 0 12px 34px rgba(0,0,0,.22); font-size: 11px; line-height: 1.5; }
.toast.error { background: #8f332c; }
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 900px) {
  .hero, .role-summary { align-items: stretch; flex-direction: column; }
  .hero-status { justify-items: start; }
  .session-grid { grid-template-columns: 1fr; }
  .auth-card { grid-template-columns: 1fr; }
}

@media (max-width: 760px) {
  .workspace-shell { display: block; }
  .portal-sidebar { position: sticky; width: 100%; height: auto; max-height: 220px; padding: 9px 10px; overflow: auto; border-right: 0; border-bottom: 1px solid #234b40; }
  .portal-sidebar .brand, .sidebar-note { display: none; }
  .portal-nav { display: flex; gap: 12px; min-width: max-content; margin: 0; }
  .nav-group { min-width: 178px; }
  .nav-group-title { position: sticky; left: 0; margin-bottom: 3px; }
  .portal-nav-item { min-height: 38px; padding: 6px 9px; border-radius: 9px; font-size: 13px; }
  #app { width: min(100% - 20px, 1500px); padding-top: 22px; }
  .site-header { padding-inline: 12px; }
  .identity span { display: none; }
  .participant-grid { grid-template-columns: 1fr; padding-inline: 12px; }
  .panel-head { align-items: flex-start; padding-inline: 14px; }
  .session-row { grid-template-columns: 31px minmax(0, 1fr); }
  .session-row select { grid-column: 1 / -1; }
  .submit-bar { bottom: 8px; }
}

/* Keep tool navigation hidden until authentication and access checks finish. */
body.auth-pending .portal-sidebar,
body.auth-pending .site-header { display: none; }
body.auth-pending .workspace-shell { grid-template-columns: minmax(0, 1fr); }
body.auth-pending #app { max-width: 900px; padding-top: clamp(40px, 10vh, 120px); }
