/* === Taigo Sakai Portfolio — Ivory Editorial Design System === */

:root {
  color-scheme: light;
  --bg: #F7F3EA;
  --bg-2: #FAF8F3;
  --surface: #FFFFFF;
  --surface-2: #FBFAF7;
  --surface-3: #F0EBE1;
  --primary: #071A2F;
  --primary-soft: #102A43;
  --text-main: #111827;
  --text-sub: #374151;
  --muted: #6B7280;
  --accent: #B88A44;
  --accent-2: #C6A15B;
  --accent-soft: #EEE2CA;
  --stroke: rgba(17, 24, 39, 0.10);
  --stroke-strong: rgba(17, 24, 39, 0.18);
  --header-bg: rgba(250, 248, 243, 0.92);
  --profile-text: #F8F4E9;
  --profile-muted: #C7C4BC;
  --particle-color: rgba(184, 138, 68, 0.30);
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --shadow-sm: 0 4px 14px rgba(15, 23, 42, 0.05);
  --shadow-md: 0 10px 30px rgba(15, 23, 42, 0.08);
  --shadow-lg: 0 22px 52px rgba(15, 23, 42, 0.12);
  --ease-organic: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-out-expo: cubic-bezier(0.19, 1, 0.22, 1);
  --font-display: "Cormorant Garamond", Georgia, serif;
  --font-ui: "DM Sans", "Noto Sans JP", system-ui, sans-serif;
  --font-body: "DM Sans", "Noto Sans JP", system-ui, sans-serif;
}

[data-theme="dark"] {
  color-scheme: dark;
  --bg: #09131F;
  --bg-2: #0D1B2A;
  --surface: #102235;
  --surface-2: #14283D;
  --surface-3: #193149;
  --primary: #F4F0E7;
  --primary-soft: #E2D5B8;
  --text-main: #F4F0E7;
  --text-sub: #D6D0C3;
  --muted: #9CA7B5;
  --accent: #C6A15B;
  --accent-2: #D2B574;
  --accent-soft: #2B3540;
  --stroke: rgba(226, 213, 184, 0.14);
  --stroke-strong: rgba(226, 213, 184, 0.24);
  --header-bg: rgba(9, 19, 31, 0.93);
  --profile-text: #F4F0E7;
  --profile-muted: #BFC5CC;
  --particle-color: rgba(198, 161, 91, 0.22);
  --shadow-sm: 0 5px 16px rgba(0, 0, 0, 0.15);
  --shadow-md: 0 14px 34px rgba(0, 0, 0, 0.22);
  --shadow-lg: 0 24px 58px rgba(0, 0, 0, 0.30);
}

* { box-sizing: border-box; }

html {
  scroll-behavior: smooth;
  background: var(--bg);
}

body {
  min-width: 0;
  margin: 0;
  background: var(--bg);
  color: var(--text-main);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.72;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  transition: background-color 0.25s ease, color 0.25s ease;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -2;
  pointer-events: none;
  background:
    radial-gradient(circle at 12% 8%, rgba(184, 138, 68, 0.055), transparent 26%),
    radial-gradient(circle at 88% 30%, rgba(7, 26, 47, 0.035), transparent 30%),
    var(--bg);
}

[data-theme="dark"] body::before {
  background:
    radial-gradient(circle at 14% 10%, rgba(198, 161, 91, 0.055), transparent 28%),
    radial-gradient(circle at 84% 34%, rgba(65, 88, 112, 0.10), transparent 34%),
    var(--bg);
}

:lang(ja) {
  font-family: "Noto Sans JP", "Hiragino Kaku Gothic ProN", "Yu Gothic", sans-serif;
}

::selection { background: var(--accent-soft); color: var(--primary); }

a {
  color: var(--primary-soft);
  text-decoration: none;
  text-underline-offset: 3px;
  transition: color 0.18s ease;
}

a:hover { color: var(--accent); }

button,
input,
textarea { font: inherit; }

button,
a { -webkit-tap-highlight-color: transparent; }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

img { max-width: 100%; height: auto; }

.page {
  position: relative;
  z-index: 1;
  width: min(1360px, 100%);
  margin: 0 auto;
  padding: 28px 36px 48px;
}

