:root {
  --bg: #f6f7fb; --card: #fff; --ink: #22262e; --sub: #6b7280;
  --brand: #4f7cff; --brand-d: #3a63d8; --ok: #0a7d33; --warn: #c0392b;
  --line: #e6e8ef; --chip: #eef2ff;
}
* { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font-family: -apple-system, "Apple SD Gothic Neo", "Malgun Gothic", sans-serif;
  -webkit-text-size-adjust: 100%;
}
header {
  position: sticky; top: 0; background: var(--card); border-bottom: 1px solid var(--line);
  padding: 12px 16px 0; z-index: 5;
}
h1 { font-size: 1.15rem; margin: 0 0 8px; }
h2 { font-size: 1.05rem; margin: 0 0 10px; }
h3 { font-size: .95rem; margin: 18px 0 8px; color: var(--sub); }
nav { display: flex; gap: 4px; }
.tab {
  flex: 1; border: none; background: none; padding: 10px; font-size: .95rem; color: var(--sub);
  border-bottom: 2px solid transparent; cursor: pointer;
}
.tab.active { color: var(--brand); border-bottom-color: var(--brand); font-weight: 600; }
.view { max-width: 560px; margin: 0 auto; padding: 16px; }
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: 14px;
  padding: 16px; margin-bottom: 14px;
}
.card.ok { border-color: #bfe6c9; background: #f2fbf5; }
.hint { color: var(--sub); font-size: .88rem; margin: 0 0 12px; line-height: 1.5; }
.filebtn {
  display: block; text-align: center; padding: 22px; border: 2px dashed var(--brand);
  border-radius: 12px; color: var(--brand-d); font-weight: 600; cursor: pointer; background: var(--chip);
}
#preview { display: block; width: 100%; max-height: 320px; object-fit: contain; margin: 12px 0; border-radius: 10px; background: #f0f0f0; }
textarea {
  width: 100%; border: 1px solid var(--line); border-radius: 10px; padding: 12px;
  font-size: 1rem; font-family: inherit; resize: vertical;
}
button.primary, button.ghost {
  padding: 12px 16px; border-radius: 10px; font-size: .95rem; cursor: pointer; border: 1px solid transparent;
}
button.primary { background: var(--brand); color: #fff; font-weight: 600; }
button.primary:disabled { background: #b9c6ef; cursor: default; }
button.ghost { background: none; border-color: var(--line); color: var(--sub); }
button.primary:not(:disabled):active { background: var(--brand-d); }
.row { display: flex; gap: 8px; margin-top: 14px; }
.row .primary { flex: 1; }
.diag { background: #fff7ec; border: 1px solid #ffe1b0; border-radius: 10px; padding: 12px; margin: 0 0 14px; line-height: 1.5; }
.analysis { margin: 0 0 14px; }
.analysis > div { border-radius: 10px; padding: 10px 12px; margin-bottom: 8px; line-height: 1.5; }
.analysis b { display: block; font-size: .8rem; margin-bottom: 4px; color: var(--sub); }
.analysis p { margin: 0; }
.an-concept { background: #eef3ff; border: 1px solid #d3e0ff; }
.an-concept p { font-weight: 600; }
.an-req { background: #f0faf3; border: 1px solid #cdeed7; }
.an-req ul { margin: 0; padding-left: 18px; }
.an-req li { margin: 2px 0; }
.an-pit { background: #fff4f4; border: 1px solid #ffd9d9; }
.an-more { margin-top: 8px; font-size: .88rem; }
.an-more summary { color: var(--brand-d); cursor: pointer; }
.an-more .analysis { margin-top: 8px; }
.an-sum { margin-top: 6px; color: var(--sub); font-size: .88rem; }
.tag-opt {
  display: block; width: 100%; text-align: left; border: 1px solid var(--line); background: #fff;
  border-radius: 10px; padding: 12px; margin-bottom: 8px; cursor: pointer; font-size: .95rem;
}
.tag-opt.sel { border-color: var(--brand); background: var(--chip); font-weight: 600; }
.tag-opt small { display: block; color: var(--sub); font-weight: 400; margin-top: 2px; }
.bar-row { margin-bottom: 10px; }
.bar-row .lbl { display: flex; justify-content: space-between; font-size: .9rem; margin-bottom: 4px; }
.bar-row .lbl b { color: var(--warn); }
.bar { height: 10px; background: #eef0f6; border-radius: 6px; overflow: hidden; }
.bar > i { display: block; height: 100%; background: linear-gradient(90deg, var(--brand), #7aa0ff); }
.recent {
  border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; margin-bottom: 8px; font-size: .9rem;
}
.recent .chip { display: inline-block; background: var(--chip); color: var(--brand-d); border-radius: 6px; padding: 2px 8px; font-size: .78rem; margin-right: 4px; }
.recent .when { color: var(--sub); font-size: .78rem; float: right; }
.recent-body { display: flex; gap: 10px; margin-top: 6px; align-items: flex-start; }
.recent-body .thumb { width: 72px; height: 72px; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); flex: none; background: #f0f0f0; }
.empty { color: var(--sub); text-align: center; padding: 24px 0; }
.spin { color: var(--sub); text-align: center; padding: 18px 0; }
#toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: #22262e; color: #fff; padding: 10px 18px; border-radius: 20px; font-size: .9rem; z-index: 20;
}
