/* ==========================================================================
   Relay — design tokens
   ========================================================================== */
:root {
  --bg: #0a0d13;
  --bg-alt: #0f131b;
  --bg-rgb: 10, 13, 19;
  --panel-rgb: 20, 24, 33;
  --surface: rgba(255, 255, 255, 0.045);
  --surface-strong: rgba(255, 255, 255, 0.09);
  --border: rgba(255, 255, 255, 0.09);
  --border-strong: rgba(255, 255, 255, 0.16);
  --hover-tint: rgba(255, 255, 255, 0.02);
  --text: #edeff3;
  --text-dim: #8b92a3;
  --text-faint: #565d6d;
  --accent-a: #5eead4;
  --accent-b: #8b5cf6;
  --like: #fb7185;
  --bubble-mine: linear-gradient(135deg, var(--accent-a), var(--accent-b));
  --bubble-mine-text: #05070b;
  --bubble-theirs: var(--surface-strong);
  --bubble-theirs-text: var(--text);

  --font-display: "Space Grotesk", "Hiragino Sans", sans-serif;
  --font-body: "Inter", "Hiragino Sans", sans-serif;
  --font-mono: "JetBrains Mono", monospace;

  --radius-lg: 20px;
  --radius-md: 14px;
  --radius-sm: 10px;
}

/* ライトモード。ダークモードを基準に作っているアプリなので、
   同じアクセントカラー(ティール/パープル)を保ちつつ、
   明るい背景でも読みやすいようトーンだけ調整している。 */
:root[data-theme="light"] {
  --bg: #f6f7fb;
  --bg-alt: #eceef4;
  --bg-rgb: 246, 247, 251;
  --panel-rgb: 255, 255, 255;
  --surface: rgba(10, 13, 30, 0.04);
  --surface-strong: rgba(10, 13, 30, 0.075);
  --border: rgba(10, 13, 30, 0.10);
  --border-strong: rgba(10, 13, 30, 0.18);
  --hover-tint: rgba(10, 13, 30, 0.025);
  --text: #161822;
  --text-dim: #5c6172;
  --text-faint: #9398a8;
  --accent-a: #0f9c8c;
  --accent-b: #7c3aed;
  --like: #e11d48;
  --bubble-mine-text: #ffffff;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  min-height: 100vh;
  min-height: 100dvh;
  /* iPhoneのSafariは body だけに overflow-x: hidden を指定しても
     横スクロールを止めきれないことがあるため、html にも指定しておく */
  overflow-x: hidden;
}

body {
  overflow-x: hidden;
  /* リンク先ページのタイトルなど、外部から取得した文字列にはスペースを含まない
     長い単語が混ざることがある。改行できないとカードの幅からはみ出してしまうため、
     アプリ全体のテキストに対して、必要な時だけ単語の途中でも折り返すようにしておく。
     (継承されるプロパティなので、投稿カード・リンクカード・プロフィールなど
     すべてのテキストに一括で効く)
     word-break: break-word は英単語の途中でも積極的に改行してしまい不自然に
     なるため使わない。overflow-wrap: break-word は「はみ出す時だけ最終手段として
     折り返す」動作なので、通常の単語区切り・日本語の折り返しは崩さずに済む。 */
  overflow-wrap: break-word;
  word-break: normal;
}

::selection { background: rgba(139, 92, 246, 0.35); }

/* 背景の淡いアンビエント光 */
.bg-glow {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(600px 400px at 15% -5%, rgba(94, 234, 212, 0.10), transparent 60%),
    radial-gradient(700px 500px at 90% 10%, rgba(139, 92, 246, 0.12), transparent 60%),
    radial-gradient(900px 700px at 50% 110%, rgba(94, 234, 212, 0.05), transparent 60%);
}

/* ==========================================================================
   レイアウト
   ========================================================================== */
.app {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: 84px minmax(0, 640px);
  justify-content: center;
  gap: 0;
  min-height: 100vh;
  min-height: 100dvh;
}

.rail {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 24px 0;
  position: sticky;
  top: 0;
  height: 100vh;
  height: 100dvh;
}

