/**
 * AI会話カルテ（仮） - style.css
 * Version: v0.1.0
 * Updated: 2026-06-10
 *
 * Change Log:
 * - v0.1.0: 初期UIスタイルを追加。
 */

:root {
  color-scheme: light;
  --bg: #f6f7f4;
  --panel: #ffffff;
  --line: #d9ded6;
  --text: #1f2a24;
  --muted: #68746d;
  --accent: #217a70;
  --accent-strong: #145f57;
  --danger: #b83232;
  --user: #eef8f5;
  --assistant: #fff8e7;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.65;
}

button,
input,
textarea {
  font: inherit;
}

button {
  border: 1px solid var(--accent);
  border-radius: 6px;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  min-height: 38px;
  padding: 7px 12px;
}

button:hover {
  background: var(--accent-strong);
}

input,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  padding: 9px 10px;
}

textarea {
  min-height: 96px;
  resize: vertical;
}

.app-header,
.privacy-panel,
.file-panel,
.status-area,
.workspace {
  width: min(1480px, calc(100% - 32px));
  margin: 16px auto;
}

.app-header,
.file-panel {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}

.app-header h1 {
  margin: 0;
  font-size: clamp(1.8rem, 3vw, 2.8rem);
}

.version {
  margin: 0;
  color: var(--accent);
  font-weight: 700;
}

.privacy-panel,
.file-panel,
.search-panel,
.list-panel,
.detail-shell,
.status-area {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  padding: 16px;
}

.privacy-panel h2,
.file-panel h2,
.list-header h2,
.detail-header h2 {
  margin: 0 0 8px;
}

.privacy-panel p,
.file-panel p {
  margin: 6px 0;
}

.danger-button {
  border-color: var(--danger);
  background: var(--danger);
}

.file-picker input {
  position: absolute;
  inline-size: 1px;
  block-size: 1px;
  opacity: 0;
}

.file-picker span {
  display: inline-flex;
  align-items: center;
  min-height: 42px;
  border-radius: 6px;
  background: var(--accent);
  color: #fff;
  padding: 8px 16px;
  cursor: pointer;
}

.status-area.success {
  border-color: #65a87f;
  color: #166534;
}

.status-area.warn {
  border-color: #d7a940;
  color: #7a4b00;
}

.status-area.error {
  border-color: #d76c6c;
  color: #8a1f1f;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(320px, 420px) minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}

.sidebar {
  display: grid;
  gap: 16px;
  position: sticky;
  top: 12px;
}

.search-panel label {
  display: block;
  margin-bottom: 6px;
  font-weight: 700;
}

.tag-filter-area,
.assigned-tags,
.candidate-tags,
.item-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}

.tag-filter,
.candidate-tag,
.tag-chip {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #f4f8f6;
  color: var(--text);
  min-height: 30px;
  padding: 4px 10px;
}

.tag-filter.active,
.candidate-tag:hover {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}

.tag-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.chip-remove {
  min-height: 20px;
  border: 0;
  background: transparent;
  color: var(--danger);
  padding: 0 2px;
}

.list-header,
.detail-header,
.export-actions,
.tag-add-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.conversation-list {
  display: grid;
  gap: 8px;
  max-height: calc(100vh - 330px);
  overflow: auto;
}

.conversation-item {
  display: grid;
  gap: 4px;
  width: 100%;
  min-height: 132px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  padding: 12px;
  text-align: left;
}

.conversation-item.active {
  border-color: var(--accent);
  box-shadow: inset 4px 0 0 var(--accent);
}

.item-title {
  font-weight: 800;
}

.item-meta,
.item-preview,
.muted,
.detail-meta {
  color: var(--muted);
  font-size: 0.9rem;
}

.item-tags span {
  border-radius: 999px;
  background: #edf2ef;
  padding: 2px 8px;
  font-size: 0.82rem;
}

.detail-area.empty,
.conversation-list.empty {
  min-height: 180px;
  display: grid;
  place-items: center;
  color: var(--muted);
}

.detail-shell {
  display: grid;
  gap: 18px;
}

.tag-editor,
.memo-grid,
.export-panel,
.messages-panel {
  border-top: 1px solid var(--line);
  padding-top: 16px;
}

.tag-editor h3,
.tag-editor h4,
.messages-panel h3 {
  margin: 0 0 8px;
}

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

.memo-field span {
  display: block;
  margin-bottom: 5px;
  font-weight: 700;
}

.check-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
}

.check-row input {
  width: auto;
}

#handoffOutput {
  min-height: 220px;
  margin-top: 10px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.messages-panel {
  display: grid;
  gap: 10px;
}

.message-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
}

.message-card.user {
  background: var(--user);
}

.message-card.assistant {
  background: var(--assistant);
}

.message-card summary {
  cursor: pointer;
  font-weight: 800;
}

.message-text {
  margin-top: 10px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.long-message .message-text {
  max-height: 560px;
  overflow: auto;
}

@media (max-width: 900px) {
  .app-header,
  .file-panel,
  .workspace,
  .memo-grid {
    grid-template-columns: 1fr;
    display: grid;
  }

  .sidebar {
    position: static;
  }

  .conversation-list {
    max-height: none;
  }
}
