/*  Pangraphy Web 体験版 styles  */
/*  iOS app の foo_colors / foo_typography をベースにシンプル化  */

:root {
  --canvas-bg: #0a0a0f;
  --surface-bg: #1a1a2e;
  --surface-faint: rgba(255, 255, 255, 0.05);
  --neon-lime: #dfff4f;
  --neon-lime-faint: rgba(223, 255, 79, 0.12);
  --error: #ff4f4f;
  --text-hero: rgba(255, 255, 255, 1);
  --text-high: rgba(255, 255, 255, 0.85);
  --text-body: rgba(255, 255, 255, 0.7);
  --text-secondary: rgba(255, 255, 255, 0.6);
  --text-muted: rgba(255, 255, 255, 0.4);
  --text-caption: rgba(255, 255, 255, 0.4);
  --text-ghost: rgba(255, 255, 255, 0.2);
  --border-subtle: rgba(255, 255, 255, 0.08);
  --border-default: rgba(255, 255, 255, 0.18);
  --radius-tech: 4px;
  --radius-container: 12px;
  --radius-surface: 16px;
  --radius-pill: 999px;
  --safe-area-bottom: env(safe-area-inset-bottom, 0);
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  padding: 0;
  background: var(--canvas-bg);
  color: var(--text-high);
  font-family: 'Inter', 'Noto Sans JP', -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
  font-weight: 400;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
}

body {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

/* ────────  ToS / Onboarding modal  ──────── */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.85);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 24px;
}
.modal-overlay.show { display: flex; }
.modal-card {
  background: var(--canvas-bg);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-surface);
  padding: 24px;
  max-width: 420px;
  width: 100%;
}
.modal-title {
  font-size: 28px;
  font-weight: 300;
  line-height: 1.2;
  margin: 0 0 16px;
  color: var(--text-hero);
}
.modal-body {
  font-size: 14px;
  color: var(--text-body);
  line-height: 1.6;
  margin: 0 0 20px;
}

/* ────────  inputs / buttons  ──────── */

.text-input {
  width: 100%;
  padding: 14px 16px;
  border: 1px solid var(--border-default);
  border-radius: var(--radius-container);
  background: var(--surface-faint);
  color: var(--text-high);
  font-size: 16px;
  font-family: inherit;
}
.text-input:focus {
  outline: none;
  border-color: var(--neon-lime);
}
textarea.text-input {
  resize: vertical;
  min-height: 80px;
}

.checkbox-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin: 14px 0 18px;
  cursor: pointer;
  user-select: none;
}
.checkbox-row input[type='checkbox'] {
  appearance: none;
  width: 20px;
  height: 20px;
  border: 1px solid var(--border-default);
  border-radius: var(--radius-tech);
  background: var(--surface-faint);
  cursor: pointer;
  position: relative;
  flex-shrink: 0;
  margin: 0;
}
.checkbox-row input[type='checkbox']:checked {
  background: var(--neon-lime);
  border-color: var(--neon-lime);
}
.checkbox-row input[type='checkbox']:checked::after {
  content: '';
  position: absolute;
  left: 6px;
  top: 2px;
  width: 6px;
  height: 12px;
  border: solid var(--canvas-bg);
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}
.checkbox-row label {
  font-size: 13px;
  color: var(--text-body);
  line-height: 1.4;
  cursor: pointer;
}
.checkbox-row a { color: var(--neon-lime); text-decoration: none; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 52px;
  padding: 0 24px;
  border: 1.5px solid var(--neon-lime);
  border-radius: var(--radius-tech);
  background: transparent;
  color: var(--neon-lime);
  font-size: 14px;
  font-weight: 500;
  letter-spacing: 1px;
  cursor: pointer;
  font-family: inherit;
  transition: opacity 0.15s;
}
.btn:hover:not(:disabled) { background: var(--neon-lime-faint); }
.btn:disabled {
  border-color: var(--border-default);
  color: var(--text-muted);
  cursor: not-allowed;
}
.btn-secondary {
  border-color: var(--border-default);
  color: var(--text-secondary);
}
.btn-secondary:hover:not(:disabled) { background: var(--surface-faint); }