.rail-logo {
  flex-shrink: 0;
  width: 44px;
  height: 44px;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--bg);
  background: linear-gradient(135deg, var(--accent-a), var(--accent-b));
  margin-bottom: 18px;
  box-shadow: 0 6px 24px rgba(139, 92, 246, 0.35);
}

.rail-wordmark { display: none; }

.rail-btn {
  width: 46px;
  height: 46px;
  border-radius: 14px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-dim);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease, transform 0.15s ease, border-color 0.2s ease;
}

.rail-label { display: none; }

.rail-btn:hover {
  background: var(--surface);
  color: var(--text);
  transform: translateY(-1px);
}

.rail-btn.active {
  color: var(--accent-a);
  background: var(--surface);
  border-color: var(--border);
}

.rail-spacer { flex: 1; }

.main {
  border-left: 1px solid var(--border);
  border-right: 1px solid var(--border);
  min-height: 100vh;
  min-height: 100dvh;
  width: 100%;
  max-width: 640px;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  padding: 20px 24px 14px;
  background: rgba(var(--bg-rgb), 0.7);
  backdrop-filter: blur(16px) saturate(140%);
  -webkit-backdrop-filter: blur(16px) saturate(140%);
  border-bottom: 1px solid var(--border);
}

.topbar h1 {
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 600;
  margin: 0;
  letter-spacing: -0.01em;
}

/* ==========================================================================
   投稿バー(コンポーザー)
   ========================================================================== */
.composer {
  display: flex;
  gap: 14px;
  padding: 18px 24px;
  border-bottom: 1px solid var(--border);
  animation: fadeInUp 0.5s ease both;
}

.composer-avatar {
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent-a), var(--accent-b));
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-weight: 600;
  color: var(--bg);
  overflow: hidden;
}

.composer-avatar img,
.profile-avatar img,
.comment-avatar img,
.post-avatar .user-avatar-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.composer-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.composer-body input[type="text"] {
  width: 100%;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 11px 14px;
  font-family: var(--font-body);
  font-size: 14.5px;
  outline: none;
  transition: border-color 0.2s ease, background 0.2s ease, box-shadow 0.2s ease;
}

.composer-body input[type="text"]::placeholder { color: var(--text-faint); }

.composer-body input[type="text"]:focus {
  border-color: var(--accent-b);
  background: var(--surface-strong);
  box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.15);
}

#urlInput { font-family: var(--font-mono); font-size: 13.5px; }

.composer-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 2px;
}

.composer-hint {
  font-size: 12px;
  color: var(--text-faint);
  margin-right: auto;
}

.composer-icon-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 10px;
  color: var(--text-dim);
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease;
  flex-shrink: 0;
}

.composer-icon-btn:hover { background: var(--surface); color: var(--accent-a); }

.photo-preview {
  position: relative;
  width: fit-content;
  max-width: 220px;
  border-radius: var(--radius-md);
  overflow: hidden;
  border: 1px solid var(--border);
}

.photo-preview img {
  display: block;
  width: 100%;
  max-height: 200px;
  object-fit: cover;
}

.photo-remove {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 24px;
  height: 24px;
  border: none;
  border-radius: 50%;
  background: rgba(5, 6, 10, 0.65);
  color: #fff;
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.photo-remove:hover { background: rgba(5, 6, 10, 0.85); }

.btn-primary {
  border: none;
  cursor: pointer;
  padding: 9px 20px;
  border-radius: 999px;
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 13.5px;
  color: var(--bg);
  background: linear-gradient(135deg, var(--accent-a), var(--accent-b));
  transition: transform 0.15s ease, box-shadow 0.15s ease, opacity 0.15s ease;
}

.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 8px 20px rgba(139, 92, 246, 0.3); }
.btn-primary:active { transform: translateY(0); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; transform: none; box-shadow: none; }

/* ==========================================================================
   フィード / リンクカード
   ========================================================================== */
.feed {
  display: flex;
  flex-direction: column;
}

/* .feed は display:flex を指定しているため、hidden属性だけでは非表示にならない
   (ブラウザ標準の [hidden] { display:none } より、このクラスの display 指定が
   優先されてしまうため)。.modal-backdrop[hidden] と同様に明示的に上書きする。 */
