/* ============================================================
   会社のおまもり — デザインシステム
   コンセプト: 「会社を託せる信頼感」
   ダークグリーンの司令室 × エメラルドの生命感
   ============================================================ */

:root {
  /* ベース */
  --bg: #eef3f0;
  --bg-deep: #e4ece7;
  --surface: #ffffff;
  --surface-soft: #f4f8f6;
  --ink: #17211d;
  --muted: #5f7169;
  --line: #dde6e1;
  --line-strong: #c8d6cf;

  /* ブランド */
  --accent: #1e8a6e;
  --accent-strong: #12654f;
  --accent-bright: #2fbf94;
  --accent-soft: #e2f3ec;
  --accent-glow: rgba(30, 138, 110, 0.35);

  /* サイドバー(ダーク) */
  --side-bg-1: #0d1f1a;
  --side-bg-2: #14352c;
  --side-ink: #e8f2ed;
  --side-muted: #8fa89e;
  --side-line: rgba(255, 255, 255, 0.08);

  /* 状態色 */
  --amber: #b97400;
  --amber-soft: #fdf4e3;
  --rose: #b34a4a;
  --rose-soft: #fdf0f0;
  --blue: #3a6ecf;
  --blue-soft: #eef4ff;

  /* 影 */
  --shadow-sm: 0 1px 2px rgba(23, 33, 29, 0.05), 0 2px 8px rgba(23, 33, 29, 0.05);
  --shadow-md: 0 2px 4px rgba(23, 33, 29, 0.04), 0 12px 28px rgba(23, 33, 29, 0.09);
  --shadow-lg: 0 4px 10px rgba(23, 33, 29, 0.06), 0 24px 48px rgba(23, 33, 29, 0.14);
  --shadow-accent: 0 6px 18px var(--accent-glow);

  --radius: 14px;
  --radius-sm: 10px;

  /* モーション */
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);

  color-scheme: light;
}

/* ============================================================
   キーフレーム
   ============================================================ */

