/* ============================================================
   OB Lite — styles.css
   Mobile-first PWA / 375px base / Dark primary / WCAG AA
   ============================================================ */

/* ---- Web Fonts ---- */
@import url('https://fonts.googleapis.com/css2?family=Geologica:wght@400&family=Inter:wght@400;500;600;700&family=Noto+Sans+JP:wght@400;500;700&family=JetBrains+Mono:wght@400;500&display=swap');

/* ============================================================
   Design Tokens — CSS Variables
   ============================================================ */
:root {
  /* ---- Background Layers ---- */
  --bg-base:        #1e1e1e;
  --bg-surface:     #1d1d1d;
  --bg-elevated:    #1a1a1a;
  --bg-overlay:     #202020;
  --bg-hover:       #2a2a2a;
  --bg-active:      #323232;
  --bg-input:       #1a1a1a;
  --bg-code:        #111111;

  /* ---- Text ---- */
  --text-primary:   #e9e9e9;
  --text-secondary: #d7d7d7;
  --text-muted:     #6a6a6a;
  --text-inverse:   #0d0d0d;
  --text-link:      #7c9ef5;

  /* ---- Accent ---- */
  --accent-primary:       #7c9ef5;
  --accent-primary-hover: #9ab4ff;
  --accent-primary-muted: #1e2a4a;

  /* ---- Semantic ---- */
  --color-success:        #5fb87a;
  --color-success-muted:  #0d2016;
  --color-warning:        #e0a840;
  --color-warning-muted:  #2a1e00;
  --color-error:          #e05c5c;
  --color-error-muted:    #2a0d0d;
  --color-info:           #60b4d8;
  --color-info-muted:     #0a1e28;

  /* ---- Border ---- */
  --border-subtle:  #2c2c2c;
  --border-default: #303030;
  --border-strong:  #484848;
  --border-accent:  #7c9ef5;

  /* ---- Scrollbar ---- */
  --scrollbar-thumb: #333333;
  --scrollbar-track: transparent;

  /* ---- Font Families ---- */
  --font-sans: 'Inter', 'Noto Sans JP', system-ui, -apple-system, sans-serif;
  /* ブランド表記（アプリ名）専用。LP（about.html / guide）と同じ Geologica */
  --font-brand: 'Geologica', 'Inter', 'Noto Sans JP', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', 'Noto Sans Mono', monospace;

  /* ---- Font Size Scale ---- */
  --text-2xs:  0.9375rem;
  --text-xs:   1rem;
  --text-sm:   1.0625rem;
  --text-base: 1.1875rem;
  --text-md:   1.3125rem;
  --text-lg:   1.4375rem;
  --text-xl:   1.5625rem;
  --text-2xl:  1.9375rem;
  --text-3xl:  2.375rem;

  /* ---- Font Weights ---- */
  --weight-regular:  400;
  --weight-medium:   500;
  --weight-semibold: 600;
  --weight-bold:     700;

  /* ---- Line Heights ---- */
  --leading-tight:   1.2;
  --leading-snug:    1.4;
  --leading-normal:  1.6;
  --leading-relaxed: 1.75;

  /* ---- Letter Spacing ---- */
  --tracking-tight:  -0.01em;
  --tracking-normal: 0em;
  --tracking-wide:   0.04em;

  /* ---- Spacing (8px base scale) ---- */
  --space-0:   0;
  --space-px:  1px;
  --space-0-5: 0.125rem;
  --space-1:   0.25rem;
  --space-1-5: 0.375rem;
  --space-2:   0.5rem;
  --space-3:   0.75rem;
  --space-4:   1rem;
  --space-5:   1.25rem;
  --space-6:   1.5rem;
  --space-8:   2rem;
  --space-10:  2.5rem;
  --space-12:  3rem;
  --space-16:  4rem;
  --space-20:  5rem;

  /* ---- Border Radius (直線ベース) ---- */
  --radius-none:  0;
  --radius-sm:    2px;
  --radius-input: 4px;

  /* ---- Borders ---- */
  --border-width: 1px;
  --border-style: solid;

  /* ---- Safe Area (iOS standalone: ステータスバーとの干渉防止) ---- */
  --safe-top: env(safe-area-inset-top, 0px);
  /* 画面最上部バーの上余白。インセット0のブラウザ表示でも最低限の余白を確保 */
  --bar-top-pad: calc(env(safe-area-inset-top, 0px) + var(--space-1));

  /* ---- Transitions ---- */
  --transition-fast:  100ms ease;
  --transition-base:  180ms ease;
  --transition-slow:  300ms ease;
}

/* ============================================================
   Global Reset
   ============================================================ */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font-sans);
  background: var(--bg-base);
  color: var(--text-primary);
  height: 100dvh;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

button {
  font-family: var(--font-sans);
}

a {
  color: var(--text-link);
  text-decoration: none;
}

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

/* Scrollbar styling */
::-webkit-scrollbar {
  width: 4px;
  height: 4px;
}
::-webkit-scrollbar-thumb {
  background-color: var(--scrollbar-thumb);
  border-radius: 2px;
}
::-webkit-scrollbar-track {
  background: var(--scrollbar-track);
}

/* ============================================================
   Screen Management
   ============================================================ */
.screen {
  display: none;
  height: 100dvh;
  flex-direction: column;
  position: relative;
}

.screen--active {
  display: flex;
}

/* ============================================================
   App Shell Layout
   ============================================================ */
.app-shell {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  background-color: var(--bg-base);
  color: var(--text-primary);
  font-family: var(--font-sans);
  overflow: hidden;
}

.app-main {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-y: contain;
}

/* ============================================================
   Splash Screen (起動時のローディング)
   ============================================================ */
.splash {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-6);
  background-color: #E5EDFD; /* アイコン背景・manifest background_color と同値 */
}

.splash__logo {
  display: block;
  opacity: 0.95;
}

.splash__spinner {
  width: 24px;
  height: 24px;
  border: 2px solid var(--border-subtle, rgba(255,255,255,0.15));
  border-top-color: var(--text-primary);
  border-radius: 50%;
  animation: splash-spin 0.8s linear infinite;
}

@keyframes splash-spin {
  to { transform: rotate(360deg); }
}

/* ============================================================
   Login Screen
   ============================================================ */
.login-screen {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: calc(var(--space-8) + var(--safe-top)) var(--space-6) var(--space-8);
  background-color: #E3EEFF;
  overflow-y: auto;
}