.container-lg {
  display: grid;
  grid-template-columns: 304px minmax(0, 1fr);
  gap: 38px;
  margin-top: 38px;
}

.container-lg > * { min-width: 0; }
.main-content { min-width: 0; }

/* Header */
.header-bar {
  position: sticky;
  top: 0;
  z-index: 1100;
  margin: -28px -36px 0;
  padding: 24px 36px 18px;
  background: var(--header-bg);
  border-bottom: 1px solid var(--stroke);
  backdrop-filter: blur(18px);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.24);
  transition: padding 0.25s var(--ease-organic), box-shadow 0.25s ease;
}

.header-bar.scrolled {
  padding-top: 14px;
  padding-bottom: 14px;
  box-shadow: var(--shadow-sm);
}

.header-inner {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.header-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 22px;
  flex-wrap: wrap;
}

.header-profile {
  position: relative;
  display: flex;
  align-items: center;
  gap: 18px;
  min-width: 310px;
}

.header-avatar {
  width: 80px;
  height: 80px;
  flex: 0 0 80px;
  border-radius: 50%;
  object-fit: cover;
  border: 3px solid var(--surface);
  box-shadow: 0 8px 20px rgba(15, 23, 42, 0.12);
  cursor: grab;
  touch-action: none;
  user-select: none;
  will-change: transform;
  transition: transform 0.42s var(--ease-out-expo), box-shadow 0.2s ease;
}

.header-avatar.avatar-dragging {
  position: relative;
  z-index: 1200;
  cursor: grabbing;
  box-shadow: 0 18px 38px rgba(7, 26, 47, 0.22);
  transition: box-shadow 0.2s ease;
}

.header-identity {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}

.header-name {
  margin: 0;
  color: var(--primary);
  font-family: var(--font-display);
  font-size: clamp(34px, 4vw, 50px);
  font-weight: 600;
  letter-spacing: -0.025em;
  line-height: 0.94;
}

.header-subtitle {
  margin-top: 5px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.typing-container {
  display: inline-flex;
  align-items: center;
  min-height: 1.6em;
  color: var(--text-sub);
  font-family: var(--font-ui);
  font-size: clamp(12px, 1.3vw, 14px);
  font-weight: 500;
  letter-spacing: 0.015em;
}

.cursor {
  width: 1px;
  height: 1.05em;
  margin-left: 6px;
  background: var(--accent);
  animation: blink 1.05s step-end infinite;
}

@keyframes blink { 50% { opacity: 0; } }

.header-stats {
  display: flex;
  align-items: stretch;
  margin: 0 auto;
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--stroke);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
}

.stat-item {
  position: relative;
  display: flex;
  min-width: 92px;
  padding: 10px 18px;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.stat-item + .stat-item::before {
  content: "";
  position: absolute;
  top: 14px;
  bottom: 14px;
  left: 0;
  width: 1px;
  background: var(--stroke);
}

.stat-value {
  color: var(--primary);
  font-family: var(--font-display);
  font-size: 29px;
  font-weight: 600;
  line-height: 1;
}

.stat-label {
  margin-top: 3px;
  color: var(--muted);
  font-family: var(--font-ui);
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.13em;
  text-transform: uppercase;
}

.header-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}

.header-btn {
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 14px;
  border: 1px solid var(--stroke-strong);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text-sub);
  font-family: var(--font-ui);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.18s var(--ease-organic), border-color 0.18s ease, background 0.18s ease, color 0.18s ease;
}

.header-btn:hover {
  transform: translateY(-1px);
  border-color: var(--accent);
  background: var(--surface-2);
  color: var(--primary);
}

.header-btn.primary {
  border-color: var(--primary);
  background: var(--primary);
  color: #F8F4E9;
}

[data-theme="dark"] .header-btn.primary {
  border-color: var(--accent);
  background: var(--accent);
  color: #09131F;
}

.header-btn.primary:hover {
  border-color: var(--accent);
  background: var(--primary-soft);
  color: #FFFFFF;
}

