/* ===== CSS Variables & Theme ===== */
/* ax-malasada の base.css を踏襲。アクセントカラーのみ KONA 用の青系に変更。 */
:root {
  --accent: #0284c7;
  --accent-soft: rgba(2, 132, 199, 0.12);
  --bg: #f5f6f8;
  --surface: #ffffff;
  --surface-header: linear-gradient(180deg, #ffffff 0%, #f4f5f7 100%);
  --text: #1f2430;
  --text-sub: #6b7280;
  --border: #e4e6eb;
  --border-strong: #d1d5db;
  --status-active: #22c55e;
  --status-dev: #eab308;
  --status-plan: #9ca3af;
  --shadow: 0 1px 2px rgba(0,0,0,0.04);
  --shadow-hover: 0 6px 20px rgba(2, 132, 199, 0.14);
  --header-h: 60px;
  --sidebar-w: 260px;
}
[data-theme="dark"] {
  --bg: #0f1115;
  --surface: #1a1d25;
  --surface-header: linear-gradient(180deg, #1a1d25 0%, #161920 100%);
  --text: #e5e7eb;
  --text-sub: #9ca3af;
  --border: #2a2e38;
  --border-strong: #3a3f4c;
  --shadow: 0 1px 2px rgba(0,0,0,0.4);
  --shadow-hover: 0 6px 20px rgba(2, 132, 199, 0.22);
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  font-family: 'Noto Sans JP', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
}

/* ===== Auth Overlay ===== */
.auth-overlay {
  position: fixed; inset: 0;
  background: var(--bg);
  display: none;
  align-items: center; justify-content: center;
  z-index: 1000;
}
.auth-overlay.active { display: flex; }
.auth-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 40px 36px;
  width: min(92vw, 400px);
  text-align: center;
  box-shadow: 0 10px 40px rgba(0,0,0,0.08);
}
.auth-logo {
  display: flex; align-items: center; justify-content: center;
  gap: 14px;
  margin-bottom: 20px;
}
.auth-logo-emoji {
  font-size: 48px;
  line-height: 1;
  flex-shrink: 0;
}
.auth-logo-text {
  display: flex; flex-direction: column; align-items: flex-start;
  line-height: 1.1;
}
.auth-logo-main {
  font-size: 32px; font-weight: 700; letter-spacing: 1px;
  color: var(--text);
}
.auth-logo-sub {
  font-size: 11px; font-weight: 500;
  color: var(--text-sub);
  letter-spacing: 0.3px;
  margin-top: 4px;
}
.auth-msg { color: var(--text-sub); margin-bottom: 24px; }
.auth-btn {
  background: var(--accent); color: white; border: none;
  padding: 12px 28px; border-radius: 8px; font-weight: 600;
  cursor: pointer; font-size: 14px;
  transition: opacity 0.15s;
}
.auth-btn:hover { opacity: 0.9; }
.auth-err { color: #ef4444; margin-top: 12px; font-size: 13px; min-height: 1em; }

/* ===== Header ===== */
.header {
  position: fixed; top: 0; left: 0; right: 0; height: var(--header-h);
  background: var(--surface-header);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center;
  padding: 0 20px;
  z-index: 100;
  gap: 16px;
}
.hamburger {
  background: none; border: none; cursor: pointer;
  padding: 8px; border-radius: 8px;
  color: var(--text);
  display: flex; align-items: center; justify-content: center;
  transition: background 0.15s;
}
.hamburger:hover { background: var(--border); }
.hamburger svg { width: 22px; height: 22px; }
.logo {
  display: flex; align-items: center; gap: 10px;
  white-space: nowrap;
}
.logo-emoji {
  font-size: 30px;
  line-height: 1;
  flex-shrink: 0;
}
.logo-text {
  display: flex; flex-direction: column; align-items: flex-start;
  line-height: 1.1;
}
.logo-main {
  font-size: 20px; font-weight: 700;
  letter-spacing: 0.8px;
  color: var(--text);
}
.logo-sub {
  font-size: 10px; font-weight: 500;
  color: var(--text-sub);
  letter-spacing: 0.3px;
  margin-top: 2px;
}
.header-right {
  display: flex; align-items: center; gap: 12px;
  margin-left: auto;
}
.theme-toggle {
  background: none; border: 1px solid var(--border);
  cursor: pointer; padding: 6px;
  border-radius: 999px;
  width: 32px; height: 32px;
  display: flex; align-items: center; justify-content: center;
  color: var(--text);
  transition: border-color 0.15s;
}
.theme-toggle:hover { border-color: var(--accent); }
.theme-toggle .icon-dark,
.theme-toggle .icon-light { width: 16px; height: 16px; }
[data-theme="dark"] .theme-toggle .icon-light { display: none; }
[data-theme="light"] .theme-toggle .icon-dark,
:root:not([data-theme="dark"]) .theme-toggle .icon-dark { display: none; }
.user-email {
  font-size: 13px; color: var(--text-sub);
  white-space: nowrap;
  max-width: 180px; overflow: hidden; text-overflow: ellipsis;
}
.logout-btn {
  background: none; border: 1px solid var(--border);
  color: var(--text); cursor: pointer;
  padding: 6px 12px; border-radius: 8px;
  font-size: 12px; font-family: inherit;
  transition: all 0.15s;
}
.logout-btn:hover { border-color: var(--accent); color: var(--accent); }

/* ===== Sidebar ===== */
.sidebar {
  position: fixed; top: var(--header-h); left: 0; bottom: 0;
  width: var(--sidebar-w);
  background: var(--surface-header);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  transform: translateX(0);
  transition: transform 0.25s ease;
  z-index: 50;
  padding: 16px 0;
}
.sidebar.closed { transform: translateX(-100%); }
.nav-group { padding: 0 14px; margin-bottom: 4px; }
.nav-divider {
  height: 1px; background: var(--border);
  margin: 8px 14px;
}
.nav-item {
  display: flex; align-items: center;
  padding: 8px 12px;
  border-radius: 8px;
  color: var(--text);
  text-decoration: none;
  font-size: 13px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  font-weight: 500;
}
.nav-item[hidden] { display: none; }
.nav-item:hover { background: var(--accent-soft); color: var(--accent); }
.nav-item.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.nav-item.child {
  padding-left: 28px;
  font-size: 12.5px;
  font-weight: 400;
  color: var(--text-sub);
}
.nav-item.child:hover { color: var(--accent); }
.nav-item.child.active { color: var(--accent); font-weight: 600; }
.nav-parent {
  display: flex; align-items: center; justify-content: space-between;
  font-weight: 600;
}
.nav-parent .chevron {
  width: 16px; height: 16px;
  flex-shrink: 0;
  transition: transform 0.2s ease;
}
.nav-group.open > .nav-parent .chevron { transform: rotate(180deg); }
.nav-group:not(.open) > .nav-children { display: none; }
.nav-children { padding: 2px 0; }

/* ===== Main ===== */
.main {
  margin-left: var(--sidebar-w);
  padding: calc(var(--header-h) + 28px) 28px 40px;
  transition: margin-left 0.25s ease;
  min-height: 100vh;
}
.main.expanded { margin-left: 0; }

/* ===== Sidebar Overlay ===== */
.sidebar-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0, 0, 0, 0.4);
  z-index: 40;
}

