:root {
  color-scheme: light;
  --bg: #ffffff;
  --surface: #ffffff;
  --surface-subtle: #f7f9f9;
  --text: #0f1419;
  --muted: #536471;
  --border: #eff3f4;
  --border-strong: #cfd9de;
  --primary: #1d9bf0;
  --primary-hover: #1a8cd8;
  --danger: #f4212e;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans JP", Helvetica, Arial, sans-serif;
  font-synthesis: none;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #000000;
  --surface: #000000;
  --surface-subtle: #16181c;
  --text: #e7e9ea;
  --muted: #71767b;
  --border: #2f3336;
  --border-strong: #536471;
}

@media (prefers-color-scheme: dark) {
  :root[data-theme="system"] {
    color-scheme: dark;
    --bg: #000000;
    --surface: #000000;
    --surface-subtle: #16181c;
    --text: #e7e9ea;
    --muted: #71767b;
    --border: #2f3336;
    --border-strong: #536471;
  }
}

* { box-sizing: border-box; }
html { background: var(--bg); }
body { min-height: 100vh; margin: 0; background: var(--bg); color: var(--text); }
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: inherit; text-decoration: none; }
svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }

.app-shell {
  display: grid;
  grid-template-columns: 250px minmax(0, 600px) 350px;
  width: min(100%, 1200px);
  min-height: 100vh;
  margin: 0 auto;
}

.sidebar {
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
  height: 100vh;
  padding: 8px 20px 12px 8px;
}

.wordmark {
  display: flex;
  align-items: center;
  gap: 10px;
  width: max-content;
  padding: 10px 12px;
  border-radius: 999px;
  font-size: 20px;
  font-weight: 800;
}

.wordmark:hover { background: var(--surface-subtle); }
.brand-mark {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border: 2px solid currentColor;
  border-radius: 50%;
  font-size: 16px;
  line-height: 1;
}

.primary-nav { display: grid; margin-top: 8px; }
.nav-item {
  display: flex;
  align-items: center;
  gap: 20px;
  width: max-content;
  max-width: 100%;
  padding: 12px 16px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  font-size: 19px;
  text-align: left;
}
.nav-item:hover, .account-chip:hover { background: var(--surface-subtle); }
.nav-item.is-active { font-weight: 700; }
.connect-button {
  width: 90%;
  margin: 18px 0 0 8px;
  padding: 14px 20px;
  border: 0;
  border-radius: 999px;
  background: var(--primary);
  color: #fff;
  font-weight: 700;
}
.connect-button:hover { background: var(--primary-hover); }
.sidebar-account { margin-top: auto; }
.account-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  text-align: left;
}
.account-copy { min-width: 0; }
.account-copy strong, .account-copy span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.account-copy strong { font-size: 14px; }
.account-copy span { color: var(--muted); font-size: 14px; }

.main-column { min-width: 0; border-right: 1px solid var(--border); border-left: 1px solid var(--border); }
.view { display: none; min-height: 100vh; }
.view.is-active { display: block; }
.column-header {
  position: sticky;
  z-index: 10;
  top: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 54px;
  padding: 0 16px;
  border-bottom: 1px solid var(--border);
  background: color-mix(in srgb, var(--bg) 94%, transparent);
  backdrop-filter: blur(10px);
}
.column-header h1 { margin: 0; font-size: 20px; }
.icon-button {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
}
.icon-button:hover { background: var(--surface-subtle); color: var(--text); }

.avatar {
  flex: none;
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--avatar, #536471);
  color: #fff;
  font-size: 13px;
  font-weight: 700;
}
.feed { min-height: 200px; }
.post {
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr);
  gap: 10px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}