.header-tab-row {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

.tab-nav { display: flex; gap: 6px; }

.header-tab-nav {
  flex: 0 0 auto;
  padding: 4px;
  background: var(--surface);
  border: 1px solid var(--stroke);
  border-radius: 999px;
}

.tab-item {
  padding: 9px 17px;
  border-radius: 999px;
  color: var(--muted);
  font-family: var(--font-ui);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.18s ease, color 0.18s ease;
}

.tab-item:hover { color: var(--primary); }

.tab-item.active {
  background: var(--primary);
  color: #F8F4E9;
}

[data-theme="dark"] .tab-item.active {
  background: var(--accent);
  color: #09131F;
}

.header-tab-row .year-filter {
  flex: 1 1 480px;
  margin: 0;
}

.filter-row {
  display: flex;
  align-items: center;
  gap: 7px;
  flex-wrap: wrap;
}

.filter-label {
  margin-right: 2px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.chip {
  min-height: 32px;
  padding: 5px 12px;
  border: 1px solid var(--stroke-strong);
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font-family: var(--font-ui);
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  transition: border-color 0.18s ease, background 0.18s ease, color 0.18s ease, transform 0.18s ease;
}

.chip:hover {
  transform: translateY(-1px);
  border-color: var(--accent);
  color: var(--primary);
}

.chip.active {
  border-color: var(--primary);
  background: var(--primary);
  color: #F8F4E9;
}

[data-theme="dark"] .chip.active {
  border-color: var(--accent);
  background: var(--accent);
  color: #09131F;
}

/* Sidebar */
.profile-sidebar {
  position: sticky;
  top: calc(var(--header-height, 80px) + 26px);
  height: fit-content;
}

.profile-card {
  position: relative;
  overflow: hidden;
  margin-bottom: 18px;
  padding: 30px 26px 28px;
  border: 1px solid rgba(198, 161, 91, 0.25);
  border-radius: var(--radius-lg);
  background: #071A2F;
  color: var(--profile-text);
  box-shadow: 0 18px 42px rgba(7, 26, 47, 0.18);
  cursor: grab;
  transform-style: preserve-3d;
  backface-visibility: visible;
  will-change: transform;
}

.profile-card::before {
  content: "";
  position: absolute;
  top: 0;
  right: 26px;
  left: 26px;
  height: 2px;
  background: var(--accent);
}

.profile-name {
  margin-top: 5px;
  color: var(--profile-text);
  font-family: var(--font-display);
  font-size: 30px;
  font-weight: 600;
  line-height: 1;
}

.profile-username {
  margin: 7px 0 18px;
  color: var(--accent-2);
  font-size: 14px;
}

.profile-bio {
  margin-bottom: 22px;
  color: var(--profile-muted);
  font-size: 12px;
  line-height: 1.75;
}

.profile-links {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding-top: 17px;
  border-top: 1px solid rgba(248, 244, 233, 0.12);
}

.profile-links a {
  display: flex;
  min-height: 37px;
  align-items: center;
  gap: 11px;
  border-radius: 8px;
  color: var(--profile-muted);
  font-size: 12px;
  transition: color 0.18s ease, background 0.18s ease, padding 0.18s ease;
}

.profile-links a:hover {
  padding-left: 7px;
  background: rgba(255, 255, 255, 0.045);
  color: var(--profile-text);
}

.profile-links .icon {
  width: 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--accent-2);
}

.text-icon {
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 600;
}

.profile-link-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.profile-link-row a { flex: 1; }

.copy-btn {
  padding: 5px 8px;
  border: 1px solid rgba(248, 244, 233, 0.18);
  border-radius: 7px;
  background: transparent;
  color: var(--profile-muted);
  font-size: 10px;
  cursor: pointer;
}

.copy-btn:hover,
.copy-btn.success {
  border-color: var(--accent);
  color: var(--profile-text);
}

/* Section navigation */
.section-tab-nav {
  position: sticky;
  top: var(--header-height, 80px);
  z-index: 1000;
  display: flex;
  gap: 18px;
  margin: 0 0 26px;
  padding: 15px 4px 12px;
  overflow-x: auto;
  background: color-mix(in srgb, var(--bg), transparent 4%);
  border-bottom: 1px solid var(--stroke);
  backdrop-filter: blur(12px);
  scrollbar-width: none;
}

.section-tab-nav::-webkit-scrollbar { display: none; }

.section-tab-item {
  position: relative;
  flex: 0 0 auto;
  max-width: 190px;
  padding: 7px 1px 9px;
  overflow: hidden;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
  cursor: pointer;
}

.section-tab-item::after {
  content: "";
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  height: 2px;
  background: var(--accent);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 0.2s var(--ease-organic);
}

.section-tab-item:hover,
.section-tab-item.active { color: var(--primary); }

.section-tab-item.active::after { transform: scaleX(1); }

/* Content cards */
.tab-content { min-width: 0; }

.section-card {
  margin-bottom: 28px;
  padding: 29px 30px;
  background: var(--surface);
  border: 1px solid var(--stroke);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  cursor: grab;
  transform-style: preserve-3d;
  backface-visibility: visible;
  will-change: transform;
  transition: transform 0.25s var(--ease-organic), box-shadow 0.25s ease, border-color 0.25s ease;
}

.section-card:hover {
  transform: translateY(-2px);
  border-color: var(--stroke-strong);
  box-shadow: var(--shadow-md);
}

.profile-card.card-rotating,
.section-card.card-rotating {
  position: relative;
  z-index: 20;
  cursor: grabbing;
  box-shadow: var(--shadow-lg);
}

.profile-card a,
.profile-card button,
.section-card a,
.section-card button,
.section-card input,
.section-card textarea,
.section-card select,
.section-card .repo-list li,
.section-card .app-card {
  cursor: pointer;
}

.section-title {
  position: relative;
  display: flex;
  align-items: center;
  gap: 11px;
  margin: 0 0 22px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--stroke);
  color: var(--primary);
  font-family: var(--font-display);
  font-size: 24px;
  font-weight: 600;
  letter-spacing: -0.015em;
}