.login-logo {
  font-family: var(--font-brand);
  font-size: var(--text-2xl);
  font-weight: var(--weight-regular);
  color: #235794;
  letter-spacing: 1.5px;
  margin-bottom: var(--space-2);
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.login-tagline {
  font-size: var(--text-sm);
  color: rgba(35, 87, 148, 0.7);
  margin-bottom: var(--space-10);
}

.login-legal {
  margin-top: var(--space-8);
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: var(--space-2) var(--space-4);
}

.login-legal a {
  font-size: var(--text-xs);
  color: rgba(35, 87, 148, 0.6);
  text-decoration: none;
}

.login-legal a:hover {
  text-decoration: underline;
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: var(--space-5);
}

/* ライト背景上での視認性確保 */
.login-screen .input-label {
  color: #235794;
}
.login-screen .input-hint,
.login-screen .input-error-msg {
  color: rgba(35, 87, 148, 0.7);
}

.form-field {
  display: flex;
  flex-direction: column;
}

/* ============================================================
   Header / App Bar
   ============================================================ */
.app-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: calc(56px + var(--bar-top-pad));
  padding: var(--bar-top-pad) var(--space-2) 0;
  background-color: var(--bg-surface);
  border-bottom: var(--border-width) var(--border-style) var(--border-subtle);
  position: sticky;
  top: 0;
  z-index: 100;
  flex-shrink: 0;
}

.app-bar__left {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  min-width: 0;
  flex: 1;
}

.app-bar__title {
  font-size: var(--text-md);
  font-weight: var(--weight-semibold);
  color: var(--text-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 200px;
}

/* アプリ名表示（メイン画面ヘッダー）。LP と同じ Geologica で揃える */
.app-bar__title--brand {
  font-family: var(--font-brand);
  font-weight: var(--weight-regular);
  letter-spacing: 1px;
}

.app-bar__title--editable {
  cursor: text;
  padding: 2px 6px;
  margin-left: -6px;
  border: 1px solid transparent;
  transition: border-color 120ms ease, background-color 120ms ease;
}
.app-bar__title--editable:hover,
.app-bar__title--editable:focus-visible {
  border-color: var(--border-subtle, rgba(255,255,255,0.18));
  background-color: var(--bg-elevated, rgba(255,255,255,0.04));
  outline: none;
}

.app-bar__title-input {
  font-size: var(--text-md);
  font-weight: var(--weight-semibold);
  color: var(--text-primary);
  background-color: var(--bg-elevated, rgba(255,255,255,0.06));
  border: 1px solid var(--accent, #4a90e2);
  padding: 2px 6px;
  margin-left: -6px;
  max-width: 220px;
  width: 220px;
  min-width: 0;
  font-family: inherit;
  outline: none;
}
.app-bar__title-input:disabled {
  opacity: 0.6;
}

.app-bar__actions {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  flex-shrink: 0;
}

/* ============================================================
   Tab Bar
   ============================================================ */
.tab-bar {
  display: flex;
  background-color: var(--bg-surface);
  border-bottom: var(--border-width) var(--border-style) var(--border-subtle);
  flex-shrink: 0;
}

.tab-btn {
  flex: 1;
  padding: var(--space-3) var(--space-2);
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  color: var(--text-muted);
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  transition: color var(--transition-fast), border-color var(--transition-fast);
  min-height: 44px;
  -webkit-tap-highlight-color: transparent;
  letter-spacing: var(--tracking-normal);
}

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

.tab-btn--active {
  color: var(--accent-primary);
  border-bottom-color: var(--accent-primary);
}

.tab-btn:focus-visible {
  outline: 2px solid var(--border-accent);
  outline-offset: -2px;
}

/* ============================================================
   Breadcrumb
   ============================================================ */
.breadcrumb {
  padding: var(--space-2) var(--space-4);
  background-color: var(--bg-surface);
  border-bottom: var(--border-width) var(--border-style) var(--border-subtle);
  flex-shrink: 0;
}

.breadcrumb__path {
  font-size: var(--text-xs);
  color: var(--text-muted);
  font-family: var(--font-mono);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  display: block;
}

/* ============================================================
   File Tree
   ============================================================ */
.tree-item {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-3);
  font-size: var(--text-base);
  color: var(--text-secondary);
  border-left: 2px solid transparent;
  cursor: pointer;
  transition: background-color var(--transition-fast),
              color var(--transition-fast),
              border-color var(--transition-fast);
  min-height: 44px;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none; /* 長押しメニュー用: OS標準のコールアウトを抑止 */
  -webkit-tap-highlight-color: transparent;
  border-bottom: var(--border-width) var(--border-style) var(--border-subtle);
}

.tree-item:hover {
  background-color: var(--bg-hover);
  color: var(--text-primary);
}

.tree-item:active {
  background-color: var(--bg-active);
}

.tree-item--active {
  background-color: var(--accent-primary-muted);
  color: var(--accent-primary);
  border-left-color: var(--accent-primary);
}

.tree-item--folder > .tree-item__icon {
  color: var(--accent-primary);
  opacity: 0.8;
}

.tree-item__icon {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  color: var(--text-muted);
}

.tree-item__name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tree-item__meta {
  font-size: var(--text-xs);
  color: var(--text-muted);
  flex-shrink: 0;
}

/* インデントレベル */
.tree-item[data-depth="1"] { padding-left: calc(var(--space-3) + 16px); }
.tree-item[data-depth="2"] { padding-left: calc(var(--space-3) + 32px); }
.tree-item[data-depth="3"] { padding-left: calc(var(--space-3) + 48px); }

/* フォルダ開閉シェブロン */
.tree-chevron {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
  color: var(--text-muted);
  transition: transform var(--transition-fast);
}

.tree-item--open > .tree-chevron {
  transform: rotate(90deg);
}

/* ============================================================
   Viewer
   ============================================================ */
.viewer-content {
  padding: var(--space-4) var(--space-4) var(--space-16);
  max-width: 100%;
}

/* ---- Outline (Table of Contents) ---- */
.outline-backdrop {
  position: fixed;
  inset: 0;
  background-color: rgba(0, 0, 0, 0.5);
  z-index: 210;
}

.outline-drawer {
  position: fixed;
  top: calc(56px + var(--bar-top-pad));
  right: 0;
  bottom: 0;
  width: min(86vw, 320px);
  background-color: var(--bg-surface);
  border-left: var(--border-width) var(--border-style) var(--border-subtle);
  transform: translateX(100%);
  transition: transform 0.22s ease-out;
  z-index: 220;
  display: flex;
  flex-direction: column;
  box-shadow: -4px 0 12px rgba(0, 0, 0, 0.3);
}

.outline-drawer--open {
  transform: translateX(0);
}

.outline-drawer__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-3) var(--space-4);
  border-bottom: var(--border-width) var(--border-style) var(--border-subtle);
  flex-shrink: 0;
}