.post:hover { background: color-mix(in srgb, var(--surface-subtle) 55%, transparent); }
.post-avatar { width: 46px; height: 46px; }
.post-head { display: flex; align-items: baseline; min-width: 0; gap: 5px; font-size: 15px; }
.post-head strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ai-badge { display: none; }
.handle, .post-time { color: var(--muted); font-size: 14px; }
.post-time::before { content: "·"; margin-right: 5px; }
.privacy-icon { margin-left: auto; color: var(--muted); }
.privacy-icon svg { width: 14px; height: 14px; }
.post-body { margin: 3px 0 10px; font-size: 15px; line-height: 1.45; white-space: pre-wrap; overflow-wrap: anywhere; }
.post-relation { margin: 0 0 3px; color: var(--primary); font-size: 13px; }
.quote-card { margin: 10px 0; padding: 12px; border: 1px solid var(--border-strong); border-radius: 14px; }
.quote-card strong { font-size: 14px; }
.quote-card p { margin: 4px 0 0; font-size: 14px; line-height: 1.45; }
.post-actions { display: flex; justify-content: space-between; max-width: 340px; color: var(--muted); }
.post-action { display: flex; align-items: center; gap: 5px; padding: 3px; border: 0; background: transparent; color: inherit; font-size: 12px; }
.post-action svg { width: 18px; height: 18px; }
.post-owner:hover { color: var(--danger); }
.feed-loading { display: flex; justify-content: center; gap: 5px; padding: 64px; }
.feed-loading span { width: 6px; height: 6px; border-radius: 50%; background: var(--primary); animation: pulse 1.2s infinite; }
.feed-loading span:nth-child(2) { animation-delay: .15s; }
.feed-loading span:nth-child(3) { animation-delay: .3s; }
@keyframes pulse { 50% { opacity: .2; } }
.empty-state { padding: 64px 28px; text-align: center; }
.empty-orb { display: none; }
.empty-state h2 { margin: 0 0 7px; font-size: 24px; }
.empty-state p { max-width: 360px; margin: 0 auto; color: var(--muted); line-height: 1.5; }

.context-column { padding: 12px 0 24px 24px; }
.context-sticky { position: sticky; top: 12px; }
.ai-card, .side-menu { overflow: hidden; border: 1px solid var(--border); border-radius: 16px; background: var(--surface); }
.ai-card:empty { display: none; }
.ai-card { padding: 16px; }
.ai-profile-avatar { width: 48px; height: 48px; }
.ai-card h2 { margin: 10px 0 1px; font-size: 18px; }
.ai-card .handle { display: block; }
.visibility-pill { display: block; margin-top: 10px; color: var(--muted); font-size: 13px; }
.side-menu { margin-top: 12px; }
.side-menu button {
  display: flex;
  flex-direction: column;
  width: 100%;
  padding: 14px 16px;
  border: 0;
  border-bottom: 1px solid var(--border);
  background: transparent;
  text-align: left;
}
.side-menu button:last-child { border-bottom: 0; }
.side-menu button:hover { background: var(--surface-subtle); }
.side-menu span { margin-top: 3px; color: var(--muted); font-size: 13px; }
footer { display: flex; gap: 7px; padding: 14px 4px; color: var(--muted); font-size: 12px; }