.section-title::before {
  content: "";
  width: 2px;
  height: 1.15em;
  flex: 0 0 2px;
  border-radius: 2px;
  background: var(--accent);
}

.subsection-title {
  margin: 26px 0 12px;
  color: var(--primary);
  font-family: var(--font-display);
  font-size: 19px;
  font-weight: 600;
}

.muted { color: var(--muted); font-size: 12px; }

/* Timeline lists */
.repo-list {
  position: relative;
  display: grid;
  gap: 0;
  margin: 0;
  padding: 0;
  list-style: none;
}

.repo-list li {
  position: relative;
  margin-left: 7px;
  padding: 4px 52px 22px 25px;
  border-left: 1px solid var(--stroke-strong);
  color: var(--text-sub);
  overflow-wrap: anywhere;
  transition: color 0.18s ease;
}

.repo-list li:last-child { padding-bottom: 4px; }

.repo-list li::before {
  content: "";
  position: absolute;
  top: 10px;
  left: -4px;
  width: 7px;
  height: 7px;
  border: 2px solid var(--surface);
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 1px var(--accent);
}

.repo-list li:hover { color: var(--text-main); }
.repo-list li b { color: var(--text-main); font-weight: 600; }

.badge-year {
  display: inline-block;
  margin: 0 8px 5px 0;
  padding: 2px 8px;
  border: 1px solid color-mix(in srgb, var(--accent), transparent 52%);
  border-radius: 999px;
  background: color-mix(in srgb, var(--accent), transparent 88%);
  color: var(--primary-soft);
  font-family: var(--font-ui);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.04em;
}

[data-theme="dark"] .badge-year { color: var(--accent-2); }

.repo-list li > .link-arrow {
  position: absolute;
  top: 8px;
  right: 8px;
  display: block;
  width: 30px;
  height: 30px;
  border: 1px solid var(--stroke-strong);
  border-radius: 50%;
  background-color: var(--surface-2);
  background-image: url("assets/icons/arrow-right.svg");
  background-position: center;
  background-repeat: no-repeat;
  background-size: 12px auto;
  transition: transform 0.18s ease, border-color 0.18s ease, background-color 0.18s ease;
}

.repo-list li > .link-arrow:hover {
  transform: translateX(2px);
  border-color: var(--accent);
  background-color: var(--accent);
}

/* Application cards */
.grid-dense {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
  gap: 17px;
}