.feed[hidden] {
  display: none;
}

.post {
  position: relative;
  display: flex;
  gap: 12px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  animation: fadeInUp 0.5s ease both;
  transition: background 0.2s ease;
}

.post:hover { background: var(--hover-tint); }

/* ドメインごとに色が変わるオーラ(このアプリの署名要素) */
.post .aura {
  position: absolute;
  top: 10px;
  left: 46px;
  width: 140px;
  height: 140px;
  border-radius: 50%;
  filter: blur(38px);
  opacity: 0.35;
  background: hsl(var(--aura-hue, 200) 90% 55%);
  animation: breathe 6s ease-in-out infinite;
  pointer-events: none;
  z-index: 0;
}

.post-avatar {
  position: relative;
  z-index: 1;
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--surface-strong);
  border: 1px solid var(--border-strong);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  box-shadow: 0 0 0 3px hsla(var(--aura-hue, 200) 90% 55% / 0.15);
}

.post-avatar img { width: 19px; height: 19px; object-fit: contain; }
.post-avatar .fallback {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-dim);
  text-transform: uppercase;
}

.post-main {
  position: relative;
  z-index: 1;
  flex: 1;
  min-width: 0;
}

.post-head {
  display: flex;
  align-items: baseline;
  gap: 7px;
  flex-wrap: wrap;
}

.post-head .name {
  font-weight: 600;
  font-size: 13.5px;
  color: var(--text);
}

.post-head .handle,
.post-head .time {
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--text-faint);
}

.post-comment {
  margin: 3px 0 7px;
  font-size: 13.5px;
  line-height: 1.45;
  color: var(--text);
}

/* リンクの埋め込みカード(URL文字列は出さない) */
.link-card {
  display: block;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  overflow: hidden;
  text-decoration: none;
  color: inherit;
  transition: border-color 0.2s ease, transform 0.18s ease, background 0.2s ease;
}

.link-card:hover {
  border-color: hsla(var(--aura-hue, 200) 90% 65% / 0.5);
  transform: translateY(-2px);
  background: var(--surface-strong);
}

.link-card .thumb {
  width: 100%;
  aspect-ratio: 1.7 / 1;
  background-color: var(--bg-alt);
  position: relative;
  overflow: hidden;
}

.link-card .thumb-img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
}

.link-card .thumb::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.45), transparent 50%);
}

.link-card .thumb.no-image {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: linear-gradient(135deg, hsla(var(--aura-hue, 200) 70% 20% / 1), var(--bg-alt));
}

.link-card .thumb.no-image img { width: 56px; height: 56px; opacity: 0.9; }

.link-card .thumb-domain {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-dim);
}

.link-card .info {
  padding: 9px 11px;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.link-card .domain-row {
  display: flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-faint);
  text-transform: lowercase;
}

.link-card .domain-row img { width: 12px; height: 12px; border-radius: 3px; }

.link-card .title {
  font-family: var(--font-display);
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.link-card .desc {
  font-size: 11.5px;
  color: var(--text-dim);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* 写真のみの投稿カード(リンクなし)
   縦横比を固定して、画像の読み込み前から高さを確保しておく
   (読み込み完了時にカードがガクッと伸び縮みしてレイアウトがズレるのを防ぐため) */
.photo-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
  background: var(--bg-alt);
  aspect-ratio: 4 / 3;
}

.photo-card img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.post-actions {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-top: 6px;
}

.action-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  border: none;
  background: transparent;
  color: var(--text-faint);
  font-family: var(--font-mono);
  font-size: 11.5px;
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 8px;
  transition: color 0.15s ease, background 0.15s ease;
}

.action-btn svg { width: 15px; height: 15px; }

.action-btn:hover { background: var(--surface); color: var(--text-dim); }

.action-btn.like svg { transition: transform 0.25s cubic-bezier(.34,1.56,.64,1); }
.action-btn.like.liked { color: var(--like); }
.action-btn.like.liked svg { fill: var(--like); stroke: var(--like); transform: scale(1.15); }
.action-btn.like.burst svg { animation: heartBurst 0.4s ease; }