.outline-drawer__title {
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  color: var(--text-primary);
  letter-spacing: 0.02em;
}

.outline-list {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-2) 0;
}

.outline-item {
  display: block;
  width: 100%;
  text-align: left;
  background: transparent;
  border: none;
  padding: var(--space-2) var(--space-4);
  color: var(--text-secondary);
  font-size: var(--text-xs);
  line-height: var(--leading-snug);
  cursor: pointer;
  border-left: 2px solid transparent;
  transition: background-color 0.15s, color 0.15s, border-color 0.15s;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.outline-item:hover,
.outline-item:focus-visible {
  background-color: var(--bg-hover);
  color: var(--text-primary);
  border-left-color: var(--accent-primary);
  outline: none;
}

.outline-item--l1 { padding-left: var(--space-4); font-weight: var(--weight-semibold); color: var(--text-primary); }
.outline-item--l2 { padding-left: calc(var(--space-4) + var(--space-3)); }
.outline-item--l3 { padding-left: calc(var(--space-4) + var(--space-6)); }
.outline-item--l4 { padding-left: calc(var(--space-4) + var(--space-8)); font-size: var(--text-2xs); }
.outline-item--l5 { padding-left: calc(var(--space-4) + var(--space-10)); font-size: var(--text-2xs); color: var(--text-muted); }
.outline-item--l6 { padding-left: calc(var(--space-4) + var(--space-12)); font-size: var(--text-2xs); color: var(--text-muted); }

.md-body .md-heading {
  scroll-margin-top: 64px;
}

/* ============================================================
   Editor
   ============================================================ */
.editor-shell {
  display: flex;
  flex-direction: column;
  height: 100%;
}

.editor-content {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  display: flex;
  flex-direction: column;
}

.editor-container {
  width: 100%;
  flex: 1;
  min-height: 0;
  background-color: var(--bg-base);
}

.editor-container .cm-editor {
  height: 100%;
}

/* ============================================================
   Toolbar (Editor)
   ============================================================ */
.toolbar {
  display: flex;
  align-items: center;
  gap: var(--space-0-5);
  padding: var(--space-1) var(--space-2);
  background-color: var(--bg-surface);
  border-bottom: var(--border-width) var(--border-style) var(--border-subtle);
  overflow-x: auto;
  overscroll-behavior-x: contain;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  flex-shrink: 0;
}

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

.editor-toolbar {
  flex-shrink: 0;
  position: sticky;
  top: 56px;
  z-index: 50;
}

.toolbar-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border: none;
  border-radius: var(--radius-input);
  background-color: transparent;
  color: var(--text-secondary);
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  cursor: pointer;
  flex-shrink: 0;
  transition: background-color var(--transition-fast),
              color var(--transition-fast);
  -webkit-tap-highlight-color: transparent;
}

.toolbar-btn:hover {
  background-color: var(--bg-hover);
  color: var(--text-primary);
}

.toolbar-btn:active,
.toolbar-btn--active {
  background-color: var(--accent-primary-muted);
  color: var(--accent-primary);
}

.toolbar-btn:focus-visible {
  outline: 2px solid var(--border-accent);
  outline-offset: 1px;
}

.toolbar-divider {
  width: 1px;
  height: 24px;
  background-color: var(--border-subtle);
  margin: 0 var(--space-1);
  flex-shrink: 0;
}

/* ============================================================
   Search Overlay
   ============================================================ */
.search-overlay {
  position: fixed;
  inset: 0;
  background-color: var(--bg-base);
  z-index: 150;
  display: flex;
  flex-direction: column;
}

.search-overlay__bar {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: calc(var(--space-3) + var(--safe-top)) var(--space-4) var(--space-3);
  background-color: var(--bg-surface);
  border-bottom: var(--border-width) var(--border-style) var(--border-subtle);
  flex-shrink: 0;
}

.search-input-wrap {
  flex: 1;
  position: relative;
}