.app-card {
  position: relative;
  display: flex;
  gap: 16px;
  min-width: 0;
  overflow: hidden;
  padding: 17px;
  border: 1px solid var(--stroke);
  border-radius: var(--radius-md);
  background: var(--surface-2);
  cursor: pointer;
  transform-style: preserve-3d;
  transition: transform 0.26s var(--ease-organic), border-color 0.22s ease, box-shadow 0.22s ease, background 0.22s ease;
}

.app-card:hover {
  transform: translateY(-2px);
  border-color: var(--stroke-strong);
  background: var(--surface);
  box-shadow: var(--shadow-md);
  outline: 1px solid color-mix(in srgb, var(--accent), transparent 45%);
  outline-offset: -1px;
}

.app-card::before {
  content: attr(data-tags) " · 0.98";
  position: absolute;
  top: 0;
  left: 0;
  z-index: 2;
  padding: 3px 7px;
  border: 1px solid var(--accent);
  border-top: 0;
  border-left: 0;
  border-bottom-right-radius: 6px;
  background: var(--surface);
  color: var(--accent);
  font-family: var(--font-ui);
  font-size: 9px;
  font-weight: 600;
  text-transform: capitalize;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s ease;
}

.app-card:hover::before { opacity: 0.92; }

.app-thumb {
  width: 82px;
  height: 82px;
  flex-shrink: 0;
  object-fit: cover;
  border: 1px solid var(--stroke);
  border-radius: 10px;
}

.app-info { flex: 1; min-width: 0; }

.app-title {
  display: block;
  margin-bottom: 5px;
  color: var(--primary);
  font-size: 14px;
  font-weight: 700;
}

.app-desc {
  margin-bottom: 9px;
  color: var(--text-sub);
  font-size: 11px;
  line-height: 1.6;
}

.app-links {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.app-links a {
  padding: 2px 8px;
  border: 1px solid var(--stroke-strong);
  border-radius: 999px;
  color: var(--muted);
  font-size: 10px;
}

.app-links a:hover {
  border-color: var(--accent);
  color: var(--primary);
}

/* Badges, forms, footer */
.badge-row { margin-top: 22px; }
.badge-row h4 {
  margin: 0 0 10px;
  color: var(--primary);
  font-size: 13px;
  font-weight: 600;
}
.badge-row img { margin: 0 5px 7px 0; vertical-align: middle; }

.form-group { margin-bottom: 17px; }
.form-label {
  display: block;
  margin-bottom: 7px;
  color: var(--text-sub);
  font-size: 12px;
  font-weight: 600;
}
.form-control {
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  border: 1px solid var(--stroke-strong);
  border-radius: 10px;
  background: var(--surface-2);
  color: var(--text-main);
  box-shadow: none;
}
textarea.form-control { min-height: 130px; resize: vertical; }
.form-control:focus {
  border-color: var(--accent);
  background: var(--surface);
  outline: 2px solid color-mix(in srgb, var(--accent), transparent 78%);
}
.form-status { min-height: 24px; margin-top: 10px; color: var(--muted); font-size: 12px; }

.footer {
  margin-top: 54px;
  padding: 28px 0 8px;
  border-top: 1px solid var(--stroke);
  color: var(--muted);
  font-size: 11px;
  text-align: center;
}

#back-to-top {
  position: fixed;
  right: 24px;
  bottom: 94px;
  z-index: 1300;
  min-height: 36px;
  padding: 7px 11px;
  border: 1px solid var(--stroke-strong);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  box-shadow: var(--shadow-sm);
  cursor: pointer;
}

/* TOC and modal */
#toc-fab {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 1500;
  display: flex;
  width: 56px;
  height: 56px;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--accent);
  border-radius: 50%;
  background: var(--primary);
  color: #F8F4E9;
  box-shadow: var(--shadow-lg);
  cursor: pointer;
  transition: transform 0.2s var(--ease-organic);
}

[data-theme="dark"] #toc-fab { background: var(--accent); color: #09131F; }
#toc-fab:hover { transform: translateY(-2px); }
.progress-ring { position: absolute; inset: 0; pointer-events: none; }

#toc-menu {
  position: fixed;
  right: 24px;
  bottom: 90px;
  z-index: 1400;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px;
  border: 1px solid var(--stroke);
  border-radius: var(--radius-md);
  background: var(--surface);
  box-shadow: var(--shadow-md);
  opacity: 0;
  visibility: hidden;
  transform: translateY(6px);
  transition: opacity 0.2s ease, transform 0.2s ease, visibility 0.2s;
}