@keyframes view-enter {
  from {
    opacity: 0;
    transform: translateY(14px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes card-enter {
  from {
    opacity: 0;
    transform: translateY(10px) scale(0.99);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes bubble-pop {
  0% {
    opacity: 0;
    transform: translateY(10px) scale(0.96);
  }
  100% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes pulse-dot {
  0%,
  100% {
    box-shadow: 0 0 0 0 rgba(47, 191, 148, 0.55);
  }
  60% {
    box-shadow: 0 0 0 7px rgba(47, 191, 148, 0);
  }
}

@keyframes typing-bounce {
  0%,
  60%,
  100% {
    transform: translateY(0);
    opacity: 0.45;
  }
  30% {
    transform: translateY(-5px);
    opacity: 1;
  }
}

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

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

@keyframes shimmer {
  from {
    background-position: 200% 0;
  }
  to {
    background-position: -200% 0;
  }
}

/* ============================================================
   ベース
   ============================================================ */

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(1100px 500px at 85% -10%, rgba(47, 191, 148, 0.07), transparent 60%),
    linear-gradient(180deg, var(--bg) 0%, var(--bg-deep) 100%);
  background-attachment: fixed;
  color: var(--ink);
  font-family: "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Yu Gothic UI", "Yu Gothic",
    "Meiryo", system-ui, sans-serif;
  font-size: 16px;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

::selection {
  background: rgba(47, 191, 148, 0.28);
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

:focus-visible {
  outline: 3px solid var(--accent-glow);
  outline-offset: 2px;
  border-radius: 6px;
}

textarea,
input,
select {
  width: 100%;
  border: 1.5px solid var(--line);
  border-radius: var(--radius-sm);
  background: #fff;
  color: var(--ink);
  padding: 11px 13px;
  min-height: 44px;
  transition: border-color 0.18s ease, box-shadow 0.18s ease;
}

textarea:hover,
input:hover,
select:hover {
  border-color: var(--line-strong);
}

textarea:focus,
input:focus,
select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(30, 138, 110, 0.13);
}

textarea {
  resize: vertical;
}

label {
  display: grid;
  gap: 7px;
  color: var(--ink);
  font-weight: 700;
}

label small,
.muted {
  color: var(--muted);
  font-weight: 500;
}

/* ============================================================
   レイアウト
   ============================================================ */

.app-shell {
  display: grid;
  grid-template-columns: 288px minmax(0, 1fr);
  min-height: 100vh;
}

/* ---------- サイドバー(ダーク司令室) ---------- */

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 24px;
  background:
    radial-gradient(400px 260px at 20% -5%, rgba(47, 191, 148, 0.16), transparent 65%),
    linear-gradient(168deg, var(--side-bg-1) 0%, var(--side-bg-2) 100%);
  color: var(--side-ink);
  padding: 26px 18px 20px;
  overflow-y: auto;
}

.brand {
  display: flex;
  align-items: center;
  gap: 13px;
  min-width: 0;
  padding: 0 4px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border-radius: 14px;
  background: linear-gradient(140deg, var(--accent-bright) 0%, var(--accent-strong) 90%);
  color: #fff;
  font-size: 21px;
  font-weight: 800;
  flex: 0 0 auto;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.35),
    0 8px 18px rgba(0, 0, 0, 0.35);
}

.brand h1 {
  margin: 0;
  font-size: 18px;
  line-height: 1.25;
  letter-spacing: 0.02em;
  color: #fff;
}

.brand p {
  margin: 3px 0 0;
  color: var(--side-muted);
  font-size: 12.5px;
}

.nav-list {
  display: grid;
  gap: 4px;
}

.nav-button {
  display: flex;
  align-items: center;
  gap: 11px;
  min-height: 46px;
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: var(--side-muted);
  padding: 10px 13px;
  text-align: left;
  font-weight: 700;
  font-size: 15px;
  transition: background 0.18s ease, color 0.18s ease, transform 0.18s var(--ease-out);
}

.nav-icon {
  font-size: 17px;
  width: 24px;
  text-align: center;
  flex: 0 0 auto;
  filter: grayscale(0.25);
  transition: transform 0.25s var(--ease-spring), filter 0.18s ease;
}

.nav-label {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.nav-button:hover {
  background: rgba(255, 255, 255, 0.07);
  color: var(--side-ink);
}

.nav-button:hover .nav-icon {
  transform: translateY(-1px) scale(1.12);
  filter: grayscale(0);
}

.nav-button:active {
  transform: scale(0.98);
}

.nav-button.is-active {
  background: linear-gradient(120deg, rgba(47, 191, 148, 0.22), rgba(30, 138, 110, 0.14));
  color: #fff;
  box-shadow: inset 0 0 0 1px rgba(47, 191, 148, 0.35);
}

.nav-button.is-active .nav-icon {
  filter: grayscale(0);
}

.nav-count {
  min-width: 26px;
  border-radius: 999px;
  background: rgba(47, 191, 148, 0.2);
  color: #a9e8d3;
  padding: 1px 8px;
  text-align: center;
  font-size: 12px;
  font-weight: 800;
  transition: transform 0.25s var(--ease-spring);
}

.nav-step {
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: rgba(47, 191, 148, 0.16);
  color: #8ed9bf;
  font-size: 13px;
  font-weight: 800;
  box-shadow: inset 0 0 0 1.5px rgba(47, 191, 148, 0.4);
  transition: background 0.2s ease, color 0.2s ease, transform 0.25s var(--ease-spring);
}

.nav-button:hover .nav-step {
  transform: scale(1.1);
}

.nav-button.is-active .nav-step {
  background: var(--accent-bright);
  color: #072a20;
  box-shadow: none;
}

.nav-group-label {
  margin: 14px 6px 2px;
  color: var(--side-muted);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  opacity: 0.8;
}

.nav-button.is-sub {
  min-height: 40px;
  font-size: 13.5px;
  opacity: 0.85;
}

.nav-button.is-sub .nav-icon {
  font-size: 14px;
}

.nav-button.is-active .nav-count {
  background: var(--accent-bright);
  color: #072a20;
}

@keyframes update-glow {
  0%,
  100% {
    box-shadow: 0 0 0 0 rgba(255, 196, 87, 0.45), 0 4px 14px rgba(0, 0, 0, 0.3);
  }
  50% {
    box-shadow: 0 0 0 6px rgba(255, 196, 87, 0), 0 4px 14px rgba(0, 0, 0, 0.3);
  }
}

.update-banner {
  margin-top: auto;
  border: 1.5px solid rgba(255, 196, 87, 0.55);
  border-radius: var(--radius-sm);
  background: linear-gradient(135deg, rgba(255, 196, 87, 0.18), rgba(255, 160, 60, 0.1));
  color: #ffd489;
  padding: 12px 14px;
  font-weight: 800;
  font-size: 13.5px;
  text-align: left;
  cursor: pointer;
  animation: update-glow 2s ease-in-out infinite;
  transition: transform 0.2s var(--ease-out), background 0.2s ease;
}

.update-banner:hover {
  transform: translateY(-2px);
  background: linear-gradient(135deg, rgba(255, 196, 87, 0.3), rgba(255, 160, 60, 0.18));
}

.update-banner + .sidebar-note {
  margin-top: 12px;
}

.sidebar-note {
  margin-top: auto;
  border: 1px solid var(--side-line);
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.05);
  padding: 14px 15px;
  backdrop-filter: blur(4px);
}

.sidebar-note strong {
  color: var(--side-ink);
  font-size: 13px;
  letter-spacing: 0.04em;
}

.sidebar-note p {
  margin: 5px 0 0;
  color: var(--side-muted);
  font-size: 12.5px;
  line-height: 1.55;
  overflow-wrap: anywhere;
}

.sidebar-note #sidebar-ai-note {
  display: flex;
  align-items: center;
  gap: 7px;
}

.ai-dot {
  flex: 0 0 auto;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #6b7f78;
}

.sidebar-note.is-online .ai-dot {
  background: var(--accent-bright);
  animation: pulse-dot 2.2s ease-out infinite;
}

.sidebar-note.is-online #sidebar-ai-note {
  color: #a9e8d3;
  font-weight: 700;
}

/* ---------- メインパネル ---------- */

.main-panel {
  min-width: 0;
  padding: 22px clamp(18px, 4vw, 52px) 36px;
}

.view {
  max-width: 1180px;
  margin: 0 auto;
}

.view:not([hidden]) {
  animation: view-enter 0.42s var(--ease-out) both;
}

.page-head {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: flex-start;
  margin-bottom: 24px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.14em;
}

h2,
h3 {
  margin: 0;
  line-height: 1.35;
}

h2 {
  font-size: clamp(21px, 2.3vw, 26px);
  letter-spacing: 0.01em;
  font-weight: 800;
}

h3 {
  font-size: 18px;
  font-weight: 800;
}

.last-updated {
  align-self: center;
  color: var(--muted);
  font-size: 13.5px;
  font-weight: 700;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 14px;
  box-shadow: var(--shadow-sm);
}

/* ============================================================
   カード・帯
   ============================================================ */

.guide-band,
.pc-save-band,
.editor-band,
.panel-block,
.list-card,
.manual-card,
.question-card,
.detail-pane {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-md);
}

.guide-band {
  margin-bottom: 18px;
  padding: 18px 22px;
  border-left: 5px solid var(--accent);
  background: linear-gradient(120deg, #fdfffe 0%, var(--surface-soft) 100%);
}

.guide-band p {
  margin: 4px 0 0;
  color: var(--muted);
}

.pc-save-band {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  margin-bottom: 18px;
  padding: 17px 20px;
  border-left: 5px solid var(--blue);
  background: linear-gradient(120deg, #fdfeff 0%, var(--blue-soft) 100%);
}

.pc-save-band p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 14.5px;
}

.storage-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
  justify-content: flex-end;
}

.security-strip {
  margin-bottom: 18px;
  padding: 13px 17px;
  border: 1px solid #f0dfba;
  border-left: 5px solid var(--amber);
  border-radius: var(--radius-sm);
  background: var(--amber-soft);
  color: #6b4508;
  font-weight: 700;
  font-size: 14.5px;
}

/* ---------- ホーム: 今やること ---------- */

.next-action-band {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 20px;
  margin-bottom: 18px;
  padding: 22px 26px;
  border-radius: var(--radius);
  background:
    radial-gradient(500px 200px at 90% -20%, rgba(47, 191, 148, 0.25), transparent 65%),
    linear-gradient(135deg, var(--side-bg-2) 0%, var(--side-bg-1) 100%);
  color: #fff;
  box-shadow: var(--shadow-lg);
  animation: card-enter 0.45s var(--ease-out) both;
}

.next-action-copy {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.next-action-eyebrow {
  color: var(--accent-bright);
  font-size: 12.5px;
  font-weight: 800;
  letter-spacing: 0.1em;
}

.next-action-copy strong {
  font-size: clamp(18px, 2.2vw, 23px);
  line-height: 1.4;
}

.next-action-copy p {
  margin: 2px 0 0;
  color: rgba(232, 242, 237, 0.75);
  font-size: 14.5px;
}

.next-action-button {
  flex: 0 0 auto;
  min-height: 50px;
  padding: 12px 26px;
  font-size: 16px;
  border-radius: 999px;
  background: linear-gradient(140deg, var(--accent-bright) 0%, var(--accent) 100%);
  box-shadow: 0 6px 20px rgba(47, 191, 148, 0.45);
}

/* ---------- ホーム: 3ステップフロー ---------- */

.flow-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.flow-card {
  position: relative;
  display: grid;
  gap: 6px;
  align-content: start;
  border: 1.5px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 20px;
  text-align: left;
  box-shadow: var(--shadow-sm);
  transition: transform 0.22s var(--ease-out), box-shadow 0.22s var(--ease-out),
    border-color 0.22s ease;
  animation: card-enter 0.45s var(--ease-out) both;
}

.flow-card:nth-child(1) { animation-delay: 0.05s; }
.flow-card:nth-child(2) { animation-delay: 0.12s; }
.flow-card:nth-child(3) { animation-delay: 0.19s; }

.flow-card:hover {
  transform: translateY(-3px);
  border-color: var(--accent);
  box-shadow: var(--shadow-md);
}

.flow-card:not(:last-child)::after {
  content: "→";
  position: absolute;
  top: 50%;
  right: -15px;
  transform: translateY(-50%);
  z-index: 1;
  color: var(--accent);
  font-size: 17px;
  font-weight: 800;
}

.flow-step {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: linear-gradient(140deg, var(--accent-bright), var(--accent-strong));
  color: #fff;
  font-size: 16px;
  font-weight: 800;
  box-shadow: 0 4px 10px var(--accent-glow);
}

.flow-card strong {
  font-size: 17px;
}

.flow-card p {
  margin: 0;
  color: var(--muted);
  font-size: 13.5px;
  line-height: 1.55;
}

.flow-count {
  display: flex;
  align-items: baseline;
  gap: 5px;
  margin-top: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.flow-count em {
  color: var(--accent-strong);
  font-size: 26px;
  font-style: normal;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.flow-count.is-go {
  color: var(--accent-strong);
  font-size: 14.5px;
  margin-top: 12px;
}

/* ---------- ダッシュボード ---------- */

.stat-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.stat-card {
  position: relative;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 18px;
  box-shadow: var(--shadow-sm);
  transition: transform 0.25s var(--ease-out), box-shadow 0.25s var(--ease-out);
  animation: card-enter 0.45s var(--ease-out) both;
}

.stat-card::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 4px;
  background: linear-gradient(180deg, var(--accent-bright), var(--accent-strong));
  opacity: 0;
  transition: opacity 0.25s ease;
}

.stat-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-md);
}

.stat-card:hover::before {
  opacity: 1;
}

.stat-card:nth-child(1) { animation-delay: 0.02s; }
.stat-card:nth-child(2) { animation-delay: 0.07s; }
.stat-card:nth-child(3) { animation-delay: 0.12s; }
.stat-card:nth-child(4) { animation-delay: 0.17s; }
.stat-card:nth-child(5) { animation-delay: 0.22s; }
.stat-card:nth-child(6) { animation-delay: 0.27s; }

.stat-card span {
  color: var(--muted);
  font-size: 13.5px;
  font-weight: 700;
}

.stat-card strong {
  display: block;
  margin-top: 4px;
  color: var(--accent-strong);
  font-size: 32px;
  line-height: 1.15;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.dashboard-columns,
.split-panel,
.memo-create-layout,
.backup-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.memo-create-layout {
  grid-template-columns: minmax(0, 1.35fr) minmax(320px, 0.65fr);
  align-items: start;
}

.backup-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.panel-block {
  padding: 20px;
}

.panel-block h3 {
  margin-bottom: 12px;
}

.panel-block.wide {
  grid-column: 1 / -1;
}

.simple-list {
  display: grid;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.simple-list li {
  display: flex;
  gap: 9px;
  align-items: flex-start;
}

.big-number {
  margin: 8px 0 4px;
  color: var(--accent-strong);
  font-size: 34px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

/* ============================================================
   チャット(メモを作成)
   ============================================================ */

/* AIと話す: 画面の高さにピッタリ収め、ページスクロールを無くす。
   スクロールするのは会話ログだけで、入力欄は常に画面内に見える */
#view-memo-create:not([hidden]) {
  display: flex;
  flex-direction: column;
  height: calc(100vh - 58px); /* main-panelの上下余白ぶん */
  min-height: 460px;
}

.chat-panel,
.memo-draft-panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-md);
  padding: 18px;
}

.chat-panel {
  display: flex;
  flex-direction: column;
  min-height: 0;
}

#view-memo-create .chat-panel {
  flex: 1;
  width: 100%;
  max-width: 940px;
  margin: 0 auto;
}