.search-results {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.search-result-item {
  display: flex;
  flex-direction: column;
  gap: var(--space-0-5);
  padding: var(--space-3) var(--space-4);
  border-bottom: var(--border-width) var(--border-style) var(--border-subtle);
  cursor: pointer;
  transition: background-color var(--transition-fast);
  -webkit-tap-highlight-color: transparent;
}

.search-result-item:hover,
.search-result-item:active {
  background-color: var(--bg-hover);
}

.search-result-item__name {
  font-size: var(--text-base);
  color: var(--text-primary);
  font-weight: var(--weight-medium);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.search-result-item__path {
  font-size: var(--text-xs);
  color: var(--text-muted);
  font-family: var(--font-mono);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.search-result-item__match {
  font-size: var(--text-sm);
  color: var(--text-secondary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.search-highlight {
  color: var(--accent-primary);
  font-weight: var(--weight-semibold);
}

.search-empty {
  padding: var(--space-12) var(--space-6);
}

/* ============================================================
   Toast Notifications
   ============================================================ */
.toast-container {
  position: fixed;
  bottom: calc(env(safe-area-inset-bottom, 0px) + var(--space-4));
  left: var(--space-4);
  right: var(--space-4);
  z-index: 300;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  background-color: var(--bg-overlay);
  border: var(--border-width) var(--border-style) var(--border-default);
  border-left: 3px solid var(--border-default);
  font-size: var(--text-base);
  color: var(--text-primary);
  animation: toast-in var(--transition-base);
  pointer-events: auto;
}

@keyframes toast-in {
  from { transform: translateY(8px); opacity: 0; }
  to   { transform: translateY(0);   opacity: 1; }
}

@keyframes toast-out {
  from { transform: translateY(0);   opacity: 1; }
  to   { transform: translateY(8px); opacity: 0; }
}

.toast--success { border-left-color: var(--color-success); }
.toast--warning { border-left-color: var(--color-warning); }
.toast--error   { border-left-color: var(--color-error); }
.toast--info    { border-left-color: var(--accent-primary); }
.toast--exit    { animation: toast-out var(--transition-base) forwards; }

.toast__icon  { flex-shrink: 0; width: 16px; height: 16px; }
.toast__msg   { flex: 1; line-height: var(--leading-snug); }
.toast__close {
  flex-shrink: 0;
  color: var(--text-muted);
  cursor: pointer;
  padding: var(--space-1);
  background: none;
  border: none;
  display: flex;
  align-items: center;
  min-height: 44px;
  min-width: 44px;
  justify-content: center;
  -webkit-tap-highlight-color: transparent;
}

/* ============================================================
   Dialog / Bottom Sheet
   ============================================================ */
.dialog-backdrop {
  position: fixed;
  inset: 0;
  background-color: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(2px);
  z-index: 200;
  display: flex;
  align-items: flex-end;
  padding: 0;
}

@media (min-width: 600px) {
  .dialog-backdrop {
    align-items: center;
    padding: var(--space-4);
  }
}

.dialog {
  width: 100%;
  max-width: 480px;
  margin: 0 auto;
  background-color: var(--bg-overlay);
  border: var(--border-width) var(--border-style) var(--border-default);
  border-radius: 0;
  border-top: 2px solid var(--border-default);
  overflow: hidden;
  animation: dialog-slide-up var(--transition-base);
}

@media (min-width: 600px) {
  .dialog {
    border-top-width: var(--border-width);
    border-top-color: var(--border-default);
  }
}

@keyframes dialog-slide-up {
  from { transform: translateY(20px); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}

.dialog__header {
  padding: var(--space-4) var(--space-4) var(--space-3);
  border-bottom: var(--border-width) var(--border-style) var(--border-subtle);
}

.dialog__title {
  font-size: var(--text-md);
  font-weight: var(--weight-semibold);
  color: var(--text-primary);
  display: flex;
  align-items: center;
}

.dialog__subtitle {
  font-size: var(--text-sm);
  color: var(--text-secondary);
  margin-top: var(--space-1);
  line-height: var(--leading-snug);
}

.dialog__body {
  padding: var(--space-4);
}

.dialog__footer {
  display: flex;
  justify-content: flex-end;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-4);
  border-top: var(--border-width) var(--border-style) var(--border-subtle);
  background-color: var(--bg-surface);
  padding-bottom: calc(var(--space-3) + env(safe-area-inset-bottom, 0px));
}

/* ログイン: GitHub App 接続との区切り */
.login-divider {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin: var(--space-4) 0;
  font-size: var(--text-xs);
  color: var(--text-secondary);
  user-select: none;
}

.login-divider::before,
.login-divider::after {
  content: '';
  flex: 1;
  border-top: var(--border-width) var(--border-style) var(--border-subtle);
}

.login-pat-toggle {
  background: transparent;
  border: none;
  padding: 0;
  font-size: var(--text-xs);
  color: var(--text-secondary);
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.login-pat-toggle:hover {
  color: var(--text-link);
}

/* ファイル移動: フォルダピッカー */
.move-current-path {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--text-secondary);
  padding: var(--space-2) var(--space-3);
  background-color: var(--bg-surface);
  border: var(--border-width) var(--border-style) var(--border-subtle);
  margin-bottom: var(--space-2);
  word-break: break-all;
}

.move-folder-list {
  max-height: 40vh;
  overflow-y: auto;
  border: var(--border-width) var(--border-style) var(--border-subtle);
}

.move-folder-item {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-3);
  font-size: var(--text-base);
  color: var(--text-secondary);
  cursor: pointer;
  min-height: 44px;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  border-bottom: var(--border-width) var(--border-style) var(--border-subtle);
}

.move-folder-item:last-child {
  border-bottom: none;
}

.move-folder-item:active {
  background-color: var(--bg-active);
}

.move-folder-item__icon {
  color: var(--accent-primary);
  opacity: 0.8;
  display: flex;
  align-items: center;
}

.move-folder-empty {
  padding: var(--space-4);
  font-size: var(--text-sm);
  color: var(--text-tertiary, var(--text-secondary));
  text-align: center;
}

/* コンフリクト差分表示 */
.conflict-diff {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  background-color: var(--bg-code);
  border: var(--border-width) var(--border-style) var(--border-subtle);
  padding: var(--space-3);
  overflow-x: auto;
  max-height: 140px;
  overflow-y: auto;
  color: var(--text-secondary);
  line-height: 1.5;
}

.conflict-diff__added   { color: var(--color-success); }
.conflict-diff__removed { color: var(--color-error); }

/* ============================================================
   Button Components
   ============================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-4);
  font-family: var(--font-sans);
  font-size: var(--text-base);
  font-weight: var(--weight-medium);
  line-height: var(--leading-snug);
  border-radius: var(--radius-input);
  border: var(--border-width) var(--border-style) transparent;
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
  transition: background-color var(--transition-fast),
              border-color var(--transition-fast),
              color var(--transition-fast);
  min-height: 44px;
  min-width: 44px;
  -webkit-tap-highlight-color: transparent;
}

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

.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  pointer-events: none;
}

/* Primary */
.btn--primary {
  background-color: var(--accent-primary);
  color: var(--text-inverse);
  border-color: var(--accent-primary);
}
.btn--primary:hover {
  background-color: var(--accent-primary-hover);
  border-color: var(--accent-primary-hover);
}
.btn--primary:active { opacity: 0.85; }

/* Secondary */
.btn--secondary {
  background-color: transparent;
  color: var(--text-primary);
  border-color: var(--border-default);
}
.btn--secondary:hover {
  background-color: var(--bg-hover);
  border-color: var(--border-strong);
}

/* Ghost */
.btn--ghost {
  background-color: transparent;
  color: var(--text-secondary);
  border-color: transparent;
}
.btn--ghost:hover {
  background-color: var(--bg-hover);
  color: var(--text-primary);
}

/* Danger */
.btn--danger {
  background-color: var(--color-error-muted);
  color: var(--color-error);
  border-color: var(--color-error);
}
.btn--danger:hover {
  background-color: var(--color-error);
  color: #fff;
}

/* Size variants */
.btn--sm {
  padding: var(--space-1-5) var(--space-3);
  font-size: var(--text-sm);
  min-height: 36px;
}
.btn--lg {
  padding: var(--space-3) var(--space-6);
  font-size: var(--text-md);
  min-height: 52px;
}
.btn--icon {
  padding: var(--space-2);
  width: 44px;
  height: 44px;
}

/* ============================================================
   Input / Textarea
   ============================================================ */
.input {
  display: block;
  width: 100%;
  padding: var(--space-3) var(--space-4);
  font-family: var(--font-sans);
  font-size: var(--text-base);
  color: var(--text-primary);
  background-color: var(--bg-input);
  border: var(--border-width) var(--border-style) var(--border-default);
  border-radius: var(--radius-input);
  line-height: var(--leading-snug);
  transition: border-color var(--transition-fast),
              box-shadow var(--transition-fast);
  outline: none;
  -webkit-appearance: none;
  min-height: 44px;
}

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

.input:hover  { border-color: var(--border-strong); }

.input:focus {
  border-color: var(--border-accent);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent-primary) 20%, transparent);
}

.input--error { border-color: var(--color-error); }
.input--error:focus {
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--color-error) 20%, transparent);
}

