:root {
    --bg:        #F6F4EE;
    --bg-deep:   #EFECE3;
    --panel:     #FFFFFF;
    --panel-2:   #FAF8F3;
    --ink:       #1A1916;
    --ink-2:     #3D3A33;
    --muted:     #807A6E;
    --muted-2:   #A8A294;
    --line:      rgba(20,18,12,0.08);
    --line-2:    rgba(20,18,12,0.04);
    --accent:    oklch(0.55 0.13 155);
    --accent-soft: oklch(0.93 0.04 155);
    --accent-ink:  oklch(0.30 0.10 155);
    --danger:    oklch(0.58 0.20 25);
    --danger-soft: oklch(0.95 0.04 25);
    --warn:      oklch(0.74 0.15 75);
    --warn-soft: oklch(0.95 0.05 75);
    --info:      oklch(0.55 0.13 245);
    --info-soft: oklch(0.94 0.04 245);

    --radius: 10px;
    --radius-sm: 6px;
    --radius-lg: 16px;

    --shadow-sm: 0 1px 0 rgba(20,18,12,0.04), 0 1px 2px rgba(20,18,12,0.04);
    --shadow:    0 1px 0 rgba(20,18,12,0.04), 0 4px 14px rgba(20,18,12,0.06);

    --row-pad-y: 10px;
    --row-pad-x: 14px;
    --sidebar-w: 240px;

    --font-ui: "Plus Jakarta Sans", "Noto Sans JP", system-ui, sans-serif;
    --font-jp: "Noto Sans JP", "Plus Jakarta Sans", system-ui, sans-serif;
    --font-mono: "JetBrains Mono", ui-monospace, monospace;
    --font-display: "Instrument Serif", "Plus Jakarta Sans", serif;
  }

  /* Density variations */
  body[data-density="compact"] { --row-pad-y: 6px; --row-pad-x: 10px; }
  body[data-density="comfy"]   { --row-pad-y: 14px; --row-pad-x: 18px; }

  /* Sidebar width */
  body[data-sidebar="narrow"] { --sidebar-w: 200px; }
  body[data-sidebar="wide"]   { --sidebar-w: 280px; }

  /* Dark theme */
  body[data-theme="dark"] {
    --bg:        #0F0E0C;
    --bg-deep:   #07060B;
    --panel:     #16140F;
    --panel-2:   #1C1A14;
    --ink:       #F2EFE6;
    --ink-2:     #C7C2B5;
    --muted:     #8E8979;
    --muted-2:   #5B564B;
    --line:      rgba(246,241,224,0.08);
    --line-2:    rgba(246,241,224,0.04);
    --accent-soft: oklch(0.28 0.08 155);
    --accent-ink:  oklch(0.85 0.13 155);
    --danger-soft: oklch(0.28 0.10 25);
    --warn-soft:   oklch(0.28 0.08 75);
    --info-soft:   oklch(0.28 0.08 245);
  }

  /* Accent override hook */
  body[data-accent="emerald"] {
    --accent:      oklch(0.55 0.13 155);
    --accent-soft: oklch(0.93 0.04 155);
    --accent-ink:  oklch(0.30 0.10 155);
  }
  body[data-accent="cobalt"] {
    --accent:      oklch(0.50 0.18 255);
    --accent-soft: oklch(0.93 0.04 255);
    --accent-ink:  oklch(0.30 0.14 255);
  }
  body[data-accent="ember"] {
    --accent:      oklch(0.58 0.18 40);
    --accent-soft: oklch(0.94 0.04 40);
    --accent-ink:  oklch(0.32 0.12 40);
  }
  body[data-accent="violet"] {
    --accent:      oklch(0.50 0.17 295);
    --accent-soft: oklch(0.93 0.04 295);
    --accent-ink:  oklch(0.30 0.13 295);
  }
  body[data-theme="dark"][data-accent="emerald"] { --accent-soft: oklch(0.30 0.06 155); --accent-ink: oklch(0.86 0.13 155); }
  body[data-theme="dark"][data-accent="cobalt"]  { --accent-soft: oklch(0.28 0.10 255); --accent-ink: oklch(0.82 0.13 255); }
  body[data-theme="dark"][data-accent="ember"]   { --accent-soft: oklch(0.28 0.10 40);  --accent-ink: oklch(0.85 0.14 40);  }
  body[data-theme="dark"][data-accent="violet"]  { --accent-soft: oklch(0.28 0.10 295); --accent-ink: oklch(0.83 0.13 295); }

  * { box-sizing: border-box; }
  html, body { margin: 0; padding: 0; height: 100%; background: var(--bg); color: var(--ink); font-family: var(--font-jp); font-feature-settings: "palt"; -webkit-font-smoothing: antialiased; }

  ::selection { background: var(--accent); color: white; }

  /* shared classes */
  .num { font-family: var(--font-mono); font-variant-numeric: tabular-nums; letter-spacing: -0.01em; }
  .display { font-family: var(--font-display); font-weight: 400; letter-spacing: -0.01em; }
  .label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); font-weight: 600; }
  .hairline { border-bottom: 1px solid var(--line); }
  .panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); }

  button { font-family: inherit; cursor: pointer; }

  /* === FORM INPUTS (from form-library.html, library-aligned) === */
  /* テキスト入力 — 標準 (枠線は --line-3 で視認性を確保) */
  .mh-input {
    height: 36px;
    padding: 0 12px;
    background: var(--panel);
    border: 1px solid var(--muted-2);
    border-radius: 8px;
    color: var(--ink);
    font-size: 13px;
    font-family: var(--font-jp);
    transition: border-color 120ms, box-shadow 120ms;
    outline: none;
    width: 100%;
  }
  .mh-input::placeholder { color: var(--muted-2); }
  .mh-input:hover { border-color: var(--ink-2); }
  .mh-input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
  .mh-input:disabled { background: var(--panel-2); color: var(--muted); cursor: not-allowed; }
  .mh-input.error { border-color: var(--danger); }
  .mh-input.error:focus { box-shadow: 0 0 0 3px var(--danger-soft); }
  .mh-input.success { border-color: var(--accent); }

  /* サイズバリエーション */
  .mh-input.sm { height: 28px; font-size: 12px; padding: 0 10px; border-radius: 6px; }
  .mh-input.lg { height: 44px; font-size: 14px; padding: 0 14px; border-radius: 10px; }

  /* アイコン付き入力ラッパー */
  .mh-input-wrap { position: relative; }
  .mh-input-wrap > .icon-l { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--muted-2); pointer-events: none; }
  .mh-input-wrap > .icon-r { position: absolute; right: 11px; top: 50%; transform: translateY(-50%); color: var(--muted-2); }
  .mh-input-wrap > .mh-input.has-icon-l { padding-left: 34px; }
  .mh-input-wrap > .mh-input.has-icon-r { padding-right: 34px; }

  /* モノスペース入力 (ID等) */
  .mh-input.mono { font-family: var(--font-mono); letter-spacing: 0.02em; }

  /* テキストエリア */
  .mh-textarea {
    padding: 10px 12px;
    background: var(--panel);
    border: 1px solid var(--muted-2);
    border-radius: 8px;
    color: var(--ink);
    font-size: 13px;
    font-family: var(--font-jp);
    transition: border-color 120ms, box-shadow 120ms;
    outline: none;
    width: 100%;
    resize: vertical;
    line-height: 1.6;
  }
  .mh-textarea:hover { border-color: var(--ink-2); }
  .mh-textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

  /* ラベル / ヒント / エラー */
  .mh-flabel { display: block; font-size: 12px; font-weight: 600; color: var(--ink); margin-bottom: 6px; }
  .mh-fhint { font-size: 11px; color: var(--muted); margin-top: 6px; }
  .mh-ferror { font-size: 11px; color: var(--danger); margin-top: 6px; display: flex; align-items: center; gap: 4px; }
  .mh-fsuccess { font-size: 11px; color: var(--accent-ink); margin-top: 6px; display: flex; align-items: center; gap: 4px; }
  .mh-freq { color: var(--danger); margin-left: 2px; }
  input, textarea, select { font-family: inherit; color: inherit; }

  /* scrollbars */
  *::-webkit-scrollbar { width: 10px; height: 10px; }
  *::-webkit-scrollbar-thumb { background: var(--line); border-radius: 8px; border: 2px solid transparent; background-clip: padding-box; }
  *::-webkit-scrollbar-thumb:hover { background: var(--muted-2); background-clip: padding-box; border: 2px solid transparent; }

  /* App grid */
  .app { display: grid; grid-template-columns: var(--sidebar-w) 1fr; min-height: 100vh; }

  /* keyframes */
  @keyframes spin { to { transform: rotate(360deg); } }
  @keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.5; } }
  @keyframes pop { 0% { transform: scale(0.92); opacity: 0; } 100% { transform: scale(1); opacity: 1; } }
  @keyframes slide-up { 0% { transform: translateY(8px); opacity: 0; } 100% { transform: translateY(0); opacity: 1; } }
  @keyframes shimmer { 0% { background-position: -200px 0; } 100% { background-position: 200px 0; } }
  @keyframes flash { 0% { background: var(--accent-soft); } 100% { background: transparent; } }
  @keyframes radar {
    0%   { transform: scale(0.6); opacity: 0.6; }
    100% { transform: scale(2.4); opacity: 0; }
  }
  @keyframes blink { 0%,49% { opacity: 1; } 50%,100% { opacity: 0.15; } }

  .skeleton { background: linear-gradient(90deg, var(--line-2), var(--line), var(--line-2)); background-size: 400px 100%; animation: shimmer 1.4s linear infinite; border-radius: 4px; }