.chat-toolbar {
  display: flex;
  align-items: center;
  gap: 9px;
  padding-bottom: 10px;
  margin-bottom: 4px;
  border-bottom: 1px solid var(--line);
}

.chat-title {
  font-size: 16px;
  font-weight: 800;
  white-space: nowrap;
}

.chat-mode {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-toolbar-spacer {
  flex: 1;
}

/* 回答が十分たまったら「押しどき」をやわらかく知らせる */
@keyframes ready-glow {
  0%,
  100% {
    box-shadow: 0 0 0 0 rgba(47, 191, 148, 0.55), 0 3px 10px var(--accent-glow);
  }
  50% {
    box-shadow: 0 0 0 8px rgba(47, 191, 148, 0), 0 3px 10px var(--accent-glow);
  }
}

#memo-create-finalize-button.is-ready {
  animation: ready-glow 2s ease-out infinite;
}

.chat-toolbar-hint {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.chat-reset-button {
  min-height: 38px;
  padding: 6px 13px;
  font-size: 13px;
  color: var(--muted);
  border-color: transparent;
}

.chat-reset-button:hover:not(:disabled) {
  color: var(--rose);
  background: var(--rose-soft);
}

.chat-log {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: flex-start;
  gap: 4px;
  flex: 1 1 auto;
  min-height: 160px;
  overflow-y: auto;
  padding: 8px 6px 16px;
  scrollbar-width: thin;
  scrollbar-color: var(--line-strong) transparent;
}

.chat-log::-webkit-scrollbar {
  width: 8px;
}

.chat-log::-webkit-scrollbar-thumb {
  background: var(--line-strong);
  border-radius: 999px;
}

/* LINE風: 1発言 = 1行(アバター + 吹き出し + 時刻) */
.chat-row {
  display: flex;
  gap: 9px;
  margin-bottom: 10px;
}

.chat-row-user {
  justify-content: flex-end;
}

.chat-avatar {
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: linear-gradient(140deg, var(--accent-bright), var(--accent-strong));
  color: #fff;
  font-size: 11px;
  font-weight: 800;
  box-shadow: var(--shadow-sm);
}

.chat-col {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  max-width: min(78%, 640px);
  min-width: 0;
}

.chat-row-user .chat-col {
  align-items: flex-end;
}

.chat-message {
  width: fit-content;
  max-width: 100%;
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 10px 15px;
  box-shadow: var(--shadow-sm);
}

.chat-row:last-child .chat-message,
.chat-row:last-child .chat-typing {
  animation: bubble-pop 0.35s var(--ease-spring) both;
}

.chat-message p {
  margin: 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.chat-user {
  background: linear-gradient(135deg, #d9f3e8 0%, #c8ecdc 100%);
  border-color: #aeddca;
  border-bottom-right-radius: 6px;
}

.chat-assistant {
  background: #fff;
  border-bottom-left-radius: 6px;
}

.chat-meta {
  margin: 4px 6px 0;
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
}

/* AIが考えている間のタイピングドット */
.chat-typing {
  display: inline-flex;
  gap: 5px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 18px;
  border-bottom-left-radius: 6px;
  background: #fff;
  padding: 14px 18px;
  box-shadow: var(--shadow-sm);
}

.typing-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  animation: typing-bounce 1.2s ease-in-out infinite;
}

.typing-dot:nth-child(2) {
  animation-delay: 0.15s;
}

.typing-dot:nth-child(3) {
  animation-delay: 0.3s;
}

.quick-prompts {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 9px 0;
}

.quick-prompts .ghost-button {
  min-height: 36px;
  border-radius: 999px;
  padding: 5px 15px;
  font-size: 13.5px;
  background: var(--surface-soft);
  border-color: var(--line);
}

.quick-prompts .ghost-button:hover {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent-strong);
  transform: translateY(-1px);
}

.chat-input-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 46px;
  gap: 9px;
  align-items: end;
}