.input-label {
  display: block;
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  color: var(--text-secondary);
  margin-bottom: var(--space-1-5);
  letter-spacing: var(--tracking-wide);
  text-transform: uppercase;
}

.input-hint {
  font-size: var(--text-xs);
  color: var(--text-muted);
  margin-top: var(--space-1);
}

.input-error-msg {
  font-size: var(--text-xs);
  color: var(--color-error);
  margin-top: var(--space-1);
}

.input--mono {
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  letter-spacing: 0.02em;
}

.textarea {
  resize: vertical;
  min-height: 120px;
  line-height: var(--leading-normal);
}

/* Search Input */
.search-input {
  padding-left: calc(var(--space-4) + 20px + var(--space-2));
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%236a6a6a' stroke-width='2'%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3Cpath d='m21 21-4.35-4.35'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: var(--space-3) center;
  background-size: 16px;
}

/* ============================================================
   Badge / Tag
   ============================================================ */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 1px var(--space-1-5);
  font-size: var(--text-2xs);
  font-weight: var(--weight-medium);
  letter-spacing: var(--tracking-wide);
  text-transform: uppercase;
  border-radius: var(--radius-sm);
  border: var(--border-width) var(--border-style) currentColor;
  line-height: 1.4;
}

.badge--default {
  color: var(--text-muted);
  border-color: var(--border-subtle);
  background-color: var(--bg-elevated);
}
.badge--accent {
  color: var(--accent-primary);
  border-color: var(--accent-primary);
  background-color: var(--accent-primary-muted);
}
.badge--success {
  color: var(--color-success);
  border-color: var(--color-success);
  background-color: var(--color-success-muted);
}
.badge--warning {
  color: var(--color-warning);
  border-color: var(--color-warning);
  background-color: var(--color-warning-muted);
}
.badge--error {
  color: var(--color-error);
  border-color: var(--color-error);
  background-color: var(--color-error-muted);
}

/* ============================================================
   Skeleton Loader
   ============================================================ */
@keyframes shimmer {
  0%   { background-position: -200% 0; }
  100% { background-position:  200% 0; }
}

.skeleton {
  background: linear-gradient(
    90deg,
    var(--bg-elevated) 0%,
    var(--bg-hover) 50%,
    var(--bg-elevated) 100%
  );
  background-size: 200% 100%;
  animation: shimmer 1.4s ease infinite;
  border-radius: 0;
}

.skeleton--text       { height: 14px; width: 100%; }
.skeleton--title      { height: 18px; width: 60%; }
.skeleton--line-short { height: 12px; width: 40%; }

/* ============================================================
   Section Divider
   ============================================================ */
.divider {
  height: var(--border-width);
  background-color: var(--border-subtle);
  border: none;
  margin: 0;
}

.section-label {
  font-size: var(--text-xs);
  font-weight: var(--weight-medium);
  color: var(--text-muted);
  letter-spacing: var(--tracking-wide);
  text-transform: uppercase;
  padding: var(--space-3) var(--space-4) var(--space-1-5);
}

/* ============================================================
   Empty State
   ============================================================ */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--space-12) var(--space-6);
  text-align: center;
}

.empty-state p {
  font-size: var(--text-sm);
  color: var(--text-muted);
}

/* ============================================================
   Loading Area (in-panel)
   ============================================================ */
.loading-area {
  padding: var(--space-4) 0;
}

/* ============================================================
   Offline Banner
   ============================================================ */
.offline-banner {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 250;
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: calc(var(--space-2) + var(--safe-top)) var(--space-4) var(--space-2);
  background-color: var(--color-warning-muted);
  border-bottom: var(--border-width) var(--border-style) var(--color-warning);
  font-size: var(--text-sm);
  color: var(--color-warning);
  animation: slide-down var(--transition-base);
}

@keyframes slide-down {
  from { transform: translateY(-100%); }
  to   { transform: translateY(0); }
}

/* ============================================================
   Pull-to-Refresh
   ============================================================ */
