:root {
    --ink: #0e1013;
    --panel: #14171c;
    --panel-2: #171b21;
    --line: #262b33;
    --amber: #d99a2b;
    --amber-dim: rgba(217, 154, 43, 0.35);
    --amber-faint: rgba(217, 154, 43, 0.12);
    --paper: #e9e4d8;
    --muted: #9096a0;
    --serif: "Yu Mincho", "YuMincho", "Hiragino Mincho ProN", "MS PMincho", serif;
    --sans: "Yu Gothic Medium", "Yu Gothic", "Hiragino Kaku Gothic ProN", "Meiryo", sans-serif;
    --mono: "Consolas", "SF Mono", "Courier New", monospace;
  }

  * { margin: 0; padding: 0; box-sizing: border-box; }

  html { scroll-behavior: smooth; }

  body {
    background: var(--ink);
    color: var(--paper);
    font-family: var(--sans);
    font-size: 16px;
    line-height: 1.9;
    -webkit-font-smoothing: antialiased;
  }

  h1, h2, h3 {
    font-family: var(--serif);
    font-weight: 600;
    word-break: auto-phrase;
    text-wrap: balance;
  }

  a { color: var(--paper); text-decoration: none; }

  ::selection { background: var(--amber); color: var(--ink); }

  /* ---- 計器盤ステータスバー ---- */
  .statusbar {
    position: fixed;
    top: 0; left: 0; right: 0;
    z-index: 100;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 20px;
    height: 40px;
    background: rgba(14, 16, 19, 0.9);
    border-bottom: 1px solid var(--line);
    font-family: var(--mono);
    font-size: 11px;
    letter-spacing: 0.08em;
    color: var(--muted);
  }
  .statusbar .sb-left b { color: var(--amber); font-weight: 400; }
  .statusbar .sb-readout { color: var(--amber); min-width: 120px; text-align: right; }
  .statusbar nav { display: flex; gap: 22px; }
  .statusbar nav a { color: var(--muted); transition: color 0.2s; }
  .statusbar nav a:hover { color: var(--amber); }
  @media (max-width: 900px) { .statusbar nav { display: none; } }

  .progress {
    position: fixed;
    top: 40px; left: 0;
    height: 2px;
    width: 0;
    background: var(--amber);
    z-index: 100;
  }

  /* ---- 共通レイアウト ---- */
  .wrap { max-width: 1080px; margin: 0 auto; padding: 0 24px; }

  section { padding: 110px 0; border-bottom: 1px solid var(--line); position: relative; }

  .sec-head { display: flex; align-items: baseline; gap: 18px; margin-bottom: 48px; }
  .sec-head .idx { font-family: var(--mono); font-size: 13px; color: var(--amber); display: inline-block; }
  .sec-head h2 {
    font-size: clamp(26px, 4vw, 38px);
    letter-spacing: 0.04em;
    position: relative;
    display: inline-block;
  }
  .sec-head h2 .t { opacity: 0; }
  .sec-head h2::after {
    content: "";
    position: absolute;
    inset: -2px -8px;
    background: var(--amber);
    transform: scaleX(0);
    transform-origin: left;
  }
  .sec-head.on h2 .t { animation: appear 0.01s 0.42s forwards; }
  .sec-head.on h2::after { animation: wipe 0.85s cubic-bezier(0.7, 0, 0.2, 1) forwards; }
  .sec-head.on .idx { animation: flipIn 0.6s 0.2s cubic-bezier(0.2, 0.9, 0.3, 1.2) backwards; }
  @keyframes appear { to { opacity: 1; } }
  @keyframes wipe {
    0%   { transform: scaleX(0); transform-origin: left; }
    45%  { transform: scaleX(1); transform-origin: left; }
    55%  { transform: scaleX(1); transform-origin: right; }
    100% { transform: scaleX(0); transform-origin: right; }
  }
  @keyframes flipIn {
    from { transform: perspective(300px) rotateX(90deg); opacity: 0; }
    to   { transform: perspective(300px) rotateX(0); opacity: 1; }
  }

  .rv { opacity: 0; transform: translateY(22px); transition: opacity 0.7s ease, transform 0.7s ease; }
  .rv.on { opacity: 1; transform: none; }

  /* ---- 01 Hero ---- */
  .hero {
    position: relative;
    min-height: 100svh;
    display: flex;
    align-items: flex-end;
    border-bottom: 1px solid var(--line);
    overflow: hidden;
  }
  /* PCではHeroを縦に長めに取り、スクラブの尺と本文量を確保する。
     テキストは上寄せで開始位置を固定し、余った高さは下側に逃がす */
  @media (min-width: 801px) {
    .hero { min-height: 108svh; align-items: flex-start; }
    .hero .hero-inner { padding-top: 130px; padding-bottom: 64px; }
  }
  /* ポスター画像を背景に敷いておく。動画のフレームを描画できない環境（モバイルで
     自動再生が拒否された場合等）でも映像面が空白にならないための保険 */
  #hero-video {
    position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover;
    background: var(--ink) url("hero-poster.jpg") center / cover no-repeat;
  }
  /* テキストの可読性を保つ暗幕（左下を最も暗く） */
  .hero-scrim {
    position: absolute; inset: 0;
    background:
      linear-gradient(75deg, rgba(14, 16, 19, 0.85) 0%, rgba(14, 16, 19, 0.35) 55%, rgba(14, 16, 19, 0.2) 100%),
      linear-gradient(0deg, rgba(14, 16, 19, 0.9) 0%, rgba(14, 16, 19, 0) 45%);
  }

  /* ---- ローディング画面 ---- */
  #loader {
    position: fixed; inset: 0; z-index: 300;
    background: var(--ink);
    display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    gap: 28px;
    transition: opacity 0.6s ease, visibility 0.6s;
  }
  #loader.done { opacity: 0; visibility: hidden; }
  .loader-type {
    font-family: var(--serif);
    font-size: clamp(40px, 9vw, 86px);
    letter-spacing: 0.06em;
    color: var(--paper);
    line-height: 1;
  }
  .loader-type .ch {
    display: inline-block;
    animation: flipIn 0.5s cubic-bezier(0.2, 0.9, 0.3, 1.2) backwards;
  }
  .loader-type .ch.sub {
    font-family: var(--mono);
    font-size: 0.34em;
    color: var(--amber);
    letter-spacing: 0.18em;
  }
  .loader-bar { width: min(240px, 50vw); height: 2px; background: var(--line); overflow: hidden; }
  .loader-bar i { display: block; height: 100%; width: 40%; background: var(--amber); animation: sweep 1.1s ease-in-out infinite; }
  @keyframes sweep { from { transform: translateX(-110%); } to { transform: translateX(280%); } }
  .hero-inner { position: relative; width: 100%; padding: 0 24px 84px; }
  .hero-mark {
    font-family: var(--serif);
    font-size: 13px;
    letter-spacing: 0.24em;
    color: var(--amber);
    margin-bottom: 26px;
  }
  .hero-statement {
    font-family: var(--serif);
    font-size: clamp(38px, 7.2vw, 84px);
    line-height: 1.35;
    letter-spacing: 0.06em;
  }
  .hero-sub {
    margin-top: 30px;
    font-family: var(--serif);
    font-size: clamp(15px, 2vw, 19px);
    letter-spacing: 0.08em;
    color: var(--muted);
  }
  .hero-sub em { font-style: normal; color: var(--paper); }
  .hero-desc {
    margin-top: 26px;
    max-width: 600px;
    font-family: var(--serif);
    font-size: 14.5px;
    line-height: 2.1;
    color: var(--muted);
    word-break: auto-phrase;
  }
  .hero-desc + .hero-desc { margin-top: 16px; }
  /* 狭い画面では手動改行を解除し、自然な折返しに任せる */
  @media (max-width: 640px) { .hero-desc br { display: none; } }
  .hero .rv:nth-child(1) { transition-delay: 0.1s; }
  .hero .rv:nth-child(2) { transition-delay: 0.25s; }
  .hero .rv:nth-child(3) { transition-delay: 0.45s; }
  .hero .rv:nth-child(4) { transition-delay: 0.6s; }
  .hero .rv:nth-child(5) { transition-delay: 0.75s; }
  .scroll-cue {
    position: absolute; right: 28px; bottom: 28px;
    font-family: var(--mono); font-size: 10px; letter-spacing: 0.2em;
    color: var(--muted); writing-mode: vertical-rl;
  }
  .hero-note {
    position: absolute; left: 24px; top: 56px;
    font-family: var(--mono); font-size: 10px; color: var(--muted);
    letter-spacing: 0.06em;
  }

  /* ---- 02 プロフィール ---- */
  .identity-grid { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: 56px; align-items: start; }
  .identity-copy p + p { margin-top: 1.4em; }
  .identity-copy .lead { font-family: var(--serif); font-size: clamp(20px, 2.8vw, 27px); line-height: 1.8; letter-spacing: 0.05em; }
  .profile-facts { list-style: none; margin-top: 26px; border-top: 1px solid var(--line); }
  .profile-facts li { display: flex; gap: 16px; padding: 10px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
  .profile-facts .k { font-family: var(--mono); font-size: 11px; color: var(--muted); min-width: 88px; padding-top: 4px; }
  .portrait-slot {
    aspect-ratio: 1 / 1;
    border: 1px solid var(--line);
    overflow: hidden;
    position: relative;
  }
  .portrait-slot img,
  .portrait-slot video {
    width: 100%; height: 100%;
    object-fit: cover; display: block;
    /* #hero-video と同じ意図の保険。フレーム未描画時はポスターを見せる */
    background: var(--ink) url("prof-poster.jpg") center / cover no-repeat;
    /* 圧縮ノイズを目立たせないための減彩とコントラスト調整 */
    filter: saturate(0.78) contrast(1.07) brightness(0.97);
  }
  /* 計器モニター風の走査線とビネットで質感を統一（圧縮の粗を馴染ませる） */
  .portrait-slot::after {
    content: "";
    position: absolute; inset: 0;
    pointer-events: none;
    background:
      repeating-linear-gradient(0deg, rgba(14, 16, 19, 0.16) 0 1px, transparent 1px 3px),
      radial-gradient(ellipse at center, transparent 55%, rgba(14, 16, 19, 0.38) 100%);
  }
  .portrait-cap { margin-top: 10px; font-family: var(--mono); font-size: 11px; color: var(--muted); letter-spacing: 0.08em; }
  @media (max-width: 800px) {
    .identity-grid { grid-template-columns: 1fr; }
    .portrait-slot { max-width: 320px; }
  }

  /* ---- 03 歩み ---- */
  .timeline { position: relative; padding-left: 36px; }
  .tl-rail { position: absolute; left: 8px; top: 0; bottom: 0; width: 1px; background: var(--line); }
  .tl-rail i { position: absolute; left: 0; top: 0; width: 100%; height: 0; background: var(--amber); display: block; }
  .tl-item { position: relative; padding: 0 0 44px; }
  .tl-item::before {
    content: "";
    position: absolute; left: -32px; top: 10px;
    width: 9px; height: 9px;
    background: var(--ink);
    border: 1px solid var(--amber);
    transform: rotate(45deg) scale(0);
    transition: transform 0.5s cubic-bezier(0.2, 0.9, 0.3, 1.4);
  }
  .tl-item.on::before { transform: rotate(45deg) scale(1); }
  .tl-item .tl-year { font-family: var(--mono); font-size: 12px; color: var(--amber); letter-spacing: 0.1em; }
  .tl-item h3 { font-size: 20px; margin: 4px 0 8px; }
  .tl-item p { font-size: 14px; color: var(--muted); max-width: 620px; }

  /* ---- 04 Re-Systems ---- */
  .org-section {
    background:
      repeating-linear-gradient(90deg, transparent, transparent 79px, rgba(233, 228, 216, 0.025) 80px),
      repeating-linear-gradient(0deg, transparent, transparent 79px, rgba(233, 228, 216, 0.025) 80px),
      var(--panel);
  }
  .org-lead { max-width: 720px; margin-bottom: 44px; }
  .org-lead .lead { font-family: var(--serif); font-size: clamp(18px, 2.4vw, 23px); line-height: 1.9; letter-spacing: 0.04em; }
  .org-lead p + p { margin-top: 1.2em; font-size: 14px; color: var(--muted); }

  .dept-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 1px;
    background: var(--line);
    border: 1px solid var(--line);
  }
  @media (max-width: 900px) { .dept-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
  .dept { background: var(--panel-2); padding: 14px 14px 12px; transition: background 0.25s; }
  .dept:hover { background: #1d232b; }
  .dept .d-row { display: flex; justify-content: space-between; align-items: baseline; }
  .dept .d-name { font-family: var(--serif); font-size: 15px; letter-spacing: 0.03em; }
  .dept .n { font-family: var(--mono); font-size: 13px; color: var(--amber); }
  .dept .d-bar { height: 2px; background: var(--line); margin-top: 10px; overflow: hidden; }
  .dept .d-bar i { display: block; height: 100%; width: 0; background: var(--amber); transition: width 1s ease 0.2s; }
  .dept.on .d-bar i { width: var(--w); }

  .org-cta { margin-top: 32px; display: flex; flex-wrap: wrap; gap: 20px; align-items: center; }
  .btn {
    display: inline-block;
    border: 1px solid var(--amber);
    color: var(--amber);
    font-family: var(--mono);
    font-size: 13px;
    letter-spacing: 0.1em;
    padding: 12px 26px;
    transition: background 0.25s, color 0.25s;
    cursor: pointer;
  }
  .btn:hover { background: var(--amber); color: var(--ink); }
  .org-cta .note { font-size: 12px; color: var(--muted); }

  /* ---- 05 2つの会社 ---- */
  .companies {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1px;
    background: var(--line);
    border: 1px solid var(--line);
  }
  @media (max-width: 800px) { .companies { grid-template-columns: 1fr; } }
  .company { background: var(--ink); padding: 40px 36px 32px; }
  .company.alt { background: var(--panel); }
  @media (max-width: 480px) { .company { padding: 30px 20px 26px; } }
  .company .c-role { font-family: var(--mono); font-size: 11px; color: var(--amber); letter-spacing: 0.14em; }
  .company h3 { font-size: clamp(21px, 3vw, 27px); margin: 10px 0 14px; }
  .company .c-desc { font-size: 14px; color: var(--muted); }
  /* 2カラム表示時は説明文と各項目の高さを固定し、左右の行位置を揃える */
  @media (min-width: 801px) {
    .company .c-desc { min-height: 5.7em; }
    .company h3 { min-height: 1.4em; }
    .company li { min-height: 4.6em; }
  }
  .company ul { list-style: none; margin-top: 16px; }
  .company li { padding: 9px 0; border-top: 1px solid var(--line); font-size: 14px; }
  .company .li-note { display: block; font-size: 12px; color: var(--muted); }
  .company .li-note a { border-bottom: 1px solid var(--amber-dim); }
  .company .li-note a:hover { color: var(--amber); }
  .company .btn { margin-top: 20px; font-size: 12px; }

  /* ---- 06 公開サイトと制作物 ---- */
  .shelf-label { font-family: var(--mono); font-size: 11px; color: var(--muted); letter-spacing: 0.14em; margin: 0 0 14px; }
  .shelf + .shelf-label { margin-top: 44px; }
  .shelf { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; }
  .shelf.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  @media (max-width: 800px) { .shelf, .shelf.three { grid-template-columns: 1fr; } }
  .work {
    border: 1px solid var(--line);
    padding: 26px 24px;
    display: flex; flex-direction: column; gap: 10px;
    min-height: 180px;
    transition: border-color 0.3s;
  }
  a.work:hover { border-color: var(--amber-dim); }
  .work.site { background: var(--panel); }
  .work .w-tag { font-family: var(--mono); font-size: 10px; color: var(--muted); letter-spacing: 0.12em; }
  .work .w-tag.run { color: var(--amber); }
  .work h3 { font-size: 21px; }
  .work p { font-size: 14px; color: var(--muted); flex: 1; }
  .work .w-url {
    align-self: flex-start;
    border: 1px solid var(--amber);
    color: var(--amber);
    font-family: var(--mono);
    font-size: 11px;
    letter-spacing: 0.1em;
    padding: 9px 18px;
    transition: background 0.25s, color 0.25s;
  }
  a.work:hover .w-url { background: var(--amber); color: var(--ink); }

  /* ---- 06 技術スタック ---- */
  .stack-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; }
  @media (max-width: 800px) { .stack-grid { grid-template-columns: 1fr; } }
  .stack {
    border: 1px solid var(--line);
    padding: 24px 22px;
  }
  .stack h3 { font-family: var(--mono); font-weight: 400; font-size: 12px; color: var(--amber); letter-spacing: 0.14em; margin-bottom: 14px; }
  .stack dl { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 6px 18px; font-size: 13px; }
  .stack dt { font-family: var(--mono); color: var(--paper); white-space: nowrap; }
  .stack dd { color: var(--muted); }
  .stack-note { margin-top: 20px; font-size: 12px; color: var(--muted); }

  /* ---- 07 AI社員が作るメルマガ ---- */
  .mag-grid { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); gap: 56px; }
  @media (max-width: 800px) { .mag-grid { grid-template-columns: 1fr; } }
  .issue-list { list-style: none; }
  .issue-list li { border-top: 1px solid var(--line); }
  .issue-list li:last-child { border-bottom: 1px solid var(--line); }
  .issue-list a { display: block; padding: 16px 4px; transition: background 0.2s; }
  .issue-list a:hover { background: var(--panel); }
  .issue-list .a-date { font-family: var(--mono); font-size: 11px; color: var(--muted); }
  .issue-list .a-date b { color: var(--amber); font-weight: 400; }
  .issue-list .a-title { font-family: var(--serif); font-size: 17px; margin-top: 2px; }
  .issue-more { margin-top: 18px; }

  .mailmag {
    border: 1px solid var(--amber-dim);
    background: var(--amber-faint);
    padding: 24px 22px;
  }
  .mailmag h3 { font-size: 18px; margin-bottom: 8px; }
  .mailmag p { font-size: 13px; color: var(--muted); }
  .mailmag .row { display: flex; gap: 10px; margin-top: 16px; }
  .mailmag input {
    flex: 1; min-width: 0;
    background: var(--ink); border: 1px solid var(--line);
    color: var(--paper); font-family: var(--mono); font-size: 13px;
    padding: 11px 14px;
  }
  .mailmag input::placeholder { color: var(--muted); }

  .ki { border-top: 2px solid var(--amber); padding-top: 20px; margin-top: 34px; }
  .ki h3 { font-size: 15px; color: var(--amber); font-family: var(--mono); font-weight: 400; letter-spacing: 0.1em; margin-bottom: 12px; }
  .ki p { font-family: var(--serif); font-size: 15px; line-height: 2.1; }
  .ki .sig { margin-top: 14px; font-family: var(--mono); font-size: 12px; color: var(--muted); }

  /* ---- 08 相談とリンク ---- */
  .contact { border-bottom: none; }
  .contact p { max-width: 560px; color: var(--muted); font-size: 14px; }
  .contact .big { font-family: var(--serif); font-size: clamp(24px, 4vw, 36px); color: var(--paper); margin-bottom: 18px; }

  .links-grid {
    margin-top: 54px;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 1px;
    background: var(--line);
    border: 1px solid var(--line);
  }
  @media (max-width: 800px) { .links-grid { grid-template-columns: 1fr; } }
  .link-col { background: var(--ink); padding: 22px 22px 18px; }
  .link-col h3 { font-family: var(--mono); font-weight: 400; font-size: 11px; color: var(--muted); letter-spacing: 0.14em; margin-bottom: 12px; }
  .link-col a { display: block; padding: 7px 0; font-size: 14px; border-top: 1px solid var(--line); transition: color 0.2s; }
  .link-col a:hover { color: var(--amber); }
  .link-col a span { font-family: var(--mono); font-size: 11px; color: var(--muted); display: block; }

  /* ---- トップへ戻る ---- */
  .to-top {
    position: fixed;
    right: 20px; bottom: 20px;
    z-index: 90;
    display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    gap: 2px;
    width: 52px; height: 52px;
    background: rgba(14, 16, 19, 0.85);
    border: 1px solid var(--amber-dim);
    color: var(--amber);
    font-family: var(--mono);
    font-size: 14px;
    line-height: 1;
    opacity: 0;
    visibility: hidden;
    transform: translateY(8px);
    transition: opacity 0.3s, transform 0.3s, visibility 0.3s, background 0.25s;
  }
  .to-top span { font-size: 9px; letter-spacing: 0.16em; }
  .to-top.show { opacity: 1; visibility: visible; transform: none; }
  .to-top:hover { background: var(--amber); color: var(--ink); }

  footer {
    border-top: 1px solid var(--line);
    padding: 26px 0 34px;
    font-family: var(--mono); font-size: 11px; color: var(--muted); letter-spacing: 0.06em;
  }
  footer .wrap { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 8px; }

  @media (prefers-reduced-motion: reduce) {
    html { scroll-behavior: auto; }
    .loader-type .ch { animation: none; }
    .loader-bar i { animation: none; width: 100%; }
    #loader { transition: none; }
    .rv { opacity: 1; transform: none; transition: none; }
    .dept .d-bar i { transition: none; }
    .sec-head h2 .t { opacity: 1; animation: none; }
    .sec-head.on h2::after, .sec-head.on .idx { animation: none; }
    .tl-item::before { transition: none; transform: rotate(45deg) scale(1); }
  }