.chat-input-row textarea {
  border-radius: 22px;
  padding: 11px 17px;
  min-height: 46px;
  max-height: 150px;
  resize: none;
  line-height: 1.55;
}

.chat-send-button {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  min-height: 46px;
  padding: 0;
  border-radius: 50%;
  font-size: 17px;
  line-height: 1;
}

.chat-send-button.is-busy::before {
  margin-right: 0;
}

.chat-hint {
  margin: 6px 4px 0;
  color: var(--muted);
  font-size: 11.5px;
}

.memo-draft-panel {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 0;
  overflow-y: auto;
}

.memo-draft-panel h3,
.memo-draft-panel p {
  margin: 0;
}

#memo-create-draft {
  flex: 1 1 auto;
  min-height: 100px;
}

.subscription-note {
  border: 1px solid #cfdff5;
  border-radius: var(--radius-sm);
  background: var(--blue-soft);
  padding: 13px 14px;
  font-size: 14px;
}

.subscription-note p {
  margin: 4px 0 0;
  color: var(--muted);
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ============================================================
   フォーム・ボタン
   ============================================================ */

.input-stack {
  display: grid;
  gap: 12px;
  margin-bottom: 18px;
}

.action-row,
.card-actions,
.toolbar,
.question-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.toolbar {
  margin-bottom: 16px;
  align-items: flex-end; /* ラベル付きの選択ボックスとボタンの下端を揃える */
}

.toolbar button {
  min-height: 44px;
}

.toolbar label,
.question-controls label {
  min-width: 180px;
}

.primary-button,
.secondary-button,
.ghost-button,
.danger-button,
.file-button {
  position: relative;
  min-height: 42px;
  border-radius: var(--radius-sm);
  border: 1.5px solid transparent;
  padding: 9px 16px;
  font-weight: 800;
  text-decoration: none;
  transition:
    transform 0.18s var(--ease-out),
    box-shadow 0.22s var(--ease-out),
    background 0.18s ease,
    border-color 0.18s ease,
    color 0.18s ease;
}

.primary-button:active,
.secondary-button:active,
.ghost-button:active,
.danger-button:active {
  transform: scale(0.97);
}

.primary-button {
  background: linear-gradient(140deg, var(--accent) 0%, var(--accent-strong) 100%);
  color: #fff;
  box-shadow: 0 3px 10px var(--accent-glow), inset 0 1px 0 rgba(255, 255, 255, 0.22);
}

.primary-button:hover:not(:disabled) {
  transform: translateY(-1.5px);
  box-shadow: 0 7px 18px var(--accent-glow), inset 0 1px 0 rgba(255, 255, 255, 0.22);
}

.secondary-button,
.file-button {
  background: var(--accent-soft);
  border-color: #bfe0d4;
  color: var(--accent-strong);
}

.secondary-button:hover:not(:disabled),
.file-button:hover {
  background: #d3ecdf;
  border-color: var(--accent);
  transform: translateY(-1px);
}

.ghost-button {
  background: #fff;
  border-color: var(--line);
  color: var(--ink);
}

.ghost-button:hover:not(:disabled) {
  border-color: var(--line-strong);
  background: var(--surface-soft);
}

.danger-button {
  background: #fff;
  border-color: #eccece;
  color: var(--rose);
}

.danger-button:hover:not(:disabled) {
  background: var(--rose-soft);
  border-color: var(--rose);
}

.file-button {
  display: inline-grid;
  place-items: center;
  width: fit-content;
  cursor: pointer;
}

.file-button input {
  position: absolute;
  inline-size: 1px;
  block-size: 1px;
  opacity: 0;
  pointer-events: none;
}

.finalize-button {
  width: 100%;
  min-height: 52px;
  font-size: 16px;
}

.update-badge {
  display: inline-block;
  margin-left: 8px;
  border-radius: 999px;
  background: var(--blue-soft);
  color: var(--blue);
  border: 1px solid #d3e1f8;
  padding: 1px 9px;
  font-size: 11.5px;
  font-weight: 800;
  vertical-align: 2px;
  white-space: nowrap;
}

/* AI実行中のスピナー */
.is-busy {
  pointer-events: none;
}

.is-busy::before {
  content: "";
  display: inline-block;
  width: 14px;
  height: 14px;
  margin-right: 9px;
  vertical-align: -2px;
  border-radius: 50%;
  border: 2.5px solid rgba(255, 255, 255, 0.35);
  border-top-color: #fff;
  animation: spin 0.7s linear infinite;
}

/* ============================================================
   カードリスト(メモ・マニュアル・質問)
   ============================================================ */

.card-list {
  display: grid;
  gap: 14px;
  margin-top: 18px;
}

.card-list > * {
  animation: card-enter 0.4s var(--ease-out) both;
}

.card-list > *:nth-child(1) { animation-delay: 0.02s; }
.card-list > *:nth-child(2) { animation-delay: 0.06s; }
.card-list > *:nth-child(3) { animation-delay: 0.1s; }
.card-list > *:nth-child(4) { animation-delay: 0.14s; }
.card-list > *:nth-child(5) { animation-delay: 0.18s; }

.list-card,
.manual-card,
.question-card {
  padding: 18px;
  transition: transform 0.22s var(--ease-out), box-shadow 0.22s var(--ease-out),
    border-color 0.22s ease;
}

.list-card {
  cursor: pointer;
}

.manual-card:hover,
.question-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

.list-card.is-selected {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(30, 138, 110, 0.14), var(--shadow-md);
}

.card-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
  margin-bottom: 12px;
}

