/* Instagram Transcript Tool - Minimal Clean Design */
/* No frameworks, no external fonts */

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

:root {
  --bg: #ffffff;
  --fg: #1a1a1a;
  --muted: #666;
  --accent: #E1306C;
  --accent-hover: #C1124F;
  --border: #e0e0e0;
  --result-bg: #f9f9f9;
  --radius: 8px;
  --max-width: 640px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--fg);
  background: var(--bg);
  line-height: 1.6;
  font-size: 16px;
}

/* Header */
header {
  text-align: center;
  padding: 20px 16px 0;
}
header h1 {
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

/* Main */
main {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 16px;
}

/* Tool Section */
#tool {
  margin-bottom: 32px;
}

.input-row {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 12px;
}
#file-input, #transcribe-btn {
  width: 100%;
  min-width: 0;
}

@media (min-width: 560px) {
  .input-row { flex-direction: row; }
  #file-input { flex: 1; width: auto; }
  #transcribe-btn { width: auto; }
}

#file-input {
  flex: 1;
  min-width: 0;
  padding: 14px 16px;
  font-size: 16px;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  outline: none;
  transition: border-color 0.2s;
}
#file-input:focus {
  border-color: var(--accent);
}

#transcribe-btn {
  padding: 14px 24px;
  font-size: 16px;
  font-weight: 600;
  color: #fff;
  background: var(--accent);
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.2s;
}
#transcribe-btn:hover {
  background: var(--accent-hover);
}
#transcribe-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.format-toggle {
  display: flex;
  gap: 20px;
  margin-bottom: 16px;
  font-size: 0.9rem;
  color: var(--muted);
}
.format-toggle label {
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 4px;
}

/* Status */
.status {
  padding: 16px;
  text-align: center;
  color: var(--muted);
  font-size: 0.95rem;
}
.status.error {
  color: #d32f2f;
  background: #fef0f0;
  border-radius: var(--radius);
  padding: 12px 16px;
  text-align: left;
}

/* Spinner */
.spinner {
  display: inline-block;
  width: 18px;
  height: 18px;
  border: 2.5px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  vertical-align: middle;
  margin-right: 8px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Result */
.result {
  margin-top: 16px;
}
.result-meta {
  display: flex;
  gap: 16px;
  font-size: 0.85rem;
  color: var(--muted);
  margin-bottom: 8px;
}
.result-actions {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}
.result-actions button {
  padding: 8px 16px;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--fg);
  background: var(--bg);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: all 0.2s;
}
.result-actions button:hover {
  border-color: var(--accent);
  color: var(--accent);
}
.result-actions button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

#transcript-text {
  background: var(--result-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  white-space: pre-wrap;
  word-wrap: break-word;
  font-size: 0.95rem;
  line-height: 1.7;
  max-height: 400px;
  overflow-y: auto;
  font-family: inherit;
}

/* Upload Area */
#upload-area {
  margin-top: 12px;
  padding: 12px;
  border: 1.5px dashed var(--border);
  border-radius: var(--radius);
  text-align: center;
}
.upload-label {
  cursor: pointer;
  color: var(--muted);
  font-size: 0.9rem;
}
#file-input {
  display: none;
}
.intro { margin: 8px 0 16px; }
.hint { margin: 8px 0 16px; color: var(--muted); font-size: 0.9rem; }
.upload-label {
  display: block;
  width: 100%;
  padding: 14px 16px;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  color: var(--muted);
}
.selected-file {
  display: grid;
  grid-template-columns: minmax(120px, 220px) minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  margin: 12px 0 16px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--result-bg);
}
.selected-file.hidden { display: none; }
.media-preview { min-width: 0; }
.video-preview {
  display: block;
  width: 100%;
  max-height: 150px;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  border-radius: 6px;
  background: #111;
}
.audio-preview { display: block; width: 100%; }
.selected-file-info { display: grid; gap: 4px; min-width: 0; }
.selected-file-info strong,
.selected-file-info span { overflow-wrap: anywhere; }
.selected-file-info strong { font-size: 0.92rem; }
.selected-file-info span { color: var(--muted); font-size: 0.82rem; }
.selected-file-info .file-state { color: var(--accent); font-weight: 600; }
.remove-file-btn {
  align-self: start;
  padding: 6px 9px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  color: var(--muted);
  cursor: pointer;
}
.remove-file-btn:disabled { opacity: 0.55; cursor: not-allowed; }

/* Sections */
section {
  margin-bottom: 32px;
}
h2 {
  font-size: 1.2rem;
  font-weight: 600;
  margin-bottom: 12px;
}
ol, ul {
  padding-left: 20px;
}
li {
  margin-bottom: 6px;
  font-size: 0.95rem;
}
code {
  background: var(--result-bg);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.85em;
  font-family: "SF Mono", Consolas, monospace;
}

/* FAQ */
details {
  border-bottom: 1px solid var(--border);
  padding: 12px 0;
}
details summary {
  cursor: pointer;
  font-size: 0.95rem;
  font-weight: 500;
}
details p {
  margin-top: 8px;
  font-size: 0.9rem;
  color: var(--muted);
}

/* Footer */
footer {
  text-align: center;
  padding: 24px 16px;
  font-size: 0.8rem;
  color: var(--muted);
}
footer a {
  color: var(--accent);
  text-decoration: none;
}
footer nav {
  display: flex;
  justify-content: center;
  gap: 16px;
  margin-top: 8px;
}
footer a:hover,
footer a:focus-visible {
  text-decoration: underline;
}

/* Utility */
.hidden { display: none; }

/* Ensure nothing overflows narrow viewports */
header h1,
#file-input,
#transcribe-btn,
.format-toggle,
section,
li,
code {
  overflow-wrap: anywhere;
  word-wrap: break-word;
}

/* Small screens: tighter heading */
@media (max-width: 559px) {
  header h1 { font-size: 1.5rem; }
  .format-toggle { flex-wrap: wrap; gap: 12px; }
  .selected-file { grid-template-columns: 1fr auto; }
  .media-preview { grid-column: 1 / -1; }
  .video-preview { max-height: 220px; }
}

/* Larger screens */
@media (min-width: 768px) {
  header h1 { font-size: 2rem; }
  main { padding: 24px; }
  #file-input { font-size: 1rem; }
  #transcribe-btn { font-size: 1rem; }
}