.action-btn.comment-toggle:hover { color: var(--accent-b); }

/* ==========================================================================
   コメント(返信)
   ========================================================================== */
.comments-panel {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.comments-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.comments-status {
  font-size: 12.5px;
  color: var(--text-faint);
  padding: 4px 0;
}

.comment-item {
  display: flex;
  gap: 10px;
}

.comment-avatar {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--surface-strong);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-size: 11px;
  font-weight: 600;
  color: var(--text-dim);
  overflow: hidden;
}

.comment-body { min-width: 0; }

.comment-author {
  font-weight: 600;
  font-size: 13px;
  color: var(--text);
}

.comment-handle {
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--text-faint);
  margin-left: 6px;
}

.comment-text {
  margin: 2px 0 0;
  font-size: 13.5px;
  line-height: 1.5;
  color: var(--text-dim);
}

.comment-form {
  display: flex;
  gap: 8px;
}

.comment-form input {
  flex: 1;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  border-radius: 999px;
  padding: 9px 14px;
  font-size: 13px;
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.comment-form input:focus {
  border-color: var(--accent-b);
  box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.15);
}

.comment-form .btn-primary { padding: 8px 16px; font-size: 12.5px; flex-shrink: 0; }

/* ==========================================================================
   プロフィール
   ========================================================================== */
.profile-view { padding: 24px; }

.profile-header {
  display: flex;
  align-items: center;
  gap: 18px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 6px;
}

.profile-info { min-width: 0; }

.profile-avatar {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent-a), var(--accent-b));
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-size: 26px;
  font-weight: 700;
  color: var(--bg);
  overflow: hidden;
  flex-shrink: 0;
}

.profile-info h2 {
  margin: 0 0 2px;
  font-family: var(--font-display);
  font-size: 20px;
}

.profile-info .handle {
  font-family: var(--font-mono);
  color: var(--text-faint);
  font-size: 13px;
}

.profile-stats {
  display: flex;
  gap: 16px;
  margin-top: 8px;
  font-size: 13px;
  color: var(--text-dim);
}

.profile-stats b { color: var(--text); }

.profile-bio {
  margin: 6px 0 0;
  font-size: 13.5px;
  line-height: 1.5;
  color: var(--text-dim);
  white-space: pre-wrap;
}

.profile-actions { margin-left: auto; display: flex; gap: 8px; }

.btn-ghost {
  border: 1px solid var(--border-strong);
  background: transparent;
  color: var(--text);
  padding: 8px 18px;
  border-radius: 999px;
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
  transition: background 0.2s ease, border-color 0.2s ease;
}

.btn-ghost:hover { background: var(--surface); }
.btn-ghost.following { color: var(--accent-a); border-color: var(--accent-a); }
.btn-ghost.btn-block { width: 100%; text-align: center; }

/* ==========================================================================
   チャット(相互フォロー限定のダイレクトメッセージ)
   ========================================================================== */
.chats-view { padding: 0; }

.chat-list-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.15s ease;
}

.chat-list-item:hover { background: var(--hover-tint); }

.chat-list-avatar {
  flex-shrink: 0;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  overflow: hidden;
  background: linear-gradient(135deg, var(--accent-a), var(--accent-b));
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-weight: 600;
  color: var(--bg);
}

.chat-list-avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }

.chat-list-main { flex: 1; min-width: 0; }

.chat-list-top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}

.chat-list-name {
  font-weight: 600;
  font-size: 14.5px;
  color: var(--text);
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-list-time {
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--text-faint);
  flex-shrink: 0;
}