/* ============================================================
   MIHARI layout components (extracted from app.jsx inline styles)
   ============================================================ */

/* Sidebar */
.mhr-sidebar {
    background: var(--panel);
    border-right: 1px solid var(--line);
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}
.mhr-sidebar-brand { padding: 20px 18px 16px; border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 10px; }
.mhr-sidebar-brand .logo-mark { width: 32px; height: 32px; color: var(--accent); }
.mhr-sidebar-brand .wordmark { font-family: var(--font-display); font-style: italic; font-size: 22px; line-height: 1; color: var(--ink); }
.mhr-sidebar-brand .submark { font-family: var(--font-mono); font-size: 9px; letter-spacing: 0.18em; color: var(--muted); margin-top: 3px; }
.mhr-quick-add {
    margin: 14px;
    padding: 11px 14px;
    border: 1.5px dashed var(--accent);
    background: var(--accent-soft);
    color: var(--accent-ink);
    border-radius: var(--radius);
    font-weight: 600;
    font-size: 13px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
    transition: background 0.15s;
}
.mhr-quick-add:hover { background: color-mix(in oklch, var(--accent-soft), white 15%); }
.mhr-nav { padding: 8px 12px 14px; flex: 1; }
.mhr-nav .label { padding: 8px 6px; }
.mhr-nav-item {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    border-radius: 7px;
    border: 1px solid transparent;
    background: none;
    color: var(--ink-2);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.15s;
    text-decoration: none;
}
.mhr-nav-item:hover { background: var(--panel-2); }
.mhr-nav-item.active { background: var(--panel-2); border-color: var(--line); color: var(--ink); }
.mhr-nav-item.active .icon { color: var(--accent); }
.mhr-nav-item .icon { width: 18px; height: 18px; color: var(--muted); flex-shrink: 0; }
.mhr-nav-item.active .icon { color: var(--accent); }
.mhr-nav-item .count {
    margin-left: auto;
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--muted);
    background: var(--panel-2);
    padding: 1px 6px;
    border-radius: 8px;
}
.mhr-nav-item .live-dot { margin-left: auto; width: 6px; height: 6px; border-radius: 50%; background: var(--accent); animation: pulse 1.6s ease-in-out infinite; }
.mhr-sidebar-pill {
    margin: 12px 14px;
    padding: 10px 12px;
    background: var(--panel-2);
    border: 1px solid var(--line);
    border-radius: 9px;
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 12px;
}
.mhr-sidebar-pill .radar { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); position: relative; }
.mhr-sidebar-pill .radar::after { content: ''; position: absolute; inset: 0; border-radius: 50%; background: var(--accent); animation: radar 1.8s ease-out infinite; }
.mhr-sidebar-footer { border-top: 1px solid var(--line); padding: 10px 12px; }
.mhr-user-row {
    display: flex; align-items: center; gap: 10px;
    padding: 6px 8px; margin-top: 4px; border-radius: 7px;
}
.mhr-user-avatar {
    width: 28px; height: 28px; border-radius: 50%;
    background: linear-gradient(135deg, var(--accent), var(--accent-ink));
    color: white; font-size: 12px; font-weight: 700;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
}
.mhr-user-name { font-size: 12px; color: var(--ink); font-weight: 600; }
.mhr-user-plan { font-size: 11px; color: var(--muted); }

