:root {
  --navy: #2C3E50;
  --navy2: #3d5166;
  --blue: #4A90D9;
  --bg: #f4f6f9;
  --card: #fff;
  --border: #e0e4ea;
  --text: #333;
  --muted: #888;
  --accent: #e8f0fb;
  --success: #27ae60;
  --error: #e74c3c;
  --warn: #f39c12;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Hiragino Sans', 'Noto Sans JP', -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 14px;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
}

/* ===== Login ===== */
.login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #f4f6f9 0%, #e8eef5 100%);
  padding: 24px;
}

.login-box {
  background: var(--card);
  border-radius: 16px;
  border: 1px solid var(--border);
  padding: 40px 32px;
  width: 100%;
  max-width: 380px;
  box-shadow: 0 8px 32px rgba(44,62,80,.12);
  text-align: center;
}

.login-logo { font-size: 40px; margin-bottom: 12px; }
.login-title { font-size: 20px; font-weight: bold; color: var(--navy); margin-bottom: 4px; }
.login-sub { font-size: 12px; color: var(--muted); margin-bottom: 28px; }

/* ===== Header ===== */
.header {
  background: var(--navy);
  color: #fff;
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-inner {
  max-width: 900px;
  margin: 0 auto;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.header-logo { font-size: 14px; font-weight: bold; }
.header-right { display: flex; align-items: center; gap: 10px; }
.header-user { font-size: 12px; opacity: .7; }

/* ===== Progress bar ===== */
.progress-bar {
  background: var(--card);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 48px;
  z-index: 99;
}

.progress-steps {
  max-width: 900px;
  margin: 0 auto;
  display: flex;
}

.ps {
  flex: 1;
  padding: 10px 8px;
  text-align: center;
  font-size: 12px;
  color: var(--muted);
  border-right: 1px solid var(--border);
  transition: all .15s;
}
.ps:last-child { border-right: none; }
.ps.active { background: var(--navy); color: #fff; font-weight: bold; }
.ps.done { background: #d1fae5; color: var(--success); }

/* ===== Main ===== */
.main {
  max-width: 760px;
  margin: 0 auto;
  padding: 24px 16px 80px;
}

/* ===== Card ===== */
.card {
  background: var(--card);
  border-radius: 12px;
  border: 1px solid var(--border);
  padding: 24px;
  box-shadow: 0 2px 8px rgba(0,0,0,.05);
}

.card-title {
  font-size: 16px;
  font-weight: bold;
  color: var(--navy);
  margin-bottom: 20px;
  padding-bottom: 12px;
  border-bottom: 2px solid var(--navy);
}

/* ===== Forms ===== */
.form-group { margin-bottom: 20px; }

.lbl {
  display: block;
  font-size: 12px;
  font-weight: bold;
  color: var(--navy);
  margin-bottom: 6px;
}

.req { color: var(--error); }
.hint { font-size: 11px; color: var(--muted); margin-top: 4px; }

input[type=text],
input[type=url],
input[type=password],
textarea,
select {
  width: 100%;
  padding: 10px 12px;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  font-size: 13px;
  font-family: inherit;
  color: var(--text);
  background: #fff;
  transition: border-color .15s;
}
input:focus, textarea:focus {
  outline: none;
  border-color: var(--blue);
}
textarea { resize: vertical; }

.suggestions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.tag {
  background: var(--accent);
  color: var(--navy);
  border: 1px solid #c8d9f0;
  border-radius: 20px;
  padding: 3px 10px;
  font-size: 11px;
  cursor: pointer;
  user-select: none;
  transition: .15s;
}
.tag:hover { background: var(--navy); color: #fff; }

/* ===== Platform chips ===== */
.platform-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

.plat-chip {
  border: 2px solid var(--border);
  border-radius: 10px;
  padding: 12px;
  cursor: pointer;
  text-align: center;
  transition: .15s;
  user-select: none;
}
.plat-chip:hover { border-color: var(--blue); background: var(--accent); }
.plat-chip.selected { border-color: var(--navy); background: var(--accent); }
.plat-chip input { display: none; }
.chip-ico { display: block; font-size: 22px; margin-bottom: 4px; }
.chip-name { font-size: 11px; font-weight: bold; }

/* ===== Style cards ===== */
.style-grid { display: flex; flex-direction: column; gap: 10px; }

.style-card {
  border: 2px solid var(--border);
  border-radius: 10px;
  padding: 14px;
  cursor: pointer;
  transition: .15s;
}
.style-card:hover { border-color: var(--blue); background: var(--accent); }
.style-card.selected { border-color: var(--navy); background: var(--accent); }
.style-card input { display: none; }
.style-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}
.style-ico { font-size: 18px; }
.style-desc { font-size: 11.5px; color: var(--muted); line-height: 1.5; }
.badge-rec {
  background: var(--success);
  color: #fff;
  border-radius: 20px;
  padding: 1px 8px;
  font-size: 10px;
  font-weight: bold;
  margin-left: auto;
}

/* ===== URL row ===== */
.url-row { display: flex; gap: 8px; }
.url-row input { flex: 1; }

/* ===== Summary box ===== */
.summary-box {
  background: var(--accent);
  border-radius: 8px;
  padding: 14px;
  font-size: 12px;
  line-height: 1.8;
  margin-bottom: 16px;
  color: #444;
}
.summary-box strong { color: var(--navy); }

/* ===== Buttons ===== */
.btn {
  padding: 10px 20px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: bold;
  border: none;
  cursor: pointer;
  font-family: inherit;
  transition: .15s;
  white-space: nowrap;
}
.btn-primary { background: var(--navy); color: #fff; }
.btn-primary:hover { background: var(--navy2); }
.btn-primary:disabled { background: #aaa; cursor: not-allowed; }
.btn-ghost { background: #fff; color: var(--navy); border: 1.5px solid var(--navy); }
.btn-ghost:hover { background: var(--accent); }
.btn-full { width: 100%; }
.btn-sm { padding: 6px 12px; font-size: 11.5px; }
.btn-lg { font-size: 15px; padding: 14px 40px; }

.nav-row { display: flex; justify-content: space-between; align-items: center; margin-top: 20px; }

/* ===== Messages ===== */
.msg { padding: 10px 14px; border-radius: 8px; font-size: 12px; margin-bottom: 12px; line-height: 1.5; }
.err { background: #fee2e2; color: #991b1b; display: block; }
.ok  { background: #d1fae5; color: #065f46; display: block; }
.info{ background: var(--accent); color: #1a56db; display: block; }

/* ===== Output ===== */
.output-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
  flex-wrap: wrap;
  gap: 8px;
}
.output-label { font-size: 12px; font-weight: bold; color: var(--navy); }
.output-actions { display: flex; gap: 6px; }

.table-wrap { overflow-x: auto; border-radius: 8px; border: 1px solid var(--border); }

.script-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}
.script-table th {
  background: var(--navy);
  color: #fff;
  padding: 8px 10px;
  text-align: left;
  font-size: 11px;
  white-space: nowrap;
}
.script-table td {
  padding: 7px 10px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
  line-height: 1.5;
}
.script-table tr:last-child td { border-bottom: none; }
.script-table tr:nth-child(even) td { background: #fafbfc; }
.script-table .tc { color: var(--muted); white-space: nowrap; font-family: monospace; }
.script-table .section-row td { background: var(--accent); font-weight: bold; }

/* Long: sections */
.section-block {
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-bottom: 12px;
  overflow: hidden;
}
.section-header {
  background: var(--navy);
  color: #fff;
  padding: 8px 14px;
  font-size: 12px;
  font-weight: bold;
  display: flex;
  gap: 12px;
}
.section-time { opacity: .7; }
.section-body { display: grid; grid-template-columns: 1fr 1fr; gap: 0; }
.section-col {
  padding: 12px 14px;
  font-size: 12px;
  line-height: 1.6;
  border-right: 1px solid var(--border);
}
.section-col:last-child { border-right: none; }
.col-label { font-size: 10px; font-weight: bold; color: var(--muted); margin-bottom: 4px; }

.analysis-block {
  background: #fafafa;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px;
  margin-bottom: 10px;
}
.analysis-block h4 { font-size: 12px; color: var(--navy); margin-bottom: 8px; }
.analysis-block ul { list-style: none; }
.analysis-block li { font-size: 12px; padding: 3px 0; }
.analysis-block li::before { content: '• '; color: var(--navy); }

/* Streaming */
.stream-header {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 10px;
  padding: 10px 14px;
  background: #fef9c3;
  border-radius: 8px;
}
.stream-text {
  white-space: pre-wrap;
  font-size: 12px;
  font-family: 'Hiragino Sans', monospace;
  line-height: 1.7;
  max-height: 400px;
  overflow-y: auto;
  background: #fafafa;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px;
  color: #444;
}
.raw-output {
  width: 100%;
  height: 200px;
  font-size: 11px;
  font-family: monospace;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 10px;
  resize: vertical;
  margin-top: 8px;
  color: #444;
}

/* Spinner */
.spin {
  display: inline-block;
  width: 14px; height: 14px;
  border: 2px solid #ccc;
  border-top-color: var(--navy);
  border-radius: 50%;
  animation: sp .7s linear infinite;
}
@keyframes sp { to { transform: rotate(360deg) } }

/* Misc */
.muted { color: var(--muted); font-weight: normal; }

/* ===== Mode selection ===== */
.mode-grid { display: flex; gap: 10px; }
.mode-btn {
  flex: 1;
  padding: 12px;
  border: 2px solid var(--border);
  border-radius: 10px;
  background: #fff;
  cursor: pointer;
  font-size: 13px;
  font-weight: bold;
  font-family: inherit;
  transition: .15s;
  color: var(--text);
}
.mode-btn:hover { border-color: var(--blue); background: var(--accent); }
.mode-btn.selected { border-color: var(--navy); background: var(--accent); color: var(--navy); }

.form-row { display: flex; gap: 12px; }

/* ===== Research cards ===== */
.research-section { margin-bottom: 20px; }
.research-section-title {
  font-size: 14px;
  font-weight: bold;
  color: var(--navy);
  margin-bottom: 10px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
}

.research-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

.research-card {
  border: 2px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  cursor: pointer;
  transition: .15s;
  background: #fff;
}
.research-card:hover { border-color: var(--blue); box-shadow: 0 2px 8px rgba(0,0,0,.08); }
.research-card.selected { border-color: var(--navy); background: var(--accent); }

.rc-thumb {
  width: 100%;
  height: 0;
  padding-bottom: 56.25%;
  background-size: cover;
  background-position: center;
  position: relative;
}
.rc-duration {
  position: absolute;
  bottom: 4px;
  right: 4px;
  background: rgba(0,0,0,.7);
  color: #fff;
  font-size: 10px;
  padding: 1px 5px;
  border-radius: 3px;
}
.rc-info { padding: 8px 10px; }
.rc-title {
  font-size: 12px;
  font-weight: bold;
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin-bottom: 4px;
}
.rc-channel { font-size: 11px; color: var(--muted); margin-bottom: 4px; }
.rc-stats {
  display: flex;
  gap: 8px;
  font-size: 10px;
  color: var(--muted);
  flex-wrap: wrap;
}
.rc-er {
  color: var(--success);
  font-weight: bold;
}

/* ===== Output tabs ===== */
.output-tabs {
  display: flex;
  gap: 0;
  border-bottom: 2px solid var(--border);
  margin-bottom: 12px;
}
.output-tab {
  padding: 8px 16px;
  border: none;
  background: none;
  cursor: pointer;
  font-size: 12px;
  font-weight: bold;
  font-family: inherit;
  color: var(--muted);
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: .15s;
}
.output-tab:hover { color: var(--navy); }
.output-tab.active {
  color: var(--navy);
  border-bottom-color: var(--navy);
}

/* ===== Titles list ===== */
.title-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-bottom: 8px;
  background: #fafafa;
}
.title-num {
  background: var(--navy);
  color: #fff;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: bold;
  flex-shrink: 0;
}
.title-text { flex: 1; font-size: 13px; }

/* ===== Thumb copies ===== */
.thumb-item {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px;
  margin-bottom: 10px;
  background: #fafafa;
}
.thumb-header {
  font-size: 11px;
  font-weight: bold;
  color: var(--muted);
  margin-bottom: 6px;
}
.thumb-main {
  font-size: 18px;
  font-weight: bold;
  color: var(--navy);
  margin-bottom: 4px;
}
.thumb-sub {
  font-size: 13px;
  color: var(--text);
  margin-bottom: 6px;
}
.thumb-reason {
  font-size: 11px;
  color: var(--muted);
  font-style: italic;
  margin-bottom: 8px;
}

@media (max-width: 600px) {
  .card { padding: 16px; }
  .platform-grid { grid-template-columns: repeat(2, 1fr); }
  .section-body { grid-template-columns: 1fr; }
  .section-col { border-right: none; border-bottom: 1px solid var(--border); }
  .section-col:last-child { border-bottom: none; }
  .btn-lg { padding: 12px 24px; font-size: 13px; }
  .research-grid { grid-template-columns: 1fr; }
  .mode-grid { flex-direction: column; }
  .form-row { flex-direction: column; gap: 0; }
}