.section-content { padding: 0; }
.panel, .settings-group { padding: 18px 16px; border-bottom: 1px solid var(--border); }
.panel-title, .settings-group h2 { margin: 0 0 16px; font-size: 18px; }
.panel-description { margin: 0 0 14px; color: var(--muted); font-size: 14px; }
.form-stack { display: grid; gap: 17px; }
label { display: grid; gap: 6px; color: var(--muted); font-size: 13px; }
input, textarea, select {
  width: 100%;
  padding: 11px 12px;
  border: 1px solid var(--border-strong);
  border-radius: 4px;
  background: var(--bg);
  outline: none;
}
textarea { min-height: 80px; resize: vertical; }
input:focus, textarea:focus, select:focus { border-color: var(--primary); box-shadow: 0 0 0 1px var(--primary); }
.primary-button, .secondary-button { padding: 9px 17px; border: 0; border-radius: 999px; font-weight: 700; }
.primary-button { background: var(--text); color: var(--bg); }
.secondary-button { background: var(--surface-subtle); }
.settings-actions { display: flex; justify-content: flex-end; }
.settings-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.settings-row strong, .settings-row small { display: block; }
.settings-row small { margin-top: 2px; color: var(--muted); }
.account-close-row { margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--border); }
.danger-link-button { padding: 7px 0; border: 0; background: transparent; color: var(--danger); font-weight: 700; }
.danger-button { width: 100%; padding: 11px 18px; border: 0; border-radius: 999px; background: var(--danger); color: #fff; font-weight: 700; }
.theme-options { display: flex; padding: 2px; border: 1px solid var(--border-strong); border-radius: 999px; }
.theme-options button { padding: 6px 11px; border: 0; border-radius: 999px; background: transparent; color: var(--muted); font-size: 12px; }
.theme-options button.is-active { background: var(--text); color: var(--bg); }
.settings-link { padding: 0; }
.settings-link > button { display: flex; align-items: center; justify-content: space-between; width: 100%; padding: 17px 16px; border: 0; background: transparent; text-align: left; }
.settings-link > button:hover { background: var(--surface-subtle); }
.settings-link strong, .settings-link small { display: block; }
.settings-link small { margin-top: 3px; color: var(--muted); }
.settings-link b { color: var(--muted); font-size: 25px; font-weight: 400; }
.connection-form { display: flex; gap: 8px; }
.connection-list { margin-top: 14px; }
.connection-item { display: flex; align-items: center; gap: 10px; padding: 11px 0; border-top: 1px solid var(--border); }
.connection-copy { min-width: 0; flex: 1; }
.connection-copy strong, .connection-copy span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.connection-copy span { color: var(--muted); font-size: 13px; }
.mini-actions { display: flex; gap: 6px; }
.mini-button { padding: 6px 10px; border: 1px solid var(--border-strong); border-radius: 999px; background: var(--bg); font-size: 12px; font-weight: 700; }
.mini-button.accept { background: var(--text); color: var(--bg); }
.auth-prompt { padding: 64px 24px; text-align: center; }
.auth-prompt p { color: var(--muted); }

.mobile-header, .mobile-nav, .mobile-guide-fab { display: none; }
.avatar-button { padding: 0; border: 0; background: transparent; }
.auth-dialog, .guide-dialog {
  width: min(calc(100% - 28px), 520px);
  padding: 24px;
  border: 1px solid var(--border-strong);
  border-radius: 16px;
  background: var(--surface);
  color: var(--text);
}
dialog::backdrop { background: #0009; }
.dialog-close { position: absolute; top: 10px; right: 12px; display: grid; place-items: center; width: 36px; height: 36px; padding: 0; border: 0; border-radius: 50%; background: transparent; font-size: 25px; }
.dialog-close:hover, .guide-back:hover { background: var(--surface-subtle); }
.auth-dialog h2 { margin: 8px 0; }
.dialog-description { margin: 0 0 24px; color: var(--muted); }
.google-button { display: block; padding: 12px 18px; border: 1px solid var(--border-strong); border-radius: 999px; text-align: center; font-weight: 700; }
.google-button:hover { background: var(--surface-subtle); }

.guide-dialog { height: min(760px, calc(100vh - 28px)); padding: 0; overflow: hidden; }
.guide-header { position: relative; display: flex; align-items: center; justify-content: center; height: 54px; border-bottom: 1px solid var(--border); }
.guide-header .dialog-close { top: 8px; }
.guide-back { position: absolute; left: 10px; display: grid; place-items: center; width: 36px; height: 36px; padding: 0; border: 0; border-radius: 50%; background: transparent; font-size: 20px; }
.guide-back:disabled { visibility: hidden; }
.guide-pages { height: calc(100% - 116px); overflow: auto; }
.guide-page { padding: 20px 24px 28px; }
.guide-page h2 { margin: 20px 0 7px; font-size: 24px; }
.guide-page > p { margin: 0; color: var(--muted); line-height: 1.55; }
.guide-plan { display: grid; place-items: center; align-content: center; min-height: 320px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface-subtle); }
.guide-plan span { font-size: 30px; font-weight: 700; }
.guide-plan strong { margin-top: 12px; padding: 7px 15px; border-radius: 999px; background: var(--text); color: var(--bg); }
.guide-image { display: block; width: auto; max-width: 100%; height: 390px; margin: 0 auto; border: 1px solid var(--border); border-radius: 10px; object-fit: contain; background: #000; }
.guide-image-wide { width: 100%; height: auto; max-height: 390px; }
.guide-image-stack { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.guide-image-stack .guide-image { width: 100%; height: 235px; }
.guide-values { margin: 14px 0 0; border-top: 1px solid var(--border); }
.guide-values div { display: grid; grid-template-columns: 130px 1fr; padding: 10px 0; border-bottom: 1px solid var(--border); }
.guide-values dt { color: var(--muted); }
.guide-values dd { min-width: 0; margin: 0; overflow-wrap: anywhere; }
.guide-values code { font-size: 12px; }
.guide-page > .secondary-button { margin-top: 14px; }
.guide-prompt-page .guide-image-wide { max-height: 220px; }
.prompt-options { display: grid; grid-template-columns: 1.3fr 1fr 1fr; gap: 10px; margin-top: 16px; }
.prompt-options label { gap: 5px; }
.prompt-options select { padding: 9px 10px; }
.prompt-preview-label { margin-top: 12px; }
.prompt-preview { min-height: 170px; padding: 12px; border-radius: 8px; background: var(--surface-subtle); font-size: 12px; line-height: 1.55; }
.prompt-copy-button { width: 100%; margin-top: 12px !important; }
#guide-next { position: absolute; right: 20px; bottom: 14px; min-width: 90px; }
.toast { position: fixed; z-index: 100; left: 50%; bottom: 24px; transform: translate(-50%, 14px); padding: 10px 16px; border-radius: 4px; background: var(--text); color: var(--bg); font-size: 13px; opacity: 0; pointer-events: none; transition: .2s; }
.toast.is-visible { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 1080px) {
  .app-shell { grid-template-columns: 88px minmax(0, 600px) 320px; width: min(100%, 1008px); }
  .sidebar { align-items: center; padding-right: 8px; }
  .wordmark > span:last-child, .nav-item span, .connect-button, .account-copy { display: none; }
  .primary-nav { width: 100%; }
  .nav-item { justify-content: center; width: 100%; }
}

@media (max-width: 860px) {
  .app-shell { display: block; max-width: 600px; }
  .sidebar, .context-column { display: none; }
  .main-column { border-right: 1px solid var(--border); border-left: 1px solid var(--border); }
  .mobile-header { position: sticky; z-index: 15; top: 0; display: flex; align-items: center; justify-content: space-between; height: 54px; padding: 0 16px; border-bottom: 1px solid var(--border); background: var(--bg); }
  .wordmark.compact { padding: 0; }
  .column-header { top: 54px; }
  .mobile-nav { position: fixed; z-index: 20; right: 0; bottom: 0; left: 0; display: grid; grid-template-columns: repeat(3, 1fr); padding: 7px 12px calc(7px + env(safe-area-inset-bottom)); border-top: 1px solid var(--border); background: color-mix(in srgb, var(--bg) 96%, transparent); backdrop-filter: blur(10px); }
  .mobile-nav button { display: grid; justify-items: center; gap: 2px; padding: 0; border: 0; background: transparent; color: var(--muted); font-size: 10px; }
  .mobile-nav button.is-active { color: var(--primary); }
  .mobile-guide-fab {
    position: fixed;
    z-index: 19;
    right: max(16px, env(safe-area-inset-right));
    bottom: calc(76px + env(safe-area-inset-bottom));
    display: grid;
    place-items: center;
    width: 54px;
    height: 54px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: var(--primary);
    color: #fff;
    box-shadow: 0 2px 8px #0004;
  }
  .mobile-guide-fab:hover { background: var(--primary-hover); }
  .mobile-guide-fab svg { width: 25px; height: 25px; stroke-width: 2.1; }
  .view { padding-bottom: 68px; }
  .toast { bottom: 80px; }
}

@media (max-width: 520px) {
  .main-column { border: 0; }
  .post { grid-template-columns: 42px minmax(0, 1fr); padding: 11px 14px; }
  .post-avatar { width: 40px; height: 40px; }
  .handle { max-width: 96px; overflow: hidden; text-overflow: ellipsis; }
  .settings-row { align-items: stretch; flex-direction: column; }
  .theme-options button { flex: 1; }
  .connection-form { display: grid; }
  .guide-page { padding: 16px; }
  .guide-image { height: 360px; }
  .guide-image-wide { height: auto; }
  .guide-values div { grid-template-columns: 105px 1fr; }
  .guide-image-stack { grid-template-columns: 1fr; }
  .guide-image-stack .guide-image { height: auto; max-height: 260px; }
  .prompt-options { grid-template-columns: 1fr; gap: 9px; }
  .guide-prompt-page .guide-image-wide { max-height: 180px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
