:root {
  --bg: #f7f8fb;
  --card: #ffffff;
  --text: #1f2937;
  --muted: #6b7280;
  --primary: #0d6efd;
  --primary-hover: #0b5ed7;
  --border: #e5e7eb;
  --success: #16a34a;
  --error: #dc2626;
  --shadow: 0 6px 24px rgba(15, 23, 42, 0.06);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b1020;
    --card: #121a2e;
    --text: #e5e7eb;
    --muted: #9aa3b2;
    --border: #1f2a44;
    --shadow: 0 6px 24px rgba(0, 0, 0, 0.4);
  }
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    "Helvetica Neue", "Hiragino Sans", "Yu Gothic UI", "Meiryo", Arial, sans-serif;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

.container {
  max-width: 720px;
  margin: 0 auto;
  padding: 24px 16px calc(48px + env(safe-area-inset-bottom));
}

.hero h1 {
  font-size: 1.6rem;
  margin: 0 0 8px;
}

.hero .lead {
  margin: 0 0 24px;
  color: var(--muted);
  font-size: 0.95rem;
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 20px;
  box-shadow: var(--shadow);
}

.dropzone {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  border: 2px dashed var(--border);
  border-radius: 12px;
  padding: 24px 16px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  min-height: 140px;
}

.dropzone:hover, .dropzone.dragover {
  border-color: var(--primary);
  background: rgba(13, 110, 253, 0.04);
}

.dropzone input[type="file"] {
  position: absolute;
  opacity: 0;
  pointer-events: none;
  width: 0; height: 0;
}

.dropzone-text {
  display: flex;
  flex-direction: column;
  gap: 4px;
  color: var(--muted);
}

.dropzone-text strong {
  color: var(--text);
  font-size: 1.05rem;
}

.dropzone-text small {
  font-size: 0.82rem;
}

.file-name {
  display: inline-block;
  margin-top: 12px;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(13, 110, 253, 0.1);
  color: var(--primary);
  font-size: 0.85rem;
  word-break: break-all;
}

.options {
  display: flex;
  gap: 12px;
  margin: 16px 0;
  flex-wrap: wrap;
}

.option {
  flex: 1 1 200px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.9rem;
  color: var(--muted);
}

.option select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--card);
  color: var(--text);
  font-size: 1rem;
  appearance: none;
}

.option-check {
  flex-direction: row;
  align-items: center;
  gap: 8px;
  flex: 0 1 auto;
  padding-top: 24px;
}

.option-check input {
  width: 20px;
  height: 20px;
  accent-color: var(--primary);
}

button.primary, a.secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 14px 18px;
  border-radius: 10px;
  font-size: 1rem;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  width: 100%;
  border: none;
  transition: background 0.15s, transform 0.04s;
}

button.primary {
  background: var(--primary);
  color: #fff;
}

button.primary:hover:not(:disabled) {
  background: var(--primary-hover);
}

button.primary:active { transform: translateY(1px); }

button.primary:disabled {
  background: #94a3b8;
  cursor: not-allowed;
}

a.secondary {
  background: transparent;
  color: var(--primary);
  border: 1px solid var(--primary);
}

a.secondary:hover {
  background: rgba(13, 110, 253, 0.06);
}

.status {
  margin-top: 16px;
  padding: 12px 14px;
  border-radius: 10px;
  font-size: 0.95rem;
}

.status.info {
  background: rgba(13, 110, 253, 0.08);
  color: var(--primary);
}

.status.error {
  background: rgba(220, 38, 38, 0.08);
  color: var(--error);
}

.status.success {
  background: rgba(22, 163, 74, 0.08);
  color: var(--success);
}

.result {
  margin-top: 20px;
}

.result h2 {
  font-size: 1.1rem;
  margin: 0 0 12px;
}

audio {
  width: 100%;
}

.actions {
  margin-top: 12px;
}

.meta {
  margin-top: 8px;
  color: var(--muted);
  font-size: 0.85rem;
}

.transcript-details {
  margin-top: 16px;
  border-top: 1px solid var(--border);
  padding-top: 12px;
}

.transcript-details > summary {
  cursor: pointer;
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--text);
  list-style: none;
  padding: 6px 0;
  display: flex;
  align-items: center;
  gap: 8px;
}

.transcript-details > summary::-webkit-details-marker { display: none; }

.transcript-details > summary::before {
  content: "▶";
  font-size: 0.7rem;
  color: var(--muted);
  transition: transform 0.15s;
  display: inline-block;
}

.transcript-details[open] > summary::before {
  transform: rotate(90deg);
}

.transcript-source {
  color: var(--muted);
  font-weight: 400;
  font-size: 0.8rem;
}

.transcript {
  margin-top: 10px;
  max-height: 420px;
  overflow-y: auto;
  padding: 14px 16px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 0.92rem;
  line-height: 1.65;
  -webkit-overflow-scrolling: touch;
}

.markdown-body > *:first-child { margin-top: 0; }
.markdown-body > *:last-child { margin-bottom: 0; }

.markdown-body h1,
.markdown-body h2,
.markdown-body h3,
.markdown-body h4,
.markdown-body h5,
.markdown-body h6 {
  margin: 1.1em 0 0.5em;
  line-height: 1.3;
  font-weight: 700;
}

.markdown-body h1 { font-size: 1.3rem; }
.markdown-body h2 { font-size: 1.15rem; }
.markdown-body h3 { font-size: 1.05rem; }
.markdown-body h4 { font-size: 1rem; }

.markdown-body p { margin: 0.6em 0; }

.markdown-body ul,
.markdown-body ol {
  margin: 0.6em 0;
  padding-left: 1.5em;
}

.markdown-body li + li { margin-top: 4px; }

.markdown-body blockquote {
  margin: 0.6em 0;
  padding: 4px 12px;
  border-left: 3px solid var(--border);
  color: var(--muted);
}

.markdown-body code {
  background: rgba(127, 127, 127, 0.14);
  padding: 1px 5px;
  border-radius: 4px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.88em;
}

.markdown-body pre {
  background: rgba(127, 127, 127, 0.12);
  padding: 10px 12px;
  border-radius: 8px;
  overflow-x: auto;
}

.markdown-body pre code {
  background: transparent;
  padding: 0;
  font-size: 0.85rem;
}

.markdown-body table {
  border-collapse: collapse;
  margin: 0.6em 0;
  font-size: 0.88rem;
}

.markdown-body th,
.markdown-body td {
  border: 1px solid var(--border);
  padding: 6px 10px;
  text-align: left;
}

.markdown-body th {
  background: rgba(127, 127, 127, 0.08);
}

.markdown-body a {
  color: var(--primary);
}

.markdown-body hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 1em 0;
}

.tips {
  margin-top: 28px;
  color: var(--muted);
  font-size: 0.9rem;
}

.tips h2 {
  font-size: 1rem;
  margin: 0 0 8px;
  color: var(--text);
}

.tips ul {
  margin: 0;
  padding-left: 1.2em;
}

.tips li + li { margin-top: 6px; }

.spinner {
  width: 16px;
  height: 16px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  display: inline-block;
  vertical-align: -3px;
  margin-right: 8px;
}

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