/* ============================================================
   Logram — Instagram風ブログフィード
   ============================================================ */

:root {
  --bg: #ffffff;
  --text: #0f0f0f;
  --muted: #737373;
  --line: #dbdbdb;
  --line-soft: #efefef;
  --hover: #f4f4f4;
  --btn-bg: #efefef;
  --btn-hover: #e4e4e4;
  --link: #0095f6;
  --focus: #0095f6;
  --ig-gradient: linear-gradient(45deg, #f09433 0%, #e6683c 25%, #dc2743 50%, #cc2366 75%, #bc1888 100%);
  --sidebar-w: 245px;
  --sidebar-rail: 76px;
  --topbar-h: 54px;
  --bottom-nav-h: 52px;
  --radius: 8px;
  --shadow: 0 8px 30px rgba(0, 0, 0, 0.12);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "Hiragino Kaku Gothic ProN",
    "Hiragino Sans", "Yu Gothic UI", "Yu Gothic", Meiryo, sans-serif;
}

[data-theme="dark"] {
  --bg: #000000;
  --text: #f5f5f5;
  --muted: #a8a8a8;
  --line: #262626;
  --line-soft: #1c1c1c;
  --hover: #1a1a1a;
  --btn-bg: #262626;
  --btn-hover: #333333;
  --link: #4cb5f9;
  --focus: #4cb5f9;
  --shadow: 0 8px 30px rgba(0, 0, 0, 0.6);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  letter-spacing: 0.01em;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

img {
  display: block;
  max-width: 100%;
}

a {
  color: inherit;
  text-decoration: none;
}

button {
  margin: 0;
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  cursor: pointer;
}

ul {
  margin: 0;
  padding: 0;
  list-style: none;
}

h1,
p {
  margin: 0;
}

svg {
  display: block;
}

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

::selection {
  background: #0095f6;
  color: #ffffff;
}

.svg-sprite {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
}

.skip-link {
  position: fixed;
  top: 8px;
  left: 8px;
  z-index: 100;
  padding: 10px 16px;
  border-radius: 8px;
  background: var(--text);
  color: var(--bg);
  font-weight: 600;
  transform: translateY(-200%);
  transition: transform 0.2s ease;
}

.skip-link:focus {
  transform: translateY(0);
}

/* ---------- サイドバー ---------- */

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 30;
  display: flex;
  flex-direction: column;
  width: var(--sidebar-w);
  padding: 24px 12px 20px;
  border-right: 1px solid var(--line);
  background: var(--bg);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 12px 28px;
}

.brand-mark {
  display: grid;
  flex: 0 0 auto;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: var(--ig-gradient);
  color: #ffffff;
  box-shadow: 0 3px 10px rgba(220, 39, 67, 0.28);
}

.brand-mark svg {
  width: 21px;
  height: 21px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.brand-word {
  font-family: "Segoe Script", "Brush Script MT", "Lucida Handwriting", cursive;
  font-size: 29px;
  font-weight: 700;
  line-height: 1;
  letter-spacing: -0.03em;
  transform: translateY(1px);
}

.nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 16px;
  width: 100%;
  padding: 12px;
  border-radius: 10px;
  font-size: 15px;
  text-align: left;
  transition: background-color 0.15s ease, transform 0.15s ease;
}

.nav-item:hover {
  background: var(--hover);
}

.nav-item:active {
  transform: scale(0.985);
}

.nav-item.is-active {
  font-weight: 700;
}

.nav-item svg {
  flex: 0 0 auto;
  width: 24px;
  height: 24px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.nav-item.is-active svg {
  stroke-width: 2.4;
}

.sidebar-foot {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-top: auto;
}

.sidebar-note {
  padding: 14px 12px 0;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.5;
}

.icon-swap {
  position: relative;
  display: inline-grid;
  flex: 0 0 auto;
  width: 24px;
  height: 24px;
  place-items: center;
}

.icon-swap svg {
  position: absolute;
  inset: 0;
  width: 24px;
  height: 24px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: opacity 0.2s ease, transform 0.3s ease;
}

.icon-sun {
  opacity: 0;
  transform: rotate(-45deg) scale(0.6);
}

[data-theme="dark"] .icon-moon {
  opacity: 0;
  transform: rotate(45deg) scale(0.6);
}

[data-theme="dark"] .icon-sun {
  opacity: 1;
  transform: none;
}

/* ---------- モバイル用トップバー ---------- */

.topbar {
  position: fixed;
  inset: 0 0 auto;
  z-index: 40;
  display: none;
  align-items: center;
  justify-content: space-between;
  height: var(--topbar-h);
  padding: 0 16px;
  border-bottom: 1px solid var(--line);
  background: var(--bg);
  background: color-mix(in srgb, var(--bg) 86%, transparent);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

.brand--compact {
  padding: 0;
}

.brand--compact .brand-word {
  font-size: 27px;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}

.icon-btn {
  display: grid;
  width: 40px;
  height: 40px;
  place-items: center;
  border-radius: 50%;
  color: var(--text);
  transition: background-color 0.15s ease;
}

.icon-btn:hover {
  background: var(--hover);
}

.icon-btn svg {
  width: 24px;
  height: 24px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.icon-btn--small {
  width: 28px;
  height: 28px;
  color: var(--muted);
}

.icon-btn--small svg {
  width: 16px;
  height: 16px;
  stroke-width: 2;
}

/* ---------- メイン ---------- */

.main {
  margin-left: var(--sidebar-w);
}

.wrap {
  max-width: 975px;
  margin: 0 auto;
  padding: 32px 20px 80px;
}

/* ---------- プロフィール ---------- */

.profile {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  grid-template-areas:
    "avatar head"
    "avatar bio";
  column-gap: 36px;
  align-items: start;
  margin-bottom: 30px;
}

.avatar-ring {
  grid-area: avatar;
  display: grid;
  place-items: center;
  padding: 4px;
  border-radius: 50%;
  background: var(--ig-gradient);
}

.avatar-ring img {
  width: 142px;
  height: 142px;
  border: 4px solid var(--bg);
  border-radius: 50%;
  object-fit: cover;
  background: var(--hover);
}

.profile-head {
  grid-area: head;
  min-width: 0;
}

.profile-top {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  min-height: 34px;
}

.username {
  margin-right: 6px;
  font-size: 22px;
  font-weight: 400;
  line-height: 1.3;
  letter-spacing: 0;
  overflow-wrap: anywhere;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 7px 16px;
  border-radius: 8px;
  background: var(--btn-bg);
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
  line-height: 1.4;
  white-space: nowrap;
  transition: background-color 0.15s ease, transform 0.15s ease;
}

.btn:hover {
  background: var(--btn-hover);
}

.btn:active {
  transform: scale(0.97);
}

.btn[aria-pressed="true"] {
  background: transparent;
  box-shadow: inset 0 0 0 1px var(--line);
  color: var(--text);
}

.btn-icon {
  width: 14px;
  height: 14px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.stats {
  display: flex;
  flex-wrap: wrap;
  gap: 32px;
  margin-top: 20px;
  font-size: 15px;
}

.stats strong {
  font-weight: 600;
}

.profile-bio {
  grid-area: bio;
  margin-top: 18px;
  max-width: 560px;
}

.bio {
  font-size: 14px;
  line-height: 1.65;
  white-space: pre-line;
  overflow-wrap: anywhere;
}

.bio-name {
  font-weight: 700;
}

.bio-text {
  display: block;
  white-space: pre-line;
}

.website {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin-top: 8px;
  color: var(--link);
  font-size: 13px;
  font-weight: 600;
}

.website:hover {
  text-decoration: underline;
}

.website svg {
  width: 12px;
  height: 12px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* ---------- ハイライト ---------- */

.highlights {
  display: flex;
  gap: 24px;
  padding: 2px 0 22px;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  scrollbar-width: none;
}

.highlights::-webkit-scrollbar {
  display: none;
}

.highlight {
  display: flex;
  flex: 0 0 auto;
  flex-direction: column;
  align-items: center;
  gap: 7px;
  width: 86px;
  font-size: 12px;
  line-height: 1.3;
  color: var(--text);
}

.hl-ring {
  display: grid;
  place-items: center;
  width: 66px;
  height: 66px;
  padding: 3px;
  border-radius: 50%;
  background: var(--ig-gradient);
  transition: transform 0.2s ease;
}

.highlight:hover .hl-ring {
  transform: scale(1.05);
}

.hl-ring img {
  width: 100%;
  height: 100%;
  border: 3px solid var(--bg);
  border-radius: 50%;
  object-fit: cover;
  background: var(--hover);
}

.highlight.is-active .hl-ring {
  outline: 2px solid var(--text);
  outline-offset: 3px;
}

.hl-label {
  max-width: 82px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ---------- タブ ---------- */

.tabs {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  justify-content: center;
  gap: 64px;
  margin-top: 4px;
  border-top: 1px solid var(--line);
  background: var(--bg);
}

.tab {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: -1px;
  padding: 14px 2px 13px;
  border-top: 1px solid transparent;
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  transition: color 0.15s ease;
}

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

.tab.is-active {
  border-top-color: var(--text);
  color: var(--text);
}

.tab svg {
  width: 12px;
  height: 12px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* ---------- 検索 ---------- */

.search-panel {
  margin-top: 18px;
}

.search-field {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px 9px 14px;
  border-radius: 10px;
  background: var(--hover);
}

.search-field > svg {
  flex: 0 0 auto;
  width: 18px;
  height: 18px;
  color: var(--muted);
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.search-field input {
  flex: 1;
  min-width: 0;
  border: 0;
  background: none;
  color: var(--text);
  font: inherit;
  font-size: 14px;
  outline: none;
}

.search-field input::placeholder {
  color: var(--muted);
}

.search-field input::-webkit-search-cancel-button {
  display: none;
}

.result-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 22px;
  margin: 14px 0 10px;
  color: var(--muted);
  font-size: 12px;
}

.text-btn {
  flex: 0 0 auto;
  color: var(--link);
  font-size: 12px;
  font-weight: 600;
}

.text-btn:hover {
  text-decoration: underline;
}

/* ---------- グリッド ---------- */

.grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 4px;
  scroll-margin-top: 76px;
}

.tile {
  position: relative;
  display: block;
  aspect-ratio: 1 / 1;
  overflow: hidden;
  border-radius: 2px;
  background: var(--hover);
  -webkit-tap-highlight-color: transparent;
}

.tile img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
  transition: opacity 0.45s ease, transform 0.6s cubic-bezier(0.2, 0.7, 0.2, 1);
}

.tile img.is-loaded {
  opacity: 1;
}

.tile-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 16px;
  background: linear-gradient(180deg, rgba(0, 0, 0, 0.2), rgba(0, 0, 0, 0.62));
  color: #ffffff;
  opacity: 0;
  transition: opacity 0.22s ease;
}

.tile:hover .tile-overlay,
.tile:focus-visible .tile-overlay {
  opacity: 1;
}

.tile:hover img,
.tile:focus-visible img {
  transform: scale(1.04);
}

.tile-stats {
  display: flex;
  align-items: center;
  gap: 22px;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.01em;
}

.tile-stat {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.tile-stat svg {
  width: 19px;
  height: 19px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.tile-stat svg.is-filled {
  fill: currentColor;
  stroke: none;
}

.tile-external {
  position: absolute;
  top: 8px;
  right: 8px;
  display: grid;
  width: 26px;
  height: 26px;
  place-items: center;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.45);
  color: #ffffff;
  opacity: 0;
  transform: translateY(-4px);
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.tile-external svg {
  width: 13px;
  height: 13px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.tile:hover .tile-external,
.tile:focus-visible .tile-external {
  opacity: 1;
  transform: none;
}

/* ---------- 空の状態 ---------- */

.empty {
  padding: 64px 20px 48px;
  text-align: center;
  scroll-margin-top: 76px;
}

.empty-icon {
  display: grid;
  width: 72px;
  height: 72px;
  margin: 0 auto 18px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 50%;
  color: var(--muted);
}

.empty-icon svg {
  width: 30px;
  height: 30px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.empty-title {
  font-size: 16px;
  font-weight: 700;
}

.empty-text {
  margin-top: 6px;
  color: var(--muted);
  font-size: 13px;
}

.empty .btn {
  margin-top: 18px;
}

.noscript-note {
  margin-top: 30px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--muted);
  font-size: 13px;
  text-align: center;
}

/* ---------- フッター ---------- */

.site-footer {
  margin-top: 48px;
  padding-top: 24px;
  border-top: 1px solid var(--line-soft);
  color: var(--muted);
  font-size: 12px;
  text-align: center;
}

.site-footer-small {
  margin-top: 4px;
  font-size: 11px;
  opacity: 0.8;
}

/* ---------- モバイル用ボトムナビ ---------- */

.mobile-nav {
  position: fixed;
  inset: auto 0 0;
  z-index: 40;
  display: none;
  height: calc(var(--bottom-nav-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  border-top: 1px solid var(--line);
  background: var(--bg);
  background: color-mix(in srgb, var(--bg) 90%, transparent);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

.mobile-nav-item {
  display: grid;
  flex: 1;
  place-items: center;
  color: var(--muted);
  transition: color 0.15s ease;
}

.mobile-nav-item.is-active {
  color: var(--text);
}

.mobile-nav-item svg {
  width: 24px;
  height: 24px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.mobile-nav-item.is-active svg {
  stroke-width: 2.4;
}

/* ---------- トースト ---------- */

.toast {
  position: fixed;
  bottom: 28px;
  left: 50%;
  z-index: 90;
  max-width: calc(100vw - 40px);
  padding: 11px 18px;
  border-radius: 10px;
  background: var(--text);
  color: var(--bg);
  font-size: 13px;
  font-weight: 600;
  text-align: center;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 14px);
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.toast.is-visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

/* ---------- 中間幅（アイコンのみのサイドバー） ---------- */

@media (max-width: 1199px) and (min-width: 900px) {
  :root {
    --sidebar-w: var(--sidebar-rail);
  }

  .sidebar {
    align-items: center;
    padding-inline: 8px;
  }

  .brand {
    justify-content: center;
    padding: 8px 0 26px;
  }

  .brand-word,
  .sidebar-note,
  .nav-item > span:not(.icon-swap) {
    display: none;
  }

  .nav,
  .sidebar-foot {
    width: 100%;
    align-items: center;
  }

  .nav-item {
    justify-content: center;
    padding: 12px 0;
  }
}

/* ---------- モバイル ---------- */

@media (max-width: 899px) {
  .sidebar {
    display: none;
  }

  .topbar {
    display: flex;
  }

  .main {
    margin-left: 0;
    padding-top: var(--topbar-h);
  }

  .wrap {
    max-width: none;
    padding: 18px 0 calc(var(--bottom-nav-h) + 44px);
  }

  .mobile-nav {
    display: flex;
  }

  .profile {
    grid-template-areas:
      "avatar head"
      "bio bio";
    align-items: center;
    padding: 0 16px;
    column-gap: 20px;
    margin-bottom: 22px;
  }

  .avatar-ring {
    padding: 3px;
  }

  .avatar-ring img {
    width: 86px;
    height: 86px;
    border-width: 3px;
  }

  .username {
    font-size: 19px;
    margin-right: 0;
  }

  .profile-top {
    gap: 8px;
  }

  .profile-top .btn {
    padding: 6px 13px;
    font-size: 13px;
  }

  .profile-top .btn--blog {
    display: none;
  }

  .stats {
    gap: 20px;
    margin-top: 13px;
    font-size: 13px;
  }

  .profile-bio {
    margin-top: 6px;
  }

  .bio {
    font-size: 13px;
    line-height: 1.6;
  }

  .website {
    margin-top: 6px;
    font-size: 12px;
  }

  .highlights {
    gap: 16px;
    padding: 0 16px 18px;
  }

  .highlight {
    width: 74px;
    font-size: 11px;
  }

  .hl-ring {
    width: 60px;
    height: 60px;
  }

  .hl-label {
    max-width: 72px;
  }

  .tabs {
    top: var(--topbar-h);
    gap: 0;
  }

  .tab {
    flex: 1;
    justify-content: center;
    gap: 5px;
    padding: 12px 0 11px;
    font-size: 10px;
  }

  .search-panel {
    margin: 14px 16px 0;
  }

  .result-meta {
    margin: 12px 16px 8px;
  }

  .grid {
    gap: 2px;
    scroll-margin-top: calc(var(--topbar-h) + 50px);
  }

  .tile {
    border-radius: 0;
  }

  .site-footer {
    margin: 36px 16px 0;
  }

  .toast {
    bottom: calc(var(--bottom-nav-h) + env(safe-area-inset-bottom) + 16px);
  }
}

/* タッチ端末ではホバー演出を出さない */
@media (hover: none) {
  .tile-overlay,
  .tile-external {
    display: none;
  }
}

/* ---------- 小さい画面 ---------- */

@media (max-width: 420px) {
  .avatar-ring img {
    width: 76px;
    height: 76px;
  }

  .username {
    font-size: 17px;
  }

  .profile-top .btn {
    padding: 5px 11px;
    font-size: 12px;
  }

  .stats {
    gap: 14px;
    font-size: 12px;
  }

  .tab span {
    letter-spacing: 0;
  }
}

/* ---------- 404 ---------- */

.page-404 {
  display: grid;
  min-height: 100vh;
  min-height: 100svh;
  place-items: center;
  padding: 24px;
}

.notfound {
  width: 100%;
  max-width: 420px;
  text-align: center;
}

.notfound .brand {
  justify-content: center;
  padding: 0 0 30px;
}

.notfound .notfound-code {
  background: var(--ig-gradient);
  background-clip: text;
  -webkit-background-clip: text;
  color: transparent;
  -webkit-text-fill-color: transparent;
  font-size: clamp(72px, 20vw, 112px);
  font-weight: 800;
  line-height: 1;
  letter-spacing: -0.05em;
}

.notfound h1 {
  margin: 18px 0 0;
  font-size: 20px;
  font-weight: 700;
}

.notfound p {
  margin-top: 8px;
  color: var(--muted);
  font-size: 13px;
}

.notfound .btn {
  margin-top: 26px;
  padding: 9px 22px;
}

/* ---------- モーション設定 ---------- */

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