#toc-menu.show { opacity: 1; visibility: visible; transform: translateY(0); }
.toc-header { color: var(--muted); font-size: 9px; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; }
#toc-nav { display: flex; flex-direction: column; gap: 6px; }

.toc-link {
  position: relative;
  display: flex;
  width: 38px;
  height: 38px;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--stroke);
  border-radius: 50%;
  background: var(--surface-2);
  color: var(--primary);
  font-family: var(--font-display);
  font-size: 17px;
}

.toc-link::after {
  content: attr(data-title);
  position: absolute;
  top: 50%;
  right: 135%;
  padding: 6px 10px;
  border: 1px solid var(--stroke);
  border-radius: 7px;
  background: var(--surface);
  color: var(--text-main);
  font-family: var(--font-ui);
  font-size: 11px;
  white-space: nowrap;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-50%) translateX(5px);
  transition: opacity 0.18s ease, transform 0.18s ease;
}

.toc-link:hover::after { opacity: 1; visibility: visible; transform: translateY(-50%) translateX(0); }

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 3000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(7, 26, 47, 0.62);
  backdrop-filter: blur(7px);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.22s ease, visibility 0.22s;
}

.modal-overlay.open { opacity: 1; visibility: visible; }

.modal-container {
  position: relative;
  width: min(600px, 100%);
  max-height: 88vh;
  overflow: auto;
  padding: 28px;
  border: 1px solid var(--stroke);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-lg);
  transform: translateY(12px);
  transition: transform 0.3s var(--ease-out-expo);
}

.modal-overlay.open .modal-container { transform: translateY(0); }

.modal-close {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 36px;
  height: 36px;
  border: 1px solid var(--stroke);
  border-radius: 50%;
  background: var(--surface-2);
  color: var(--text-main);
  font-size: 20px;
  cursor: pointer;
}

.modal-img { width: 100%; max-height: 300px; object-fit: cover; border-radius: 12px; }
.modal-title { margin: 20px 44px 8px 0; color: var(--primary); font-family: var(--font-display); font-size: 27px; }
.modal-desc { color: var(--text-sub); }
.modal-links { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 16px; }

/* Loading and retained CV detail */
#loading-screen {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  transition: opacity 0.45s ease, visibility 0.45s;
}

#loading-screen.hidden { opacity: 0; visibility: hidden; pointer-events: none; }

.spinner {
  color: var(--primary);
  font-family: var(--font-display);
  font-size: 32px;
  font-weight: 600;
  letter-spacing: 0.015em;
  animation: quietPulse 1.6s ease-in-out infinite;
}

@keyframes quietPulse { 50% { opacity: 0.52; } }

.header-profile::before {
  content: "";
  position: absolute;
  top: 50%;
  left: 0;
  z-index: 10;
  width: 80px;
  height: 80px;
  border: 1px solid var(--accent);
  border-radius: 50%;
  opacity: 0;
  pointer-events: none;
  transform: translateY(-50%) scale(1.04);
  transition: opacity 0.18s ease, transform 0.18s ease;
}

.header-profile::after {
  content: "Portrait · 0.99";
  position: absolute;
  top: calc(50% - 37px);
  left: 8px;
  z-index: 11;
  padding: 2px 6px;
  border-radius: 4px;
  background: var(--accent);
  color: #09131F;
  font-family: var(--font-ui);
  font-size: 8px;
  font-weight: 700;
  opacity: 0;
  pointer-events: none;
  transform: translateY(-100%);
  transition: opacity 0.18s ease;
}

.header-profile:hover::before { opacity: 0.75; transform: translateY(-50%) scale(1); }
.header-profile:hover::after { opacity: 0.9; }

.avatar-drag-tooltip {
  position: fixed;
  z-index: 5000;
  max-width: min(320px, calc(100vw - 24px));
  padding: 8px 12px;
  border: 1px solid color-mix(in srgb, var(--accent), transparent 28%);
  border-radius: 999px;
  background: color-mix(in srgb, var(--primary), transparent 5%);
  color: #F8F4E9;
  box-shadow: var(--shadow-md);
  font-size: 11px;
  font-weight: 600;
  line-height: 1.35;
  text-align: center;
  white-space: normal;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, -100%) translateY(-10px);
  transition: opacity 0.15s ease, transform 0.15s ease;
}

