:root {
  --bg: #f8fafc;
  --panel: #ffffff;
  --fg: #0f172a;
  --muted: #475569;
  --line: #e2e8f0;
  --accent: #1d4ed8;
  --accent-soft: #eff6ff;
  --warn: #be123c;
  --warn-soft: #fff1f2;
  --ok: #047857;
  --ok-soft: #ecfdf5;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  min-height: 100vh;
  background: var(--bg);
  color: var(--fg);
  font-family: "Noto Sans JP", system-ui, -apple-system, "Segoe UI", Arial, sans-serif;
  line-height: 1.6;
}

button, input, textarea { font: inherit; }
button {
  border: 0;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  padding: 10px 18px;
  font-size: 14px;
  font-weight: 800;
  cursor: pointer;
}
button.secondary {
  background: #fff;
  color: var(--accent);
  border: 1px solid #bfdbfe;
}
button.danger { background: var(--warn); }
button:disabled { background: #94a3b8; cursor: not-allowed; }

.app-header {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 12px min(4vw, 32px);
  background: rgba(255, 255, 255, 0.94);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(8px);
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}
.brand img { width: 38px; height: 38px; }
.brand strong { display: block; font-size: 15px; }
.brand span { display: block; color: var(--muted); font-size: 12px; }
.top-nav { display: flex; gap: 8px; }
.nav-button {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--line);
  padding: 8px 14px;
}
.nav-button.is-active {
  background: var(--accent-soft);
  color: var(--accent);
  border-color: #bfdbfe;
}

.app-shell {
  width: min(1180px, 94vw);
  margin: 0 auto;
  padding: 24px 0 56px;
}
.is-hidden { display: none !important; }
.auth-panel {
  min-height: calc(100vh - 120px);
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 32px;
  align-items: center;
}
.auth-panel h1,
.summary-row h1,
.view h1 {
  margin: 0 0 8px;
  font-size: clamp(24px, 4vw, 38px);
  line-height: 1.25;
}
.auth-panel p,
.status {
  color: var(--muted);
  font-size: 13px;
}
.auth-form,
.paste-panel,
.detail-panel,
.settings-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 20px;
}
label {
  display: grid;
  gap: 6px;
  color: var(--fg);
  font-size: 13px;
  font-weight: 800;
}
input, textarea {
  width: 100%;
  min-width: 0;
  border: 1px solid #cbd5e1;
  border-radius: 10px;
  background: #fff;
  color: var(--fg);
  padding: 10px 12px;
}
textarea {
  min-height: 150px;
  resize: vertical;
}
textarea.extra-context {
  min-height: 84px;
}
input:focus, textarea:focus {
  outline: 3px solid #bfdbfe;
  border-color: var(--accent);
}
.auth-actions,
.field-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.auth-form,
#pasteForm {
  display: grid;
  gap: 12px;
}
.settings-form {
  display: grid;
  gap: 12px;
}
.settings-form label:first-child {
  display: flex;
  align-items: center;
  gap: 8px;
}
.settings-form input[type="checkbox"] {
  width: auto;
}

.summary-row {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-end;
  margin-bottom: 18px;
}
.character-strip {
  display: flex;
  gap: 8px;
  align-items: flex-end;
}
.character-strip img { width: 52px; }
.paste-panel { margin-bottom: 18px; }
.paste-panel h2,
.settings-panel h2 {
  margin: 0 0 12px;
  font-size: 18px;
}

.inbox-layout {
  display: grid;
  grid-template-columns: 340px minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}
.shelf-list {
  display: grid;
  gap: 10px;
}
.shelf {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
}
.shelf-header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  font-weight: 800;
  font-size: 13px;
}
.shelf-items { display: grid; }
.item-button {
  width: 100%;
  border: 0;
  border-radius: 0;
  background: #fff;
  color: var(--fg);
  padding: 12px 14px;
  text-align: left;
  font-weight: 600;
  border-bottom: 1px solid var(--line);
}
.item-button:hover,
.item-button.is-active { background: var(--accent-soft); }
.item-button small {
  display: block;
  color: var(--muted);
  font-weight: 500;
}
.risk-high {
  background: var(--warn-soft);
  border-color: #fecaca;
}
.detail-panel {
  min-height: 420px;
}
.detail-panel .empty {
  color: var(--muted);
  margin: 0;
}
.detail-heading {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
  border-bottom: 1px solid var(--line);
  padding-bottom: 12px;
  margin-bottom: 14px;
}
.detail-heading h2 {
  margin: 0;
  font-size: 20px;
}
.badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 4px 10px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 12px;
  font-weight: 800;
}
.badge.high {
  background: var(--warn-soft);
  color: var(--warn);
}
.badge.internal {
  background: #f1f5f9;
  color: var(--muted);
}
.badge.public {
  background: var(--ok-soft);
  color: var(--ok);
}
.detail-grid {
  display: grid;
  gap: 12px;
}
.body-preview,
.draft-output,
.report-preview {
  white-space: pre-wrap;
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px;
  font-size: 13px;
}
.report-preview:empty {
  display: none;
}
.risk-confirm {
  background: var(--warn-soft);
  border: 1px solid #fecaca;
  border-radius: 10px;
  padding: 12px;
}
.risk-confirm label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
}
.leak-warning {
  background: var(--warn-soft);
  border: 1px solid #fecaca;
  border-radius: 10px;
  padding: 12px;
  font-weight: 700;
  color: var(--warn);
  margin-bottom: 12px;
}
.message-card {
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
  display: grid;
  gap: 6px;
}
.message-card .message-head {
  display: flex;
  align-items: center;
  gap: 8px;
}
.message-card .avatar {
  flex: none;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 12px;
  font-weight: 700;
}
.message-card .message-meta {
  flex: 1;
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-size: 12px;
  color: var(--muted);
}
.message-card .message-body {
  white-space: pre-wrap;
  font-size: 13px;
}
.risk-confirm input { width: auto; }
.tone-row {
  display: grid;
  grid-template-columns: 160px 1fr;
  gap: 10px;
}
.share-row {
  display: flex;
  justify-content: flex-end;
}

@media (max-width: 820px) {
  .auth-panel,
  .inbox-layout,
  .tone-row,
  .field-grid,
  .auth-actions {
    grid-template-columns: 1fr;
  }
  .summary-row {
    align-items: flex-start;
    flex-direction: column;
  }
  .character-strip img { width: 42px; }
}