.chat-list-preview {
  margin-top: 2px;
  font-size: 13px;
  color: var(--text-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-list-preview.unfollowed { color: var(--text-faint); font-style: italic; }

/* --- 会話画面 --- */
.chat-header {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 20px;
  background: rgba(var(--bg-rgb), 0.85);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
}

.chat-back-btn {
  flex-shrink: 0;
  width: 34px;
  height: 34px;
  border: none;
  background: transparent;
  color: var(--text-dim);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease;
}

.chat-back-btn:hover { background: var(--surface); color: var(--text); }

.chat-header-name { font-weight: 600; font-size: 14.5px; color: var(--text); }
.chat-header-handle { font-family: var(--font-mono); font-size: 11.5px; color: var(--text-faint); }

.chat-messages {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 20px;
}

.chat-bubble-row { display: flex; }
.chat-bubble-row.mine { justify-content: flex-end; }

.chat-bubble-wrap {
  max-width: 75%;
  flex-shrink: 0;
}

.chat-bubble {
  padding: 9px 14px;
  border-radius: 16px;
  font-size: 14px;
  line-height: 1.5;
}

.chat-bubble-row:not(.mine) .chat-bubble {
  background: var(--bubble-theirs);
  color: var(--bubble-theirs-text);
  border-bottom-left-radius: 4px;
}

.chat-bubble-row.mine .chat-bubble {
  background: var(--bubble-mine);
  color: var(--bubble-mine-text);
  border-bottom-right-radius: 4px;
}

.chat-bubble-time {
  margin-top: 3px;
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--text-faint);
}

.chat-bubble-row.mine .chat-bubble-time { text-align: right; }

.chat-input-form {
  position: sticky;
  bottom: 0;
  z-index: 5;
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 12px 20px;
  background: rgba(var(--bg-rgb), 0.85);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-top: 1px solid var(--border);
}

.chat-input-form input {
  flex: 1;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  border-radius: 999px;
  padding: 10px 16px;
  font-size: 14px;
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.chat-input-form input:focus {
  border-color: var(--accent-b);
  box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.15);
}

.chat-input-form .btn-primary { flex-shrink: 0; padding: 10px 18px; }

.chat-unavailable {
  margin: 16px 20px;
  padding: 12px 16px;
  border-radius: var(--radius-md);
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-faint);
  font-size: 13px;
}

/* ==========================================================================
   設定
   ========================================================================== */
.settings-view { padding: 24px; max-width: 480px; }

.settings-section { margin-bottom: 28px; }

.settings-section-title {
  font-family: var(--font-display);
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-faint);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin: 0 0 10px;
}

.settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 15px 18px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
  margin-bottom: 10px;
}

.settings-row-title { font-size: 14.5px; font-weight: 600; color: var(--text); }
.settings-row-desc { font-size: 12.5px; color: var(--text-faint); margin-top: 2px; }

/* トグルスイッチ */
.switch {
  position: relative;
  display: inline-block;
  width: 46px;
  height: 26px;
  flex-shrink: 0;
}

.switch input {
  position: absolute;
  inset: 0;
  opacity: 0;
  margin: 0;
  cursor: pointer;
  z-index: 1;
}

.switch-track {
  position: absolute;
  inset: 0;
  border-radius: 999px;
  background: var(--surface-strong);
  border: 1px solid var(--border-strong);
  transition: background 0.2s ease, border-color 0.2s ease;
}

.switch-track::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--text-dim);
  transition: transform 0.2s ease, background 0.2s ease;
}

.switch input:checked + .switch-track {
  background: linear-gradient(135deg, var(--accent-a), var(--accent-b));
  border-color: transparent;
}

.switch input:checked + .switch-track::after {
  transform: translateX(20px);
  background: var(--bg);
}

/* ==========================================================================
   空の状態
   ========================================================================== */
.empty-state {
  padding: 60px 24px;
  text-align: center;
  color: var(--text-faint);
}

.empty-state svg { opacity: 0.5; margin-bottom: 14px; }
.empty-state p { font-size: 14px; margin: 0; }

/* ==========================================================================
   投稿ボタン(フローティングアクションボタン)
   ========================================================================== */
.fab {
  position: fixed;
  right: 26px;
  bottom: 26px;
  z-index: 40;
  width: 56px;
  height: 56px;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--bg);
  background: linear-gradient(135deg, var(--accent-a), var(--accent-b));
  box-shadow: 0 10px 28px rgba(139, 92, 246, 0.4);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.fab:hover { transform: translateY(-2px) scale(1.04); box-shadow: 0 14px 34px rgba(139, 92, 246, 0.5); }
.fab:active { transform: translateY(0) scale(0.98); }