.avatar-drag-tooltip.visible {
  opacity: 0.96;
  transform: translate(-50%, -100%) translateY(-14px);
}

.reveal-item {
  opacity: 0;
  transform: translateY(12px);
  transition: opacity 0.52s ease, transform 0.52s var(--ease-organic);
}
.reveal-active { opacity: 1; transform: translateY(0); }

[lang="en"] { display: none !important; }
html[data-lang="en"] [lang="en"] { display: block !important; }
html[data-lang="en"] [lang="ja"] { display: none !important; }

::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { border: 2px solid var(--bg); border-radius: 999px; background: var(--stroke-strong); }
::-webkit-scrollbar-thumb:hover { background: var(--muted); }

@media (max-width: 1040px) {
  .page { padding-right: 24px; padding-left: 24px; }
  .header-bar { margin-right: -24px; margin-left: -24px; padding-right: 24px; padding-left: 24px; }
  .container-lg { grid-template-columns: 274px minmax(0, 1fr); gap: 26px; }
  .header-stats { margin: 0; }
}

@media (max-width: 768px) {
  body { font-size: 14px; }
  .page { padding: 16px 16px 38px; }
  .header-bar {
    position: static !important;
    margin: -16px -16px 0 !important;
    padding: 18px 16px 16px !important;
  }
  .header-top { min-width: 0; align-items: flex-start; gap: 16px; }
  .header-profile { min-width: 0; width: 100%; gap: 13px; }
  .header-avatar { width: 62px; height: 62px; flex-basis: 62px; }
  .header-profile::before { width: 62px; height: 62px; }
  .header-profile::after { top: calc(50% - 28px); }
  .header-name { font-size: 35px; }
  .header-subtitle { font-size: 10px; }
  .typing-container { font-size: 11px; }
  .header-stats { width: 100%; max-width: 100%; min-width: 0; }
  .stat-item { flex: 1 1 0; min-width: 0; padding: 9px 4px; }
  .stat-value { font-size: 25px; }
  .header-actions { width: 100%; justify-content: flex-start; }
  .header-btn { min-height: 40px; padding: 8px 13px; }
  .header-tab-row { align-items: stretch; gap: 12px; }
  .header-tab-nav { width: 100%; min-width: 0; }
  .header-tab-nav .tab-item {
    min-width: 0;
    flex: 1 1 0;
    padding-right: 8px;
    padding-left: 8px;
    overflow: hidden;
    font-size: 10px;
    text-align: center;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .header-tab-row .year-filter { width: 100%; }
  .filter-row { gap: 6px; }
  .filter-label { width: 100%; }
  .chip { min-height: 36px; padding-right: 11px; padding-left: 11px; }
  .container-lg { grid-template-columns: minmax(0, 1fr); gap: 22px; margin-top: 22px; }
  .profile-sidebar { position: static !important; order: 0; }
  .main-content { order: 1; }
  .profile-card { padding: 26px 22px; }
  .profile-links {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    column-gap: 14px;
  }
  .profile-link-row { grid-column: 1 / -1; }
  .section-tab-nav { position: static !important; top: auto !important; margin-bottom: 18px; }
  .section-card { padding: 23px 20px; border-radius: 16px; }
  .section-title { font-size: 21px; }
  .grid-dense { grid-template-columns: minmax(0, 1fr); }
  .app-card { padding: 14px; }
  .repo-list li { padding-right: 42px; padding-left: 21px; }
  #back-to-top { display: none; }
  #toc-fab { width: 50px; height: 50px; right: 16px; bottom: 16px; }
  #toc-menu { right: 16px; bottom: 74px; }
}

@media (max-width: 430px) {
  .header-actions .header-btn { flex: 1 1 auto; }
  .app-card { align-items: flex-start; }
  .app-thumb { width: 70px; height: 70px; }
  .section-card { padding-right: 17px; padding-left: 17px; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  .reveal-item { opacity: 1; transform: none; }
}