.card-head div {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.card-head strong {
  overflow-wrap: anywhere;
  font-size: 17px;
}

.card-head span {
  color: var(--muted);
  font-size: 13.5px;
}

.inline-editor {
  min-height: 130px;
  margin-bottom: 12px;
}

.autosave-hint {
  margin: -4px 0 12px;
  color: var(--muted);
  font-size: 12.5px;
  font-weight: 700;
}

/* ---------- ピル(状態・重要度) ---------- */

.pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  width: fit-content;
  min-height: 26px;
  border-radius: 999px;
  padding: 2px 11px;
  font-size: 12.5px;
  font-weight: 800;
  white-space: nowrap;
}

.pill::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.7;
}

.status-unprocessed,
.importance-high {
  background: var(--amber-soft);
  color: #8a5500;
  border: 1px solid #efdcae;
}

.status-processed,
.importance-medium {
  background: var(--blue-soft);
  color: var(--blue);
  border: 1px solid #d3e1f8;
}

.status-saved,
.importance-low {
  background: var(--accent-soft);
  color: var(--accent-strong);
  border: 1px solid #c4e5d8;
}

/* ============================================================
   AI整理結果
   ============================================================ */

.two-column {
  display: grid;
  grid-template-columns: 310px minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}

.result-list {
  display: grid;
  gap: 10px;
}