/* ────────  layout  ──────── */

.app-shell {
  display: flex;
  flex-direction: column;
  flex: 1;
  width: 100%;
  max-width: 600px;
  margin: 0 auto;
  padding-bottom: calc(64px + var(--safe-area-bottom));
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-subtle);
  background: var(--canvas-bg);
}
.app-header .brand {
  font-size: 16px;
  letter-spacing: 2px;
  color: var(--text-secondary);
  font-weight: 200;
}
.app-header .me {
  font-size: 11px;
  color: var(--text-muted);
  font-family: 'JetBrains Mono', ui-monospace, monospace;
}

.tab-content {
  flex: 1;
  overflow-y: auto;
  padding: 0;
}
.view { display: none; }
.view.active { display: block; }

/* ────────  bottom nav  ──────── */

.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  background: var(--canvas-bg);
  border-top: 1px solid var(--border-subtle);
  padding-bottom: var(--safe-area-bottom);
  z-index: 50;
}
.bottom-nav .tab-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 64px;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 10px;
  letter-spacing: 1.5px;
  font-family: inherit;
  cursor: pointer;
  gap: 4px;
}
.bottom-nav .tab-btn.active {
  color: var(--neon-lime);
}
.bottom-nav .tab-btn .icon {
  font-size: 22px;
  line-height: 1;
}
.bottom-nav .tab-btn.create .icon-circle {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--neon-lime-faint);
  border: 1px solid var(--neon-lime);
  color: var(--neon-lime);
  font-size: 24px;
  line-height: 1;
}
.bottom-nav .tab-btn.create.active .icon-circle {
  background: var(--neon-lime);
  color: var(--canvas-bg);
  border-color: var(--neon-lime);
}

/* ────────  feed  ──────── */

.feed-list {
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.feed-card {
  background: var(--surface-bg);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-container);
  overflow: hidden;
}
.feed-card .card-image {
  aspect-ratio: 4 / 3;
  width: 100%;
  background: var(--surface-faint);
  display: block;
  object-fit: cover;
  cursor: pointer;
}
.feed-card .card-body {
  padding: 12px;
}
.feed-card .card-desc {
  margin: 0 0 8px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-high);
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.feed-card .card-meta {
  font-size: 11px;
  color: var(--text-caption);
  font-family: 'JetBrains Mono', ui-monospace, monospace;
}
.tag-buttons {
  display: flex;
  gap: 6px;
  margin-top: 12px;
}
.tag-btn {
  flex: 1;
  height: 44px;
  border-radius: var(--radius-container);
  background: transparent;
  border: 1px solid var(--text-muted);
  color: var(--text-body);
  font-size: 11px;
  font-family: inherit;
  cursor: pointer;
  padding: 4px 6px;
  line-height: 1.2;
}
.tag-btn:hover { background: var(--surface-faint); }
.tag-btn.selected {
  border-color: var(--neon-lime);
  background: var(--neon-lime-faint);
  color: var(--neon-lime);
  font-weight: 600;
}
.mini-tag-bar {
  display: flex;
  height: 4px;
  margin-top: 8px;
  border-radius: var(--radius-tech);
  overflow: hidden;
  background: var(--border-subtle);
}
.mini-tag-bar > div { height: 100%; }
.mini-tag-bar .seg-photo { background: var(--text-body); }
.mini-tag-bar .seg-also { background: var(--neon-lime); }
.mini-tag-bar .seg-not { background: var(--text-muted); }

/* ────────  post (create) view  ──────── */