/* .fab は display:flex を指定しているため、hidden属性だけでは非表示にならない。
   .feed[hidden] と同じ理由。 */
.fab[hidden] { display: none; }

/* ==========================================================================
   モーダル(ログイン / 登録)
   ========================================================================== */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(5, 6, 10, 0.6);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fadeIn 0.2s ease both;
}

.modal-backdrop[hidden] {
  display: none;
}

.modal {
  position: relative;
  width: 100%;
  max-width: 360px;
  background: rgba(var(--panel-rgb), 0.85);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  padding: 26px 24px 22px;
  animation: popIn 0.25s cubic-bezier(.2,.8,.3,1.2) both;
}

.modal-title {
  margin: 0 0 16px;
  font-family: var(--font-display);
  font-size: 17px;
  font-weight: 600;
}

.modal-compose { max-width: 480px; }

.modal-compose .composer {
  padding: 0;
  border-bottom: none;
  animation: none;
}

.avatar-edit {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 4px;
}

.avatar-edit-preview {
  flex-shrink: 0;
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent-a), var(--accent-b));
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 700;
  color: var(--bg);
  overflow: hidden;
}

.avatar-edit-preview img { width: 100%; height: 100%; object-fit: cover; display: block; }

.modal-privacy {
  margin: 6px 0 0;
  font-size: 11.5px;
  line-height: 1.5;
  color: var(--text-faint);
  text-align: center;
}

.modal-privacy a { color: var(--accent-a); }

.btn-google {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  border: 1px solid var(--border-strong);
  background: #fff;
  color: #1f1f1f;
  padding: 10px 0;
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 13.5px;
  text-decoration: none;
  cursor: pointer;
  transition: background 0.2s ease, transform 0.15s ease, box-shadow 0.15s ease;
}

.btn-google:hover { background: #f4f4f4; transform: translateY(-1px); box-shadow: 0 6px 16px rgba(0, 0, 0, 0.25); }
.btn-google:active { transform: translateY(0); }

.modal-divider {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 16px 0;
  color: var(--text-faint);
  font-size: 12px;
}

.modal-divider::before,
.modal-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--border);
}

.modal-tabs {
  display: flex;
  gap: 6px;
  margin-bottom: 18px;
  background: var(--surface);
  border-radius: 999px;
  padding: 4px;
}

.modal-tab {
  flex: 1;
  border: none;
  background: transparent;
  color: var(--text-faint);
  padding: 8px 0;
  border-radius: 999px;
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease;
}

.modal-tab.active { background: var(--surface-strong); color: var(--text); }

.modal-form { display: flex; flex-direction: column; gap: 10px; }

.modal-form input,
.modal-form textarea {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 11px 14px;
  font-size: 14px;
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.modal-form textarea {
  resize: vertical;
  min-height: 64px;
  font-family: var(--font-body);
}

.modal-form input:focus,
.modal-form textarea:focus { border-color: var(--accent-b); box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.15); }

.modal-form .btn-primary { margin-top: 4px; padding: 11px 0; }

.modal-error {
  color: var(--like);
  font-size: 12.5px;
  min-height: 16px;
  margin: 2px 0 0;
}

.modal-close {
  position: absolute;
  top: 12px;
  right: 14px;
  border: none;
  background: transparent;
  color: var(--text-faint);
  font-size: 20px;
  cursor: pointer;
  line-height: 1;
}

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

/* ==========================================================================
   トースト
   ========================================================================== */
.toast {
  position: fixed;
  bottom: 26px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: rgba(var(--panel-rgb), 0.9);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid var(--border-strong);
  color: var(--text);
  padding: 11px 20px;
  border-radius: 999px;
  font-size: 13.5px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s ease;
  z-index: 100;
}