.result-row {
  display: grid;
  gap: 3px;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  padding: 14px;
  text-align: left;
  box-shadow: var(--shadow-sm);
  transition: transform 0.2s var(--ease-out), box-shadow 0.2s var(--ease-out),
    border-color 0.2s ease;
}

.result-row:hover {
  transform: translateX(3px);
  border-color: var(--line-strong);
}

.result-row.is-selected {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(30, 138, 110, 0.14), var(--shadow-sm);
  transform: translateX(3px);
}

.result-row span {
  font-weight: 800;
}

.result-row small {
  color: var(--muted);
}

.result-row em {
  width: fit-content;
  color: var(--accent-strong);
  font-size: 12px;
  font-style: normal;
  font-weight: 800;
}

.detail-pane {
  padding: 20px;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.summary-grid div {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  background: var(--surface-soft);
}

.summary-grid span {
  display: block;
  color: var(--muted);
  font-size: 12.5px;
  font-weight: 800;
}

.summary-grid strong {
  overflow-wrap: anywhere;
}

.compact-list {
  display: grid;
  gap: 10px;
  margin: 12px 0 20px;
}

.compact-list article {
  border: 1px solid var(--line);
  border-left: 4px solid var(--accent);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  background: var(--surface-soft);
  padding: 11px 14px;
}

.compact-list div {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: baseline;
}

.compact-list span {
  color: var(--muted);
  font-size: 13px;
}

.compact-list p {
  margin: 7px 0 0;
}

.json-editor {
  display: grid;
  gap: 8px;
  margin-top: 16px;
}

.json-editor textarea {
  font-family: "Consolas", "BIZ UDGothic", monospace;
  font-size: 13.5px;
  background: #fbfdfc;
}

/* ============================================================
   マニュアル編集
   ============================================================ */

.editor-band {
  margin-bottom: 18px;
  padding: 20px;
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(30, 138, 110, 0.09), var(--shadow-md);
  animation: card-enter 0.35s var(--ease-out) both;
}

.editor-band h3 {
  margin-bottom: 14px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.full-span {
  grid-column: 1 / -1;
}

.manual-card p,
.question-card p {
  margin: 0 0 12px;
  white-space: pre-wrap;
}

.meta-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin: 14px 0;
}

.meta-row div {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  background: var(--surface-soft);
}

.meta-row dt {
  color: var(--muted);
  font-size: 11.5px;
  font-weight: 800;
  letter-spacing: 0.03em;
}

.meta-row dd {
  margin: 0;
  overflow-wrap: anywhere;
  font-weight: 700;
}

/* ============================================================
   設定
   ============================================================ */

.settings-list {
  display: grid;
  gap: 12px;
  margin-bottom: 18px;
}

.setting-option {
  display: flex;
  align-items: flex-start;
  gap: 13px;
  border: 1.5px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 16px 18px;
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  transition: border-color 0.2s ease, box-shadow 0.2s ease, transform 0.2s var(--ease-out);
}

.setting-option:hover {
  border-color: var(--line-strong);
  transform: translateY(-1px);
}

.setting-option:has(input:checked) {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(30, 138, 110, 0.12), var(--shadow-sm);
  background: linear-gradient(120deg, #fff 0%, var(--accent-soft) 130%);
}

.setting-option input {
  width: 20px;
  min-height: 20px;
  margin-top: 4px;
  accent-color: var(--accent);
}

.setting-option span {
  display: grid;
  gap: 2px;
}

.setting-option.is-disabled {
  opacity: 0.72;
}

/* 上級者向け・補助機能の折りたたみ */
.advanced-details {
  margin: 16px 0;
  border: 1.5px dashed var(--line-strong);
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.55);
}

.advanced-details summary {
  cursor: pointer;
  padding: 12px 16px;
  color: var(--muted);
  font-weight: 700;
  font-size: 13.5px;
  user-select: none;
  transition: color 0.18s ease;
}

.advanced-details summary:hover {
  color: var(--ink);
}

.advanced-details[open] summary {
  border-bottom: 1px dashed var(--line);
}

.advanced-body {
  display: grid;
  gap: 12px;
  padding: 14px 16px 16px;
}

.phone-block {
  margin-bottom: 18px;
}

.qr-box {
  display: grid;
  place-items: center;
  width: fit-content;
  margin: 14px auto;
  padding: 14px;
  border-radius: var(--radius);
  background: #fff;
  border: 1px solid var(--line);
  box-shadow: var(--shadow-md);
}

.qr-fallback {
  font-size: 13px;
  overflow-wrap: anywhere;
}

.license-block {
  margin-bottom: 18px;
}

.license-status {
  margin-bottom: 12px;
}

.license-status p {
  margin: 0 0 10px;
}

.license-ok {
  border: 1px solid #c4e5d8;
  border-radius: var(--radius-sm);
  background: var(--accent-soft);
  color: var(--accent-strong);
  padding: 12px 15px;
  font-weight: 700;
}

.license-free {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface-soft);
  color: var(--muted);
  padding: 12px 15px;
}