.ptr-indicator {
  position: fixed;
  top: calc(60px + var(--bar-top-pad));
  left: 50%;
  transform: translateX(-50%);
  z-index: 120;
  background-color: var(--bg-overlay);
  border: var(--border-width) var(--border-style) var(--border-default);
  padding: var(--space-2) var(--space-3);
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.ptr-spinner {
  width: 16px;
  height: 16px;
  border: 2px solid var(--border-default);
  border-top-color: var(--accent-primary);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

/* ============================================================
   Global Spinner
   ============================================================ */
.global-spinner {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: rgba(13, 13, 13, 0.6);
  z-index: 400;
}

.spinner {
  width: 32px;
  height: 32px;
  border: 2px solid var(--border-default);
  border-top-color: var(--accent-primary);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ============================================================
   Image Upload Dialog
   ============================================================ */
.image-upload-options {
  margin-bottom: var(--space-4);
}

.image-preview {
  margin-top: var(--space-4);
  border: var(--border-width) var(--border-style) var(--border-default);
  padding: var(--space-2);
  background-color: var(--bg-elevated);
}

/* ============================================================
   Safe Area (Android gesture bar)
   ============================================================ */
.bottom-safe {
  padding-bottom: env(safe-area-inset-bottom, var(--space-4));
  flex-shrink: 0;
}

/* ============================================================
   File Browser Layout
   ============================================================ */
.file-browser {
  display: flex;
  flex-direction: column;
  height: 100%;
}

.file-browser__search {
  padding: var(--space-3) var(--space-4);
  border-bottom: var(--border-width) var(--border-style) var(--border-subtle);
  position: sticky;
  top: 0;
  background-color: var(--bg-surface);
  z-index: 10;
}

.file-browser__body { flex: 1; overflow-y: auto; }

.file-browser__section {
  padding: var(--space-2) 0;
  border-bottom: var(--border-width) var(--border-style) var(--border-subtle);
}

/* ============================================================
   Markdown Rendered Content (.md-body)
   ============================================================ */
.md-body {
  font-family: var(--font-sans);
  font-size: var(--text-base);
  color: var(--text-primary);
  line-height: var(--leading-relaxed);
  word-break: break-word;
  overflow-wrap: break-word;
}

/* Headings */
.md-body h1,
.md-body h2,
.md-body h3,
.md-body h4,
.md-body h5,
.md-body h6 {
  font-weight: var(--weight-semibold);
  line-height: var(--leading-tight);
  color: var(--text-primary);
  margin-top: 1.5em;
  margin-bottom: 0.5em;
}

.md-body h1 {
  font-size: var(--text-2xl);
  padding-bottom: var(--space-2);
  border-bottom: var(--border-width) var(--border-style) var(--border-subtle);
}
.md-body h2 {
  font-size: var(--text-xl);
  padding-bottom: var(--space-1);
  border-bottom: var(--border-width) var(--border-style) var(--border-subtle);
}
.md-body h3 { font-size: var(--text-lg); }
.md-body h4 { font-size: var(--text-md); }
.md-body h5 { font-size: var(--text-base); color: var(--text-secondary); }
.md-body h6 { font-size: var(--text-sm);  color: var(--text-muted); }

/* Paragraph */
.md-body p { margin: 0.75em 0; }

/* Links */
.md-body a {
  color: var(--text-link);
  text-decoration: underline;
  text-underline-offset: 2px;
}
.md-body a:hover { color: var(--accent-primary-hover); }

/* Bold / Italic */
.md-body strong { font-weight: var(--weight-bold);  color: var(--text-primary); }
.md-body em     { font-style: italic;               color: var(--text-secondary); }

/* Inline Code */
.md-body code {
  font-family: var(--font-mono);
  font-size: 0.85em;
  color: var(--accent-primary);
  background-color: var(--bg-elevated);
  padding: 1px var(--space-1-5);
  border-radius: var(--radius-sm);
}

/* Code Block */
.md-body pre {
  background-color: var(--bg-code);
  border: var(--border-width) var(--border-style) var(--border-subtle);
  padding: var(--space-4);
  overflow-x: auto;
  margin: 1em 0;
  border-radius: 0;
  -webkit-overflow-scrolling: touch;
}

.md-body pre code {
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  color: var(--text-primary);
  background-color: transparent;
  padding: 0;
  border-radius: 0;
  line-height: 1.6;
}

/* Lists */
.md-body ul,
.md-body ol {
  padding-left: var(--space-4);
  margin: 0.75em 0;
}

.md-body li {
  margin: 0.25em 0;
  line-height: var(--leading-relaxed);
}

.md-body li::marker { color: var(--text-muted); }
.md-body li.task-item { list-style: none; margin-left: calc(-1 * var(--space-4)); }

/* Task list */
.md-body input[type="checkbox"] {
  -webkit-appearance: none;
  appearance: none;
  width: 14px;
  height: 14px;
  border: 1.5px solid var(--accent-primary);
  border-radius: 50%;
  background: transparent;
  margin-right: var(--space-2);
  vertical-align: -2px;
  cursor: pointer;
  position: relative;
  flex-shrink: 0;
}
.md-body input[type="checkbox"]:checked {
  border-color: var(--accent-primary);
  background: transparent;
}
.md-body input[type="checkbox"]:checked::after {
  content: '✓';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 10px;
  color: var(--accent-primary);
  line-height: 1;
}

/* Blockquote */
.md-body blockquote {
  border-left: 3px solid var(--border-strong);
  padding: var(--space-2) var(--space-4);
  margin: 1em 0;
  background-color: var(--bg-elevated);
  color: var(--text-secondary);
}
.md-body blockquote p { margin: 0.25em 0; }

/* YAML Frontmatter */
.md-body .yaml-frontmatter {
  background: var(--bg-code);
  border-left: 3px solid var(--text-muted);
  padding: var(--space-3) var(--space-4);
  margin: 0 0 1em 0;
  font-size: 0.85em;
  font-family: monospace;
}
.md-body .fm-row {
  padding: 2px 0;
  line-height: 1.5;
}
.md-body .fm-key {
  color: var(--accent-primary);
  margin-right: 0.5em;
}
.md-body .fm-key::after { content: ':'; }
.md-body .fm-val {
  color: var(--text-secondary);
}
.md-body .fm-tag {
  display: inline-block;
  background: rgba(255,255,255,0.1);
  border: 1px solid var(--text-muted);
  border-radius: 12px;
  padding: 1px 10px;
  margin: 2px 4px 2px 0;
  font-size: 0.82em;
  color: var(--text-link);
}

/* Callout */
.md-body .callout {
  border-left: 3px solid;
  padding: var(--space-2) var(--space-4);
  margin: 1em 0;
}
.md-body .callout-title {
  font-weight: 700;
  margin-bottom: 0.25em;
  font-size: 0.95em;
}
.md-body .callout-body p { margin: 0.25em 0; }
.md-body .callout-blue  { border-color: #448aff; background: rgba(68,138,255,0.1); }
.md-body .callout-blue .callout-title { color: #448aff; }
.md-body .callout-teal  { border-color: #00bfa5; background: rgba(0,191,165,0.1); }
.md-body .callout-teal .callout-title { color: #00bfa5; }
.md-body .callout-green { border-color: #4caf50; background: rgba(76,175,80,0.1); }
.md-body .callout-green .callout-title { color: #4caf50; }
.md-body .callout-orange { border-color: #ff9100; background: rgba(255,145,0,0.1); }
.md-body .callout-orange .callout-title { color: #ff9100; }
.md-body .callout-red   { border-color: #ff5252; background: rgba(255,82,82,0.1); }
.md-body .callout-red .callout-title { color: #ff5252; }
.md-body .callout-purple { border-color: #b388ff; background: rgba(179,136,255,0.1); }
.md-body .callout-purple .callout-title { color: #b388ff; }
.md-body .callout-gray  { border-color: #9e9e9e; background: rgba(158,158,158,0.1); }
.md-body .callout-gray .callout-title { color: #9e9e9e; }

/* Horizontal Rule */
.md-body hr {
  border: none;
  border-top: var(--border-width) var(--border-style) var(--border-subtle);
  margin: 1.5em 0;
}

/* Table */
.md-body table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-sm);
  margin: 1em 0;
  display: block;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.md-body th,
.md-body td {
  padding: var(--space-2) var(--space-3);
  border: var(--border-width) var(--border-style) var(--border-default);
  text-align: left;
  white-space: nowrap;
}

.md-body th {
  background-color: var(--bg-elevated);
  color: var(--text-secondary);
  font-weight: var(--weight-medium);
  letter-spacing: var(--tracking-wide);
  font-size: var(--text-xs);
  text-transform: uppercase;
}

.md-body tr:nth-child(even) td { background-color: var(--bg-surface); }
.md-body tr:hover td           { background-color: var(--bg-hover); }

/* Images */
.md-body img {
  max-width: 100%;
  height: auto;
  display: block;
  border: var(--border-width) var(--border-style) var(--border-subtle);
}

/* Footnotes */
.md-body .footnotes {
  font-size: var(--text-xs);
  color: var(--text-muted);
  border-top: var(--border-width) var(--border-style) var(--border-subtle);
  margin-top: var(--space-8);
  padding-top: var(--space-4);
}

/* [[Obsidian internal link]] */
.md-body .internal-link {
  color: var(--accent-primary);
  text-decoration: none;
  border-bottom: 1px dashed var(--accent-primary);
}
.md-body .internal-link:hover {
  color: var(--accent-primary-hover);
  border-bottom-style: solid;
}

/* [[Unresolved link]] */
.md-body .internal-link--unresolved {
  color: var(--text-muted);
  border-bottom-color: var(--border-subtle);
}

/* Tags */
.md-body .tag {
  color: var(--accent-primary);
  font-size: var(--text-sm);
  text-decoration: none;
}
.md-body .tag:hover { color: var(--accent-primary-hover); }

/* ============================================================
   Light Theme
   ============================================================ */
[data-theme="light"] {
  --bg-base:        #F0F4F8;
  --bg-surface:     #FFFFFF;
  --bg-elevated:    #E8EDF2;
  --bg-overlay:     #FFFFFF;
  --bg-hover:       #DCE4EC;
  --bg-active:      #C8D5E0;
  --bg-input:       #FFFFFF;
  --bg-code:        #E8EDF2;

  --text-primary:   #1A2B3C;
  --text-secondary: #4A6274;
  --text-muted:     #8A9BAB;
  --text-inverse:   #FFFFFF;
  --text-link:      #4A8FA8;

  --accent-primary:       #5B9DB5;
  --accent-primary-hover: #4A8CA4;
  --accent-primary-muted: #D6EBF2;

  --color-success:        #3D9B5E;
  --color-success-muted:  #D6F0DF;
  --color-warning:        #C4920A;
  --color-warning-muted:  #FEF3CD;
  --color-error:          #CC3E3E;
  --color-error-muted:    #FCDEDE;
  --color-info:           #4A8FA8;
  --color-info-muted:     #D6EBF2;

  --border-subtle:  #DCE4EC;
  --border-default: #C8D5E0;
  --border-strong:  #A8B8C8;
  --border-accent:  #5B9DB5;

  --scrollbar-thumb: #C8D5E0;
}

/* ============================================================
   Lite Purple Theme
   ============================================================ */
[data-theme="lite-purple"] {
  --bg-base:        #54558c;
  --bg-surface:     #48497a;
  --bg-elevated:    #44457a;
  --bg-overlay:     #6A68A0;
  --bg-hover:       #6865A0;
  --bg-active:      #7875B0;
  --bg-input:       #4A4878;
  --bg-code:        #3e3f6e;

  --text-primary:   #F4F2FF;
  --text-secondary: #e8e6fa;
  --text-muted:     #c0bedb;
  --text-inverse:   #4A4878;
  --text-link:      #C8BBEF;

  --accent-primary:       #EAE070;
  --accent-primary-hover: #F0E890;
  --accent-primary-muted: #6A68A0;

  --color-success:        #7ADB8A;
  --color-success-muted:  #4A4878;
  --color-warning:        #EAE070;
  --color-warning-muted:  #5A5888;
  --color-error:          #F08888;
  --color-error-muted:    #5A3050;
  --color-info:           #88C0F0;
  --color-info-muted:     #4A4878;

  --border-subtle:  #6E6BA0;
  --border-default: #8885B0;
  --border-strong:  #A8A5C0;
  --border-accent:  #EAE070;

  --scrollbar-thumb: #8885B0;
}

/* ============================================================
   Light theme specific overrides
   ============================================================ */
[data-theme="light"] .global-spinner {
  background-color: rgba(240, 244, 248, 0.7);
}

[data-theme="light"] .dialog-backdrop {
  background-color: rgba(0, 0, 0, 0.3);
}

/* ============================================================
   Settings Panel
   ============================================================ */
.settings-panel {
  position: fixed;
  inset: 0;
  background-color: var(--bg-base);
  z-index: 160;
  display: flex;
  flex-direction: column;
}

.settings-panel__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: calc(56px + var(--bar-top-pad));
  padding: var(--bar-top-pad) var(--space-2) 0 var(--space-4);
  background-color: var(--bg-surface);
  border-bottom: var(--border-width) var(--border-style) var(--border-subtle);
  flex-shrink: 0;
}

.settings-panel__title {
  font-size: var(--text-md);
  font-weight: var(--weight-semibold);
  color: var(--text-primary);
}

.settings-panel__body {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-4) 0;
}

.settings-section {
  padding: 0 var(--space-4);
  margin-bottom: var(--space-6);
}

.settings-section__title {
  font-size: var(--text-xs);
  font-weight: var(--weight-medium);
  color: var(--text-muted);
  letter-spacing: var(--tracking-wide);
  text-transform: uppercase;
  margin-bottom: var(--space-3);
}

.settings-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-3) 0;
  border-bottom: var(--border-width) var(--border-style) var(--border-subtle);
  min-height: 48px;
}

.settings-item__label {
  font-size: var(--text-base);
  color: var(--text-primary);
}

.settings-item__desc {
  font-size: var(--text-xs);
  color: var(--text-muted);
  margin-top: var(--space-0-5);
}

/* Theme selector pills */
.theme-pills {
  display: flex;
  gap: var(--space-1);
}

.theme-pill {
  padding: var(--space-1-5) var(--space-3);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  font-family: var(--font-sans);
  color: var(--text-secondary);
  background-color: var(--bg-elevated);
  border: var(--border-width) var(--border-style) var(--border-default);
  border-radius: var(--radius-input);
  cursor: pointer;
  transition: all var(--transition-fast);
  -webkit-tap-highlight-color: transparent;
  min-height: 36px;
}

.theme-pill:hover {
  background-color: var(--bg-hover);
}

.theme-pill--active {
  background-color: var(--accent-primary);
  color: var(--text-inverse);
  border-color: var(--accent-primary);
}

/* Logout button in settings */
.settings-logout-btn {
  width: 100%;
  padding: var(--space-3);
  font-size: var(--text-base);
  font-weight: var(--weight-medium);
  font-family: var(--font-sans);
  color: var(--color-error);
  background-color: transparent;
  border: var(--border-width) var(--border-style) var(--color-error);
  border-radius: var(--radius-input);
  cursor: pointer;
  transition: all var(--transition-fast);
  min-height: 48px;
  -webkit-tap-highlight-color: transparent;
}

.settings-logout-btn:hover {
  background-color: var(--color-error-muted);
}

/* ============================================================
   New File Dialog
   ============================================================ */
.new-file-fab {
  position: fixed;
  bottom: calc(env(safe-area-inset-bottom, 0px) + var(--space-6));
  right: var(--space-4);
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background-color: var(--accent-primary);
  color: var(--text-inverse);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 8px rgba(0,0,0,0.3);
  z-index: 90;
  transition: background-color var(--transition-fast), transform var(--transition-fast);
  -webkit-tap-highlight-color: transparent;
}

.new-file-fab:hover {
  background-color: var(--accent-primary-hover);
  transform: scale(1.05);
}

.new-file-fab:active {
  transform: scale(0.95);
}

/* ============================================================
   Dataview
   ============================================================ */
.dataview-placeholder {
  margin: var(--space-4) 0;
}

.dataview-loading {
  color: var(--text-muted);
  font-size: var(--text-sm);
  padding: var(--space-3);
}

.dataview-error {
  color: var(--color-error);
  font-size: var(--text-sm);
  padding: var(--space-3);
  background: var(--color-error-muted);
  border-left: 3px solid var(--color-error);
}

.dataview-empty {
  color: var(--text-muted);
  font-size: var(--text-sm);
  font-style: italic;
  padding: var(--space-3);
}

.dataview-result {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.dataview-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-sm);
}

.dataview-table th {
  text-align: left;
  padding: var(--space-2) var(--space-3);
  color: var(--text-muted);
  font-weight: var(--weight-medium);
  font-size: var(--text-xs);
  border-bottom: 2px solid var(--border-default);
  white-space: nowrap;
}

.dataview-table td {
  padding: var(--space-3);
  border-bottom: var(--border-width) var(--border-style) var(--border-subtle);
  vertical-align: top;
}

.dataview-table td:first-child {
  white-space: nowrap;
}

.dataview-table .internal-link {
  color: var(--text-link);
  text-decoration: none;
}

.dataview-tag {
  display: inline-block;
  padding: var(--space-0-5) var(--space-2);
  margin: var(--space-0-5);
  font-size: var(--text-xs);
  color: var(--text-secondary);
  background: var(--bg-hover);
  border: var(--border-width) var(--border-style) var(--border-subtle);
}

.dataview-muted {
  color: var(--text-muted);
}

/* ============================================================
   Font Size Settings
   ============================================================ */
[data-fontsize="small"] {
  --text-2xs:  0.8125rem;
  --text-xs:   0.875rem;
  --text-sm:   0.9375rem;
  --text-base: 1.0625rem;
  --text-md:   1.1875rem;
  --text-lg:   1.3125rem;
  --text-xl:   1.4375rem;
  --text-2xl:  1.75rem;
  --text-3xl:  2.125rem;
}

[data-fontsize="large"] {
  --text-2xs:  1.0625rem;
  --text-xs:   1.125rem;
  --text-sm:   1.1875rem;
  --text-base: 1.3125rem;
  --text-md:   1.4375rem;
  --text-lg:   1.5625rem;
  --text-xl:   1.6875rem;
  --text-2xl:  2.125rem;
  --text-3xl:  2.625rem;
}

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

/* ============================================================
   Pro カード（設定パネル）＋ Paywall ダイアログ
   ============================================================ */

.pro-card {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  background-color: var(--accent-primary-muted);
  border: var(--border-width) var(--border-style) var(--accent-primary);
  border-radius: 0;
  color: var(--text-primary);
  text-align: left;
  cursor: pointer;
  font-family: inherit;
  transition: background-color var(--transition-base, 0.15s);
}

.pro-card:active {
  background-color: var(--bg-surface);
}

.pro-card__text {
  min-width: 0;
}

.pro-card__plan {
  font-size: var(--text-base);
  font-weight: var(--weight-semibold, 600);
  color: var(--accent-primary);
  line-height: var(--leading-snug, 1.4);
}

.pro-card__hint {
  font-size: var(--text-xs);
  color: var(--text-secondary);
  margin-top: 2px;
}

.pro-card__chevron {
  flex-shrink: 0;
  color: var(--accent-primary);
}

.paywall-table {
  border: var(--border-width) var(--border-style) var(--border-subtle);
  margin-bottom: var(--space-4);
}

.paywall-row {
  display: grid;
  grid-template-columns: 1fr 60px 76px;
  align-items: center;
  padding: var(--space-2) var(--space-3);
  border-bottom: var(--border-width) var(--border-style) var(--border-subtle);
  font-size: var(--text-sm);
  color: var(--text-primary);
}

.paywall-row:last-child {
  border-bottom: none;
}

.paywall-row span:nth-child(2),
.paywall-row span:nth-child(3) {
  text-align: center;
}

.paywall-row span:nth-child(2) {
  color: var(--text-secondary);
}

.paywall-row span:nth-child(3) {
  color: var(--color-success);
  font-weight: var(--weight-semibold, 600);
}

.paywall-row--head {
  background-color: var(--bg-surface);
  font-size: var(--text-xs);
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.paywall-row--head span:nth-child(2) {
  color: var(--text-secondary);
}

.paywall-row--head span:nth-child(3) {
  color: var(--accent-primary);
}

.paywall-buy {
  width: 100%;
}

.paywall-note {
  font-size: var(--text-xs);
  color: var(--text-secondary);
  text-align: center;
  line-height: var(--leading-snug, 1.4);
  margin-top: var(--space-2);
}

.paywall-legal {
  font-size: var(--text-xs);
  color: var(--text-muted);
  text-align: center;
  margin-top: var(--space-2);
}

.paywall-legal a {
  color: var(--text-muted);
  text-decoration: underline;
}

.settings-legal {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  padding: var(--space-2) 0;
}

.settings-legal a {
  font-size: var(--text-sm);
  color: var(--text-secondary);
  text-decoration: none;
}

.settings-legal a:hover {
  color: var(--text-link);
}

/* ============================================================
   Desktop: 600px フレーム（PCではモバイル幅に制限して中央寄せ）
   ============================================================ */
@media (min-width: 700px) {
  .screen {
    width: 100%;
    max-width: 600px;
    margin: 0 auto;
    border-left: var(--border-width) var(--border-style) var(--border-subtle);
    border-right: var(--border-width) var(--border-style) var(--border-subtle);
  }

  /* fixed 系オーバーレイも同じ 600px 枠に合わせる */
  .search-overlay,
  .settings-panel,
  .offline-banner {
    left: calc(50% - 300px);
    right: calc(50% - 300px);
  }

  .outline-drawer {
    right: calc(50% - 300px);
  }

  .toast-container {
    left: calc(50% - 300px + 16px);
    right: calc(50% - 300px + 16px);
  }

  .new-file-fab {
    right: calc(50% - 300px + 16px);
  }
}