.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ==========================================================================
   アニメーション
   ========================================================================== */
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes popIn {
  from { opacity: 0; transform: scale(0.94) translateY(6px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

@keyframes breathe {
  0%, 100% { opacity: 0.28; transform: scale(1); }
  50% { opacity: 0.42; transform: scale(1.12); }
}

@keyframes heartBurst {
  0% { transform: scale(1); }
  35% { transform: scale(1.5); }
  100% { transform: scale(1.15); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}

/* ==========================================================================
   レスポンシブ: 広いデスクトップ画面ではサイドナビにラベルを表示し、
   余白にもゆとりを持たせる
   ========================================================================== */
@media (min-width: 960px) {
  .app {
    grid-template-columns: 220px minmax(0, 640px);
    column-gap: 16px;
  }

  .rail {
    align-items: stretch;
    padding: 24px 8px;
  }

  .rail-logo {
    width: auto;
    justify-content: flex-start;
    padding: 0 14px 0 10px;
    gap: 8px;
    margin-left: 4px;
  }

  .rail-wordmark {
    display: inline;
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 15px;
    letter-spacing: -0.01em;
  }

  .rail-btn {
    width: 100%;
    height: auto;
    justify-content: flex-start;
    padding: 13px 16px;
    border-radius: 999px;
    font-size: 15px;
    font-weight: 600;
  }

  .rail-label {
    display: inline;
  }

  /* PC表示はスマホよりさらにコンパクトな投稿カードにして、縦により多くの投稿を収める */
  .post {
    gap: 10px;
    padding: 8px 18px;
  }

  .post-avatar { width: 28px; height: 28px; }
  .post-avatar img { width: 15px; height: 15px; }
  .post-avatar .fallback { font-size: 10.5px; }

  .post-head { gap: 6px; }
  .post-head .name { font-size: 12.5px; }
  .post-head .handle,
  .post-head .time { font-size: 10.5px; }

  .post-comment {
    margin: 2px 0 5px;
    font-size: 12.5px;
    line-height: 1.35;
  }

  .post-actions { gap: 10px; margin-top: 3px; }
  .action-btn { padding: 3px 5px; font-size: 10.5px; }
  .action-btn svg { width: 13px; height: 13px; }

  .link-card .info { padding: 7px 9px; gap: 2px; }
  .link-card .domain-row { font-size: 10.5px; }
  .link-card .title { font-size: 12.5px; }
  .link-card .desc { font-size: 11px; }
}

@media (min-width: 1320px) {
  .app {
    grid-template-columns: 260px minmax(0, 680px);
    column-gap: 32px;
  }
  .main { max-width: 680px; }
}

/* ==========================================================================
   レスポンシブ: スマートフォン画面
   ========================================================================== */
@media (max-width: 720px) {
  .app { grid-template-columns: 1fr; }
  .rail {
    position: fixed;
    bottom: 0;
    top: auto;
    left: 0;
    right: 0;
    height: 76px;
    width: 100%;
    flex-direction: row;
    align-items: flex-start;
    justify-content: space-around;
    gap: 0;
    padding: 12px 4px 10px;
    background: rgba(var(--bg-rgb), 0.85);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-top: 1px solid var(--border);
    z-index: 20;
  }
  .rail-logo { display: none; }
  .rail-spacer { display: none; }

  /* ナビが6項目に増えたので、狭い画面でもはみ出さないよう一回り小さくする */
  .rail-btn { width: 40px; height: 40px; flex-shrink: 0; }
  .rail-btn svg { width: 20px; height: 20px; }
  .main { border-left: none; border-right: none; padding-bottom: 84px; }

  .fab { right: 18px; bottom: 94px; }
  .chat-input-form { bottom: 76px; }

  /* 投稿カード・チャット関連の左右余白が画面幅に対して狭すぎた(固定px指定だったため)。
     画面幅に対する割合(6%ずつ = 左右合計12%)で確保するようにする。
     チャットはメッセージ本体(.chat-messages)だけでなく、上部ヘッダー・下部入力欄・
     一覧画面の行にも同じ固定px指定があったため、まとめて上書きする。 */
  .post { padding-left: 6%; padding-right: 6%; }
  .chat-messages,
  .chat-header,
  .chat-input-form,
  .chat-list-item {
    padding-left: 6%;
    padding-right: 6%;
  }

  /* iOS Safari は入力欄の font-size が16px未満だとフォーカス時に自動ズームするため揃える */
  .composer-body input[type="text"],
  #urlInput,
  .comment-form input,
  .modal-form input {
    font-size: 16px;
  }
}