.post-view {
  padding: 16px;
}
.post-view h2 {
  font-size: 13px;
  letter-spacing: 2px;
  color: var(--text-caption);
  text-transform: uppercase;
  margin: 0 0 12px;
  font-weight: 400;
}
.image-picker {
  width: 100%;
  aspect-ratio: 4 / 3;
  border: 2px dashed var(--border-default);
  border-radius: var(--radius-container);
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface-faint);
  cursor: pointer;
  position: relative;
  overflow: hidden;
  margin-bottom: 16px;
}
.image-picker.has-preview { border-style: solid; border-color: var(--neon-lime); }
.image-picker img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.image-picker .placeholder {
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
}
.image-picker .placeholder span {
  font-size: 36px;
  display: block;
  margin-bottom: 6px;
  color: var(--neon-lime);
}
.image-picker input[type='file'] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}
.field-group { margin-bottom: 14px; }
.field-group label {
  font-size: 11px;
  color: var(--text-caption);
  letter-spacing: 1.5px;
  display: block;
  margin-bottom: 6px;
  text-transform: uppercase;
}
.upload-progress {
  display: none;
  text-align: center;
  font-size: 13px;
  color: var(--neon-lime);
  margin: 12px 0;
}
.upload-progress.show { display: block; }

/* ────────  map view  ──────── */

.map-view {
  position: relative;
  height: calc(100vh - 64px - 56px - var(--safe-area-bottom));
  height: calc(100dvh - 64px - 56px - var(--safe-area-bottom));
}
#mapCanvas {
  width: 100%;
  height: 100%;
  display: block;
}

/* ────────  detail modal  ──────── */

.detail-modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.92);
  display: none;
  z-index: 200;
  overflow-y: auto;
}
.detail-modal.show { display: block; }
.detail-modal .close-btn {
  position: fixed;
  top: 14px;
  right: 14px;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--surface-bg);
  color: var(--text-high);
  border: none;
  font-size: 22px;
  cursor: pointer;
  z-index: 201;
}
.detail-content {
  max-width: 600px;
  margin: 0 auto;
  padding: 56px 16px calc(40px + var(--safe-area-bottom));
}
.detail-content img {
  width: 100%;
  border-radius: var(--radius-container);
  display: block;
  margin-bottom: 16px;
}
.detail-content .detail-title {
  font-size: 18px;
  color: var(--text-hero);
  margin: 0 0 8px;
  line-height: 1.4;
}
.detail-content .detail-meta {
  font-size: 12px;
  color: var(--text-caption);
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  margin-bottom: 16px;
}

.tag-summary-section {
  margin: 18px 0;
  padding: 12px 0;
  border-top: 1px solid var(--border-subtle);
  border-bottom: 1px solid var(--border-subtle);
}
.tag-summary-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}
.tag-summary-row .label {
  width: 96px;
  font-size: 12px;
  color: var(--text-secondary);
}
.tag-summary-row .bar-bg {
  flex: 1;
  height: 4px;
  background: var(--border-subtle);
  border-radius: var(--radius-tech);
  overflow: hidden;
}
.tag-summary-row .bar-fill {
  height: 100%;
  border-radius: var(--radius-tech);
}
.tag-summary-row .pct {
  width: 40px;
  text-align: right;
  font-size: 11px;
  color: var(--text-caption);
  font-family: 'JetBrains Mono', ui-monospace, monospace;
}

.comment-section {
  margin-top: 24px;
}
.comment-section h3 {
  font-size: 11px;
  letter-spacing: 2px;
  color: var(--text-caption);
  margin: 0 0 12px;
  text-transform: uppercase;
}
.comment-input-row {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}
.comment-input-row .text-input { font-size: 14px; padding: 10px 12px; }
.comment-input-row .send-btn {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-container);
  background: var(--neon-lime);
  color: var(--canvas-bg);
  border: none;
  font-size: 18px;
  cursor: pointer;
  flex-shrink: 0;
}
.comment-input-row .send-btn:disabled {
  background: var(--surface-bg);
  color: var(--text-ghost);
  cursor: not-allowed;
}
.comment-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.comment-item {
  padding: 8px 0;
  border-bottom: 1px solid var(--border-subtle);
}
.comment-item .meta {
  font-size: 11px;
  color: var(--text-caption);
  margin-bottom: 4px;
  font-family: 'JetBrains Mono', ui-monospace, monospace;
}
.comment-item .meta .name {
  font-weight: 600;
  color: var(--text-secondary);
  font-family: inherit;
}
.comment-item .meta .tag-pill {
  display: inline-block;
  padding: 1px 6px;
  border: 0.5px solid currentColor;
  border-radius: var(--radius-tech);
  font-size: 9px;
  margin-left: 6px;
}
.comment-item .meta .tag-pill.photo { color: var(--text-body); }
.comment-item .meta .tag-pill.also { color: var(--neon-lime); }
.comment-item .meta .tag-pill.not { color: var(--text-muted); }
.comment-item .text {
  font-size: 13px;
  color: var(--text-body);
  line-height: 1.5;
}