/* Topbar */
.mhr-topbar {
    height: 56px;
    position: sticky;
    top: 0;
    z-index: 5;
    background: color-mix(in oklch, var(--bg), transparent 20%);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--line);
    display: flex; align-items: center; gap: 14px;
    padding: 0 22px;
}
.mhr-search {
    flex: 1; max-width: 480px; height: 36px;
    background: var(--panel); border: 1px solid var(--line);
    border-radius: 8px;
    display: flex; align-items: center; gap: 8px;
    padding: 0 12px;
    font-size: 13px;
    color: var(--ink-2);
}
.mhr-search input {
    flex: 1; border: none; background: none; outline: none;
    font-size: 13px; color: var(--ink);
}
.mhr-divider-v { width: 1px; height: 18px; background: var(--line); }
.mhr-topbar-spacer { flex: 1; }
.mhr-icon-btn {
    width: 32px; height: 32px;
    border: 1px solid transparent;
    background: none;
    color: var(--muted);
    border-radius: 7px;
    display: inline-flex; align-items: center; justify-content: center;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
    position: relative;
}
.mhr-icon-btn:hover { background: var(--panel-2); color: var(--ink); border-color: var(--line); }
.mhr-icon-btn .badge-dot { position: absolute; top: 6px; right: 6px; width: 6px; height: 6px; border-radius: 50%; background: var(--danger); }