#license-key-input {
  font-family: "Consolas", "BIZ UDGothic", monospace;
  font-size: 12.5px;
  overflow-wrap: anywhere;
}

/* ============================================================
   その他
   ============================================================ */

.empty-state {
  border: 1.5px dashed var(--line-strong);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.6);
  color: var(--muted);
  padding: 26px 18px;
  text-align: center;
  font-weight: 600;
}

.toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 20;
  max-width: min(440px, calc(100vw - 44px));
  border-radius: var(--radius-sm);
  background: var(--ink);
  color: #fff;
  padding: 13px 17px;
  font-weight: 700;
  font-size: 14.5px;
  box-shadow: var(--shadow-lg);
  opacity: 0;
  transform: translateY(16px) scale(0.96);
  pointer-events: none;
}

.toast.is-visible {
  opacity: 1;
  transform: translateY(0) scale(1);
  animation: toast-in 0.4s var(--ease-spring) both;
}

.toast.success {
  background: linear-gradient(140deg, var(--accent) 0%, var(--accent-strong) 100%);
}

.toast.warn {
  background: linear-gradient(140deg, #c98410 0%, var(--amber) 100%);
}

.toast.error {
  background: linear-gradient(140deg, #c25b5b 0%, var(--rose) 100%);
}

/* ============================================================
   モーション低減設定の尊重
   ============================================================ */

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

  html {
    scroll-behavior: auto;
  }
}

/* ============================================================
   レスポンシブ
   ============================================================ */

@media (max-width: 980px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
  }

  .nav-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .dashboard-columns,
  .split-panel,
  .backup-grid,
  .memo-create-layout,
  .two-column,
  .stat-grid,
  .flow-grid {
    grid-template-columns: 1fr;
  }

  /* 縦積みになる幅では、画面フィットをやめて通常スクロールに戻す */
  #view-memo-create:not([hidden]) {
    height: auto;
    min-height: 0;
  }

  .chat-log {
    flex: 0 0 auto;
    height: min(58vh, 520px);
  }

  .memo-draft-panel {
    overflow-y: visible;
  }

  .flow-card:not(:last-child)::after {
    content: "↓";
    top: auto;
    right: 50%;
    bottom: -16px;
    transform: translateX(50%);
  }

  .next-action-band {
    flex-direction: column;
    align-items: stretch;
    text-align: left;
  }
}