/* ────────  empty / loading  ──────── */

.empty-state, .loading-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
  font-size: 13px;
}

.toast {
  position: fixed;
  bottom: calc(80px + var(--safe-area-bottom));
  left: 50%;
  transform: translateX(-50%);
  background: var(--surface-bg);
  color: var(--text-body);
  padding: 12px 20px;
  border-radius: var(--radius-container);
  font-size: 13px;
  border: 1px solid var(--border-subtle);
  z-index: 300;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}
.toast.show { opacity: 1; }

/* ────────  Settings sheet  ──────── */

.me-button {
  background: none;
  border: none;
  padding: 4px 8px;
  border-radius: var(--radius-tech);
  cursor: pointer;
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 11px;
  color: var(--text-muted);
}
.me-button:hover { background: var(--surface-faint); color: var(--text-secondary); }

.settings-sheet {
  background: var(--canvas-bg);
  border-radius: var(--radius-surface) var(--radius-surface) 0 0;
  width: 100%;
  max-width: 600px;
  margin-top: auto;
  padding: 8px 0 calc(12px + var(--safe-area-bottom));
  border-top: 1px solid var(--border-default);
  border-left: 1px solid var(--border-default);
  border-right: 1px solid var(--border-default);
}
.modal-overlay#settingsModal,
.modal-overlay#editNameModal {
  align-items: flex-end;
  padding: 0;
}
.modal-overlay#editNameModal {
  align-items: center;
  padding: 24px;
}
.sheet-handle {
  width: 36px;
  height: 4px;
  background: var(--border-default);
  border-radius: var(--radius-pill);
  margin: 0 auto 12px;
}
.settings-item {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  padding: 16px 20px;
  background: none;
  border: none;
  color: var(--text-high);
  font-size: 15px;
  font-family: inherit;
  text-align: left;
  cursor: pointer;
}
.settings-item:hover { background: var(--surface-faint); }
.settings-item .ico {
  width: 24px;
  text-align: center;
  color: var(--text-secondary);
  font-size: 18px;
}
.settings-item.danger { color: var(--error); }
.settings-item.danger .ico { color: var(--error); }
.settings-item.cancel {
  justify-content: center;
  color: var(--text-muted);
  font-weight: 500;
}
.settings-divider {
  height: 1px;
  background: var(--border-subtle);
  margin: 0 20px;
}

/* ────────  Lightbox (full-screen image viewer)  ──────── */

.lightbox {
  position: fixed;
  inset: 0;
  background: #000;
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 250;
  padding: 0;
}
.lightbox.show { display: flex; }
.lightbox img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  user-select: none;
  -webkit-user-select: none;
}
.lightbox-close {
  position: absolute;
  top: calc(14px + env(safe-area-inset-top, 0));
  right: 14px;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.18);
  color: #fff;
  border: none;
  font-size: 22px;
  cursor: pointer;
  z-index: 251;
}
.lightbox-close:hover { background: rgba(255, 255, 255, 0.28); }

/* Hint that detail image is tappable */
.detail-content > img {
  cursor: zoom-in;
}

/* ────────  Admin  ──────── */