/* ===== View ===== */
.view { display: none; }
.view.active { display: block; }

/* ===== Home ===== */
.home-inner {
  max-width: 800px;
  margin: 0 auto;
  padding: 20px 0 60px;
}
.home-hero {
  display: flex; align-items: center; gap: 24px;
  margin-bottom: 32px;
}
.home-logo-badge {
  width: 88px; height: 88px;
  /* コナちゃんアイコンは背景透過PNG。台座の水色ボックスを敷くと
     アイコンが切手のように浮いて見えるため、背景はページ地色に馴染ませる。 */
  background: transparent;
  display: flex; align-items: center; justify-content: center;
  font-size: 44px;
  flex-shrink: 0;
}
.home-greet { flex: 1; }
.home-greet-main {
  font-size: 24px; font-weight: 700;
  color: var(--text);
  margin-bottom: 8px;
  line-height: 1.3;
}
.home-greet-sub {
  font-size: 14px; color: var(--text-sub);
  line-height: 1.6;
}
.home-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
  margin-top: 8px;
}

/* ===== Cards ===== */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px 20px 18px;
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s, border-color 0.15s;
  position: relative;
  display: flex; flex-direction: column;
  min-height: 120px;
}
.card:hover {
  border-color: var(--accent);
  box-shadow: var(--shadow-hover);
  transform: translateY(-2px);
}
.card-icon {
  font-size: 28px;
  margin-bottom: 10px;
  line-height: 1;
}
.card-title {
  font-size: 15px; font-weight: 600;
  margin: 0 0 6px;
}
.card-desc {
  font-size: 12.5px; color: var(--text-sub);
  margin: 0;
  flex: 1;
  line-height: 1.6;
}
.card-foot {
  display: flex; align-items: center; justify-content: space-between;
  margin-top: 12px;
}
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 11px; font-weight: 600;
}
.badge::before {
  content: ''; width: 7px; height: 7px; border-radius: 50%;
}
.badge.active { background: rgba(34, 197, 94, 0.12); color: #16a34a; }
.badge.active::before { background: var(--status-active); }
[data-theme="dark"] .badge.active { color: #4ade80; }

/* ===== Common Buttons ===== */
.btn-primary {
  background: var(--accent); color: white;
  border: none; padding: 9px 18px;
  border-radius: 8px; font-weight: 600; font-size: 13px;
  cursor: pointer; font-family: inherit;
  transition: opacity 0.15s, transform 0.15s;
}
.btn-primary:hover:not(:disabled) { opacity: 0.9; transform: translateY(-1px); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-secondary {
  background: transparent; color: var(--text);
  border: 1px solid var(--border);
  padding: 9px 18px; border-radius: 8px;
  font-weight: 500; font-size: 13px;
  cursor: pointer; font-family: inherit;
  transition: border-color 0.15s, color 0.15s;
}
.btn-secondary:hover { border-color: var(--accent); color: var(--accent); }

/* ===== Responsive ===== */
@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
    box-shadow: 2px 0 20px rgba(0,0,0,0.15);
  }
  .sidebar.open { transform: translateX(0); }
  .sidebar-overlay.active { display: block; }
  .main { margin-left: 0; padding: calc(var(--header-h) + 20px) 16px 30px; }
  .user-email { display: none; }
  .logo-emoji { font-size: 24px; }
  .logo-main { font-size: 16px; }
  .logo-sub { font-size: 9px; }
  .home-hero { flex-direction: column; text-align: center; gap: 16px; }
  .home-greet-main { font-size: 20px; }
}
@media (max-width: 480px) {
  .logout-btn { padding: 6px 8px; font-size: 11px; }
  .header { gap: 10px; padding: 0 12px; }
}

/* ===== iOS 自動ズーム対策（ポキ/AI秘書 第8弾パターンの移植 2026-08-07） =====
   iOS Safari は font-size<16px の input/select/textarea にフォーカスすると
   画面を自動で拡大する。これを防ぐため、タッチ端末（スマホ幅）でのみ
   フォーム要素を 16px 以上に強制する。
   PC は業務ツールとしての情報密度を保つため既存サイズのまま。
   viewport 側でも maximum-scale=1.0 / user-scalable=no を設定している。 */
html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}
body {
  touch-action: manipulation; /* ダブルタップズームの抑止 */
}
@media (max-width: 768px) {
  input, select, textarea {
    font-size: 16px !important;
    max-width: 100%;
    box-sizing: border-box;
  }
}