@media (max-width: 640px) {
  .main-panel {
    padding: 20px 14px 40px;
  }

  .page-head,
  .card-head,
  .compact-list div,
  .pc-save-band {
    display: grid;
  }

  .last-updated {
    justify-self: start;
  }

  .nav-list,
  .form-grid,
  .chat-input-row,
  .summary-grid,
  .meta-row {
    grid-template-columns: 1fr;
  }

  .chat-message {
    width: 100%;
  }

  .action-row button,
  .card-actions button,
  .toolbar label,
  .toolbar button,
  .file-button,
  .storage-actions button {
    width: 100%;
  }
}

@media print {
  body {
    background: #fff;
  }

  .sidebar,
  .toolbar,
  .action-row,
  .toast,
  .json-editor,
  .security-strip {
    display: none !important;
  }

  .app-shell {
    display: block;
  }

  .main-panel {
    padding: 0;
  }

  .manual-card,
  .panel-block {
    box-shadow: none;
    break-inside: avoid;
  }
}

/* ============================================================
   クラウド版: ログイン画面
   ============================================================ */

.auth-overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  background:
    radial-gradient(700px 400px at 80% -10%, rgba(47, 191, 148, 0.15), transparent 60%),
    linear-gradient(168deg, var(--side-bg-1) 0%, var(--side-bg-2) 100%);
  padding: 20px;
}

.auth-overlay[hidden] {
  display: none;
}

.auth-card {
  width: 100%;
  max-width: 420px;
  background: var(--surface);
  border-radius: 18px;
  box-shadow: var(--shadow-lg);
  padding: 28px;
  animation: card-enter 0.4s var(--ease-out) both;
}

.auth-brand {
  display: flex;
  gap: 13px;
  align-items: center;
  margin-bottom: 22px;
}

.auth-brand h1 {
  margin: 0;
  font-size: 20px;
}

.auth-brand p {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 12.5px;
}

.auth-form {
  display: grid;
  gap: 14px;
}

.auth-form[hidden] {
  display: none;
}

.auth-submit {
  min-height: 48px;
  font-size: 16px;
}

.auth-switch {
  margin: 2px 0 0;
  text-align: center;
  color: var(--muted);
  font-size: 13.5px;
}

.auth-switch a {
  color: var(--accent-strong);
  font-weight: 700;
}

.auth-error {
  margin: 12px 0 0;
  color: var(--rose);
  font-weight: 700;
  text-align: center;
  font-size: 14px;
}

.logout-button {
  margin-top: 10px;
  min-height: 34px;
  padding: 4px 10px;
  font-size: 12.5px;
  color: var(--side-muted);
  border-color: rgba(255, 255, 255, 0.15);
  background: transparent;
}

.logout-button:hover:not(:disabled) {
  color: #fff;
  background: rgba(255, 255, 255, 0.08);
}

.plan-status {
  margin: 0 0 8px;
  font-weight: 800;
}

.plan-active {
  color: var(--accent-strong);
}

.optin-row {
  display: flex;
  align-items: center;
  gap: 9px;
  font-weight: 700;
  font-size: 14.5px;
  cursor: pointer;
}

.optin-row input {
  width: 18px;
  min-height: 18px;
  accent-color: var(--accent);
}

.snapshot-list {
  list-style: none;
  margin: 10px 0 0;
  padding: 0;
  display: grid;
  gap: 8px;
}

.snapshot-list li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface-soft);
  padding: 8px 12px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.snapshot-dl {
  min-height: 34px;
  padding: 4px 12px;
  font-size: 13px;
  text-decoration: none;
  display: inline-grid;
  place-items: center;
}

.usage-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
  margin: 8px 0;
}

.usage-table th,
.usage-table td {
  text-align: left;
  padding: 7px 9px;
  border-bottom: 1px solid var(--line);
  font-variant-numeric: tabular-nums;
}

.usage-table th {
  color: var(--muted);
  font-size: 12px;
}

.usage-total {
  margin: 8px 0 0;
  font-weight: 800;
  color: var(--accent-strong);
}

.auth-legal {
  margin: 16px 0 0;
  text-align: center;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.7;
}

.auth-legal a {
  color: var(--accent-strong);
  font-weight: 700;
}

.personal-doc {
  margin-top: 14px;
}

.personal-doc h4 {
  margin: 0 0 8px;
  font-size: 15px;
  color: var(--accent-strong);
}

.personal-doc-body {
  white-space: pre-wrap;
  border: 1px solid var(--line);
  border-left: 4px solid var(--accent);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  background: var(--surface-soft);
  padding: 16px 18px;
  font-size: 14.5px;
  line-height: 1.9;
  overflow-wrap: anywhere;
}