.admin-layout {
  padding: 20px;
  max-width: 900px;
  margin: 0 auto;
}
.admin-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 16px;
  font-size: 13px;
}
.admin-table th, .admin-table td {
  padding: 8px;
  text-align: left;
  border-bottom: 1px solid var(--border-subtle);
  vertical-align: middle;
}
.admin-table th {
  color: var(--text-caption);
  font-size: 11px;
  letter-spacing: 1px;
  text-transform: uppercase;
  font-weight: 500;
}
.admin-table td.text-muted { color: var(--text-muted); }
.admin-table img { width: 56px; height: 56px; object-fit: cover; border-radius: var(--radius-tech); }
.admin-action-btn {
  background: transparent;
  border: 1px solid var(--error);
  color: var(--error);
  padding: 6px 14px;
  border-radius: var(--radius-tech);
  font-size: 12px;
  cursor: pointer;
  font-family: inherit;
}
.admin-action-btn:hover { background: rgba(255, 79, 79, 0.1); }
.admin-action-btn.toggle {
  border-color: var(--border-default);
  color: var(--text-secondary);
}
.admin-action-btn.toggle.on {
  border-color: var(--neon-lime);
  color: var(--neon-lime);
}
.admin-tabs {
  display: flex;
  gap: 12px;
  border-bottom: 1px solid var(--border-subtle);
  margin-bottom: 16px;
}
.admin-tab-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  padding: 10px 12px;
  font-family: inherit;
  font-size: 13px;
  cursor: pointer;
  border-bottom: 2px solid transparent;
}
.admin-tab-btn.active { color: var(--neon-lime); border-bottom-color: var(--neon-lime); }

/* Bulk action bar */
.bulk-action-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 14px;
  background: var(--neon-lime-faint);
  border: 1px solid var(--neon-lime);
  border-radius: var(--radius-tech);
  margin-bottom: 12px;
  color: var(--neon-lime);
  font-size: 13px;
}
.bulk-checkbox {
  appearance: none;
  width: 18px;
  height: 18px;
  border: 1px solid var(--border-default);
  border-radius: 3px;
  background: var(--surface-faint);
  cursor: pointer;
  vertical-align: middle;
  position: relative;
  margin: 0;
}
.bulk-checkbox:checked {
  background: var(--neon-lime);
  border-color: var(--neon-lime);
}
.bulk-checkbox:checked::after {
  content: '';
  position: absolute;
  left: 5px;
  top: 1px;
  width: 5px;
  height: 10px;
  border: solid var(--canvas-bg);
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}
.admin-action-btn.danger-strong {
  border-color: var(--error);
  color: var(--error);
  background: rgba(255, 79, 79, 0.05);
}
.admin-action-btn.danger-strong:hover {
  background: rgba(255, 79, 79, 0.15);
}

/* ─────────  guest mode (deep link via /p/{postId})  ───────── */

/* ゲストモード時は通常の UI（ボトムナビ・設定ボタン・タブ群）を隠して
   詳細モーダルだけを「ページ」として見せる。 */
body.guest-mode .bottom-nav,
body.guest-mode .me-button,
body.guest-mode .tab-content {
  display: none !important;
}

/* 閉じるボタンも隠す（このページから抜ける動線は CTA → App Store のみ） */
body.guest-mode .detail-modal .close-btn {
  display: none !important;
}

/* 詳細モーダルを「単一ページ」として見せる */
body.guest-mode .detail-modal {
  background: var(--canvas-bg);
}

/* DL 誘導 CTA は通常モードでは非表示、ゲストモードでのみ表示 */
.guest-cta {
  display: none;
}
body.guest-mode .guest-cta {
  display: block;
  margin-top: 32px;
  margin-bottom: 16px;
  padding: 24px 20px;
  background: var(--surface-bg);
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
  text-align: center;
}
.guest-cta-title {
  color: var(--neon-lime);
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 8px;
  letter-spacing: 0.02em;
}
.guest-cta-body {
  color: rgba(255, 255, 255, 0.7);
  font-size: 14px;
  line-height: 1.6;
  margin-bottom: 20px;
}
.guest-cta-btn {
  display: inline-block;
  padding: 14px 28px;
  background: var(--neon-lime);
  color: var(--canvas-bg);
  border-radius: 8px;
  text-decoration: none;
  font-weight: 600;
  font-size: 14px;
  letter-spacing: 0.02em;
}
.guest-cta-btn:hover {
  opacity: 0.9;
}