/* Guest layout (auth pages) */
.mhr-guest-bg {
    min-height: 100vh;
    background: var(--bg);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
}
.mhr-guest-card {
    max-width: 420px;
    width: 100%;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    padding: 36px 32px;
}
.mhr-guest-card .brand-row {
    display: flex; align-items: center; gap: 10px;
    margin-bottom: 28px;
}
.mhr-guest-card .brand-row .logo-mark { width: 28px; height: 28px; color: var(--accent); }
.mhr-guest-card .brand-row .wordmark { font-family: var(--font-display); font-style: italic; font-size: 24px; color: var(--ink); }
.mhr-guest-card h1 { font-size: 18px; font-weight: 600; color: var(--ink); margin: 0 0 24px; }
.mhr-form-group { margin-bottom: 18px; }
.mhr-form-label { display: block; font-size: 12px; font-weight: 600; color: var(--ink-2); margin-bottom: 6px; }
.mhr-input {
    width: 100%;
    padding: 10px 12px;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    font-size: 14px;
    color: var(--ink);
    outline: none;
    transition: border-color 0.15s;
}
.mhr-input:focus { border-color: var(--accent); }
.mhr-input.error { border-color: var(--danger); }
.mhr-form-error { color: var(--danger); font-size: 12px; margin-top: 4px; }
.mhr-form-actions { margin-top: 24px; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.mhr-link { color: var(--muted); font-size: 13px; text-decoration: none; }
.mhr-link:hover { color: var(--ink); }

/* Main content */
.mhr-main { overflow-x: hidden; }
.mhr-page { padding: 28px 32px; max-width: 1400px; margin: 0 auto; }
.mhr-page-wide { max-width: 1600px; }

/* ============================================================
   Table (mhr-table): 共通テーブル
   - 縞々 (奇数行 transparent / 偶数行 panel-2 = 薄ベージュ)
   - 行ホバーで accent-soft (薄緑) ハイライト
   - 今後新しいテーブルを作る場合は <table class="mhr-table"> を付けるだけでOK
   ============================================================ */
.mhr-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}
.mhr-table thead tr {
    background: var(--panel-2);
    text-align: left;
}
.mhr-table thead th {
    padding: 10px 12px;
    font-size: 11px;
    color: var(--muted);
    letter-spacing: 0.06em;
    text-transform: uppercase;
    font-weight: 600;
    border-bottom: 1px solid var(--line);
}
/* tbody 行: 縞々 + ホバー */
.mhr-table tbody tr {
    border-bottom: 1px solid var(--line-2);
    transition: background 100ms;
}
.mhr-table tbody tr:nth-child(even) { background: var(--panel-2); }
.mhr-table tbody tr:hover           { background: var(--accent-soft); }
.mhr-table tbody td { padding: 12px; }
