:root {
    --ink: #0A0A0A; --paper: #FAFAF8; --paper-dim: #F0EFEA; --panel: #FFFFFF;
    --line: rgba(10,10,10,0.13); --line-strong: rgba(10,10,10,0.22); --line-on-dark: rgba(250,250,248,0.18);
    --g1: #3A3A3A; --g2: #6E6E6E; --g3: #A6A6A0; --g4: #C9C9C4;
    --radius-s: 4px; --radius-m: 10px;
    --serif: 'Fraunces', Georgia, serif;
    --sans: 'IBM Plex Sans', 'Segoe UI', Arial, sans-serif;
  }
  @media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { --ink:#0A0A0A; --paper:#FAFAF8; } }
  :root[data-theme="dark"] { --ink:#0A0A0A; --paper:#FAFAF8; }
  * { box-sizing: border-box; margin: 0; padding: 0; }
  html { scroll-behavior: smooth; scroll-padding-top: env(safe-area-inset-top, 0px); }
  body {
    background: var(--paper); color: var(--ink); font-family: var(--sans); line-height: 1.55;
    padding-top: env(safe-area-inset-top, 0px); padding-bottom: env(safe-area-inset-bottom, 0px);
  }
  img, svg { max-width: 100%; display: block; }
  a { color: inherit; }
  button { font-family: inherit; cursor: pointer; }
  .wrap { max-width: 1180px; margin: 0 auto; padding: 0 28px; }
  @media (max-width: 640px) { .wrap { padding: 0 20px; } }

  .photo-block {
    position: relative; overflow: hidden; flex-shrink: 0;
    background:
      radial-gradient(circle, var(--ink) 1px, transparent 1.2px) 0 0/8px 8px,
      linear-gradient(155deg, var(--g4) 0%, var(--g2) 55%, var(--ink) 100%);
    background-blend-mode: multiply, normal;
  }
  .photo-block::after {
    content: attr(data-label); position: absolute; left: 16px; bottom: 14px;
    font-size: 0.72rem; color: var(--paper); background: rgba(10,10,10,0.55);
    padding: 5px 10px; border-radius: 3px;
  }

  .btn { display: inline-flex; align-items: center; gap: 8px; padding: 13px 24px; border-radius: var(--radius-s); font-size: 0.95rem; font-weight: 500; text-decoration: none; border: 1px solid transparent; }
  .btn-sm { padding: 9px 16px; font-size: 0.85rem; }
  .btn-primary { background: var(--ink); color: var(--paper); }
  .btn-primary:hover { background: #222; }
  .btn-outline { border-color: var(--ink); color: var(--ink); background: transparent; }
  .btn-outline:hover { background: var(--ink); color: var(--paper); }
  .btn-outline-light { border-color: var(--paper); color: var(--paper); background: transparent; }
  .btn-outline-light:hover { background: var(--paper); color: var(--ink); }
  .btn[disabled] { opacity: 0.5; cursor: not-allowed; }

  /* ============================================================
     PUBLIC SITE
  ============================================================= */
  #public-shell { display: none; }
  #public-shell.active { display: block; }

  .utility-bar { background: var(--ink); color: var(--g3); font-size: 0.78rem; }
  .utility-bar .wrap { display: flex; justify-content: flex-end; gap: 22px; padding: 8px 28px; }
  .utility-bar a { text-decoration: none; color: var(--g3); cursor: pointer; }
  .utility-bar a:hover, .utility-bar a.active-util { color: var(--paper); }

  nav.topnav { position: sticky; top: env(safe-area-inset-top, 0px); z-index: 50; background: rgba(250,250,248,0.94); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); }
  nav.topnav .wrap { height: 76px; display: flex; align-items: center; justify-content: space-between; }
  .logo { font-family: var(--serif); font-weight: 600; font-size: 1.4rem; letter-spacing: -0.01em; cursor: pointer; }
  .nav-links { display: flex; gap: 34px; font-size: 0.92rem; color: var(--g1); }
  .nav-links a { text-decoration: none; cursor: pointer; padding-bottom: 4px; border-bottom: 2px solid transparent; }
  .nav-links a:hover { opacity: 0.6; }
  .nav-links a.active { color: var(--ink); border-bottom-color: var(--ink); font-weight: 600; }
  @media (max-width: 860px) { .nav-links { display: none; } }

  .page { display: none; }
  .page.active { display: block; animation: fadeIn .3s ease; }
  @keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
  @media (prefers-reduced-motion: reduce) { .page.active { animation: none; } }

  .hero-photo { min-height: 440px; display: flex; align-items: flex-end; position: relative; }
  @media (max-width: 700px) { .hero-photo { min-height: 340px; } }
  .hero-inner { padding: 56px 0 90px; max-width: 620px; }
  .hero-inner .wrap { color: var(--paper); }
  .kicker { font-size: 0.85rem; color: var(--g4); font-weight: 600; margin-bottom: 16px; }
  h1 { font-family: var(--serif); font-weight: 600; font-size: clamp(2.3rem, 5.2vw, 3.9rem); line-height: 1.05; letter-spacing: -0.02em; color: var(--paper); }
  .hero-sub { margin-top: 18px; font-size: 1.08rem; color: var(--g4); max-width: 42ch; }
  .hero-ctas { margin-top: 30px; display: flex; gap: 14px; flex-wrap: wrap; }
  .side-banner { position: absolute; right: 40px; top: 40px; writing-mode: vertical-rl; color: var(--paper); font-size: 0.82rem; letter-spacing: 0.14em; font-weight: 600; padding: 18px 12px; border: 1px solid var(--line-on-dark); }
  @media (max-width: 700px) { .side-banner { display: none; } }

  .stats-strip { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius-m); margin-top: -56px; position: relative; z-index: 5; display: grid; grid-template-columns: repeat(4, 1fr); }
  @media (max-width: 760px) { .stats-strip { grid-template-columns: 1fr 1fr; margin-top: -40px; } }
  .stat { padding: 26px 22px; border-right: 1px solid var(--line); }
  .stat:last-child { border-right: none; }
  .stat .num { font-family: var(--serif); font-size: 1.9rem; font-weight: 600; }
  .stat .label { font-size: 0.82rem; color: var(--g1); margin-top: 4px; }

  .path-section { padding: 90px 0 100px; }
  .path-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 20px; margin-bottom: 40px; flex-wrap: wrap; }
  .path-head h2 { font-family: var(--serif); font-weight: 600; font-size: clamp(1.8rem, 3.2vw, 2.4rem); }
  .path-head p { color: var(--g1); max-width: 44ch; margin-top: 10px; }
  .path-row { display: grid; grid-template-columns: repeat(5, 1fr); gap: 16px; }
  @media (max-width: 900px) { .path-row { grid-template-columns: repeat(2, 1fr); } }
  @media (max-width: 520px) { .path-row { grid-template-columns: 1fr; } }
  .path-card { border: 1px solid var(--line); border-radius: var(--radius-s); overflow: hidden; }
  .path-card .photo-block { height: 140px; }
  .path-card-label { padding: 14px 16px; font-size: 0.92rem; font-weight: 600; }

  .split-section { padding: 92px 0; }
  .section-head { max-width: 58ch; margin-bottom: 50px; }
  .section-head h2 { font-family: var(--serif); font-weight: 600; font-size: clamp(1.8rem, 3.2vw, 2.5rem); letter-spacing: -0.01em; }
  .section-head p { margin-top: 14px; color: var(--g1); font-size: 1.02rem; }
  .split { position: relative; border-radius: var(--radius-m); overflow: hidden; display: grid; grid-template-columns: 0.9fr 1fr 0.9fr; min-height: 440px; border: 1px solid var(--line); }
  @media (max-width: 900px) { .split { grid-template-columns: 1fr; min-height: auto; } }
  .split-photo { min-height: 200px; }
  .split-panel { padding: 44px 38px; display: flex; flex-direction: column; justify-content: space-between; background: var(--paper); }
  .split-panel.provider { background: var(--ink); color: var(--paper); }
  .panel-eyebrow { font-size: 0.82rem; font-weight: 600; color: var(--g1); margin-bottom: 10px; }
  .split-panel.provider .panel-eyebrow { color: var(--g4); }
  .split-panel h3 { font-family: var(--serif); font-size: 1.6rem; font-weight: 600; margin-bottom: 12px; max-width: 18ch; }
  .split-panel p { color: var(--g1); max-width: 34ch; font-size: 0.96rem; }
  .split-panel.provider p { color: var(--g3); }
  .panel-list { list-style: none; margin-top: 20px; display: flex; flex-direction: column; gap: 9px; font-size: 0.9rem; }
  .panel-list li { padding-left: 16px; position: relative; }
  .panel-list li::before { content: '—'; position: absolute; left: 0; color: var(--g2); }
  .split-panel.provider .panel-list li::before { color: var(--g4); }
  .panel-cta { margin-top: 28px; align-self: flex-start; }

  .modules { padding: 20px 0 100px; }
  .module-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 1px; background: var(--line); border: 1px solid var(--line); }
  @media (max-width: 900px) { .module-grid { grid-template-columns: 1fr; } }
  .module { padding: 38px 34px; display: flex; flex-direction: column; justify-content: space-between; background: var(--paper); }
  .module h3 { font-family: var(--serif); font-weight: 600; font-size: 1.4rem; margin-bottom: 12px; }
  .module p { color: var(--g1); font-size: 0.95rem; }
  .module-tag { display: inline-block; font-size: 0.76rem; padding: 5px 0; margin-bottom: 16px; width: fit-content; font-weight: 600; border-bottom: 1px solid var(--ink); }
  .module.swap { grid-column: span 3; }
  .module.hub { grid-column: span 3; background: var(--ink); color: var(--paper); }
  .module.hub p { color: var(--g3); }
  .module.hub .module-tag { border-color: var(--paper); }
  .module.res { grid-column: span 6; display: grid; grid-template-columns: 1fr 1fr; gap: 34px; padding: 0; }
  .module.res .res-photo { min-height: 220px; }
  .module.res .res-text { padding: 38px 34px; display: flex; flex-direction: column; justify-content: center; }
  @media (max-width: 900px) { .module.res { grid-template-columns: 1fr; } }
  .course-tag { font-family: monospace; font-size: 0.76rem; background: var(--paper-dim); padding: 3px 8px; border-radius: 3px; display: inline-block; margin-top: 14px; }
  .filter-pills { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 18px; }
  .filter-pills span { border: 1px solid var(--ink); padding: 7px 13px; border-radius: 20px; font-size: 0.82rem; }

  .steps-section { padding: 0 0 100px; }
  .steps { display: grid; grid-template-columns: repeat(4, 1fr); border-top: 1px solid var(--line); }
  @media (max-width: 900px) { .steps { grid-template-columns: 1fr; } }
  .step { padding: 34px 26px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); }
  .step:last-child { border-right: none; }
  .step-num { font-family: var(--serif); font-size: 2rem; color: var(--paper); -webkit-text-stroke: 1.4px var(--ink); font-weight: 600; margin-bottom: 14px; }
  .step h4 { font-size: 1rem; font-weight: 600; margin-bottom: 8px; }
  .step p { color: var(--g1); font-size: 0.9rem; }

  .policy { background: var(--ink); color: var(--paper); padding: 88px 0; }
  .policy-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 56px; align-items: center; }
  @media (max-width: 820px) { .policy-grid { grid-template-columns: 1fr; } }
  .policy h2 { font-family: var(--serif); font-size: clamp(1.8rem, 3.2vw, 2.4rem); font-weight: 600; line-height: 1.16; }
  .policy-detail { display: flex; gap: 16px; padding: 17px 0; border-top: 1px solid var(--line-on-dark); }
  .policy-detail:last-child { border-bottom: 1px solid var(--line-on-dark); }
  .policy-detail .mark { color: var(--g4); font-family: var(--serif); font-weight: 600; }
  .policy-detail p { color: var(--g3); font-size: 0.93rem; }

  .page-header { padding: 64px 0 48px; border-bottom: 1px solid var(--line); }
  .page-header .kicker2 { font-size: 0.85rem; color: var(--g1); font-weight: 600; border-left: 2px solid var(--ink); padding-left: 10px; margin-bottom: 14px; }
  .page-header h1 { color: var(--ink); font-size: clamp(2.1rem, 4.6vw, 3.2rem); max-width: 18ch; }
  .page-header p { margin-top: 16px; color: var(--g1); max-width: 50ch; font-size: 1.05rem; }
  .content-block { padding: 70px 0; }
  .two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 50px; align-items: center; }
  @media (max-width: 860px) { .two-col { grid-template-columns: 1fr; } }
  .two-col .photo-block { min-height: 320px; border-radius: var(--radius-m); }
  .feature-list { list-style: none; display: flex; flex-direction: column; gap: 18px; margin-top: 20px; }
  .feature-list li { padding-left: 22px; position: relative; font-size: 0.98rem; color: var(--g1); }
  .feature-list li::before { content: '—'; position: absolute; left: 0; color: var(--ink); }
  .table-block { border: 1px solid var(--line); border-radius: var(--radius-s); overflow: hidden; margin-top: 20px; }
  .table-row { display: grid; grid-template-columns: 1fr 2fr; border-bottom: 1px solid var(--line); }
  .table-row:last-child { border-bottom: none; }
  .table-row div { padding: 16px 20px; font-size: 0.92rem; }
  .table-row div:first-child { font-weight: 600; background: var(--paper-dim); }

  footer.site-footer { padding: 54px 0 calc(38px + env(safe-area-inset-bottom, 0px)); border-top: 1px solid var(--line); }
  .footer-grid { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 24px; }
  .footer-note { color: var(--g1); font-size: 0.84rem; max-width: 40ch; }

  /* ---------- AUTH PAGE ---------- */
  .auth-wrap { max-width: 460px; margin: 0 auto; padding: 70px 28px 100px; }
  .auth-tabs { display: flex; border: 1px solid var(--line-strong); border-radius: var(--radius-s); overflow: hidden; margin-bottom: 28px; }
  .auth-tab { flex: 1; text-align: center; padding: 11px 0; font-size: 0.88rem; background: var(--panel); border: none; border-right: 1px solid var(--line-strong); }
  .auth-tab:last-child { border-right: none; }
  .auth-tab.active { background: var(--ink); color: var(--paper); font-weight: 600; }
  .auth-role-row { display: flex; gap: 10px; margin-bottom: 22px; }
  .auth-role-btn { flex: 1; padding: 12px; border: 1px solid var(--line-strong); border-radius: var(--radius-s); background: var(--panel); font-size: 0.88rem; }
  .auth-role-btn.active { border-color: var(--ink); background: var(--paper-dim); font-weight: 600; }
  .field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
  .field label { font-size: 0.82rem; font-weight: 600; }
  .field input, .field select, .field textarea {
    border: 1px solid var(--line-strong); border-radius: var(--radius-s); padding: 11px 13px; font-size: 0.92rem;
    font-family: inherit; background: var(--panel); color: var(--ink); width: 100%;
  }
  .field-hint { font-size: 0.76rem; color: var(--g2); }
  .auth-error { background: #f4e6e3; border: 1px solid #c9847a; color: #7a1f14; padding: 10px 13px; border-radius: var(--radius-s); font-size: 0.85rem; margin-bottom: 16px; display: none; }
  .auth-error.show { display: block; }
  .auth-success { background: #eef2ee; border: 1px solid #7a9c85; color: #1f4a2c; padding: 10px 13px; border-radius: var(--radius-s); font-size: 0.85rem; margin-bottom: 16px; display: none; }
  .auth-success.show { display: block; }
  .auth-switch { text-align: center; margin-top: 18px; font-size: 0.86rem; color: var(--g2); }
  .auth-switch a { text-decoration: underline; cursor: pointer; color: var(--ink); }
  .config-banner { background: #1a1a1a; color: var(--g4); font-size: 0.76rem; padding: 10px 20px; text-align: center; }
  .config-banner b { color: var(--paper); }

  /* ============================================================
     PORTAL
  ============================================================= */
  #portal-shell { display: none; }
  #portal-shell.active { display: flex; min-height: 100vh; }

  .sidebar { width: 258px; flex-shrink: 0; background: var(--ink); color: var(--paper); display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; padding-top: env(safe-area-inset-top, 0px); }
  .sidebar-logo { padding: 26px 24px 20px; font-family: var(--serif); font-weight: 600; font-size: 1.3rem; border-bottom: 1px solid rgba(250,250,248,0.12); cursor: pointer; }
  .role-badge { margin: 18px 24px 16px; font-size: 0.78rem; color: var(--g3); }
  .nav-group { padding: 6px 14px; flex: 1; }
  .nav-group-label { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--g3); padding: 14px 10px 8px; }
  .nav-item { display: flex; align-items: center; gap: 10px; padding: 11px 12px; border-radius: var(--radius-s); font-size: 0.92rem; color: var(--g4); margin-bottom: 2px; }
  .nav-item .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--g3); flex-shrink: 0; }
  .nav-item:hover { background: rgba(250,250,248,0.06); color: var(--paper); }
  .nav-item.active { background: var(--paper); color: var(--ink); font-weight: 600; }
  .nav-item.active .dot { background: var(--ink); }
  .nav-item[hidden] { display: none; }
  .sidebar-footer { padding: 16px 24px calc(20px + env(safe-area-inset-bottom, 0px)); border-top: 1px solid rgba(250,250,248,0.12); display: flex; align-items: center; gap: 10px; }
  .avatar-sm { width: 34px; height: 34px; border-radius: 50%; }
  .sidebar-footer .who { font-size: 0.85rem; font-weight: 600; }
  .sidebar-footer .who-sub { font-size: 0.72rem; color: var(--g3); }
  .logout-btn { margin-left: auto; font-size: 0.76rem; color: var(--g3); background: none; border: none; text-decoration: underline; }

  .main { flex: 1; min-width: 0; }
  .topbar { position: sticky; top: 0; z-index: 10; background: rgba(250,250,248,0.9); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); padding: 18px 32px; display: flex; justify-content: space-between; align-items: center; gap: 20px; }
  .topbar h1 { font-family: var(--serif); font-weight: 600; font-size: 1.5rem; color: var(--ink); }
  .search-input { border: 1px solid var(--line); border-radius: var(--radius-s); padding: 9px 14px; font-size: 0.88rem; width: 220px; background: var(--panel); color: var(--ink); font-family: inherit; }
  .content-area { padding: 32px; max-width: 1180px; }
  .page-view { display: none; }
  .page-view.active { display: block; animation: fadeIn .3s ease; }

  .stat-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 32px; }
  @media (max-width: 900px) { .stat-row { grid-template-columns: repeat(2, 1fr); } }
  .stat-card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius-m); padding: 20px 22px; }
  .stat-card .num { font-family: var(--serif); font-size: 1.85rem; font-weight: 600; }
  .stat-card .label { font-size: 0.82rem; color: var(--g2); margin-top: 4px; }
  .section-title { font-family: var(--serif); font-weight: 600; font-size: 1.2rem; margin: 6px 0 16px; }
  .panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius-m); overflow: hidden; margin-bottom: 28px; }
  .panel-pad { padding: 22px 24px; }
  .row-between { display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap; }
  .list-row { display: flex; align-items: center; gap: 14px; padding: 14px 24px; border-bottom: 1px solid var(--line); }
  .list-row:last-child { border-bottom: none; }
  .list-thumb { width: 44px; height: 44px; border-radius: var(--radius-s); }
  .list-title { font-size: 0.92rem; font-weight: 600; }
  .list-sub { font-size: 0.8rem; color: var(--g2); margin-top: 2px; }
  .list-meta { margin-left: auto; font-size: 0.78rem; color: var(--g2); white-space: nowrap; }
  .badge { display: inline-block; font-size: 0.72rem; padding: 3px 9px; border-radius: 20px; border: 1px solid var(--line-strong); color: var(--g1); }
  .badge.on { background: var(--ink); color: var(--paper); border-color: var(--ink); }
  .card-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; }
  @media (max-width: 900px) { .card-grid { grid-template-columns: repeat(2, 1fr); } }
  @media (max-width: 620px) { .card-grid { grid-template-columns: 1fr; } }
  .item-card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius-m); overflow: hidden; }
  .item-card .photo-block { height: 130px; }
  .item-card-body { padding: 14px 16px; }
  .item-card-title { font-size: 0.94rem; font-weight: 600; }
  .item-card-sub { font-size: 0.8rem; color: var(--g2); margin-top: 3px; }
  .item-card-price { font-family: var(--serif); font-weight: 600; margin-top: 8px; font-size: 1.05rem; }
  .filter-row { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 20px; }
  .filter-chip { border: 1px solid var(--line-strong); padding: 7px 14px; border-radius: 20px; font-size: 0.82rem; background: var(--panel); }
  .filter-chip.on { background: var(--ink); color: var(--paper); border-color: var(--ink); }
  .table { width: 100%; border-collapse: collapse; }
  .table th { text-align: left; font-size: 0.76rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--g2); padding: 12px 24px; border-bottom: 1px solid var(--line); }
  .table td { padding: 14px 24px; font-size: 0.88rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
  .table tr:last-child td { border-bottom: none; }
  .table-thumb-name { display: flex; align-items: center; gap: 12px; }
  .table-thumb { width: 38px; height: 38px; border-radius: var(--radius-s); }
  .form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
  @media (max-width: 700px) { .form-grid { grid-template-columns: 1fr; } }
  .field.full { grid-column: 1 / -1; }
  .field textarea { resize: vertical; min-height: 80px; }
  .checkbox-row { display: flex; gap: 18px; flex-wrap: wrap; }
  .checkbox-item { display: flex; align-items: center; gap: 8px; font-size: 0.88rem; }
  .upload-box { border: 1.5px dashed var(--line-strong); border-radius: var(--radius-m); padding: 30px; text-align: center; color: var(--g2); font-size: 0.86rem; }
  .empty-state { text-align: center; padding: 50px 20px; color: var(--g2); }
  .empty-state h3 { font-family: var(--serif); font-size: 1.2rem; color: var(--ink); margin-bottom: 8px; }
  .live-tag { font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.06em; background: var(--paper-dim); color: var(--g1); padding: 3px 8px; border-radius: 3px; margin-left: 8px; }

  @media (max-width: 900px) {
    .sidebar { position: fixed; z-index: 40; transform: translateX(-100%); transition: transform .2s ease; }
    .sidebar.open { transform: translateX(0); }
    .content-area { padding: 20px; }
    .topbar { padding: 14px 18px; }
    .search-input { width: 140px; }
  }
  .menu-btn { display: none; background: none; border: 1px solid var(--line-strong); border-radius: var(--radius-s); padding: 8px 11px; }
  @media (max-width: 900px) { .menu-btn { display: inline-flex; } }

  ::selection { background: var(--ink); color: var(--paper); }
  :focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }