/* SSTV Web App - Light theme */

:root {
  --bg: #e4e6eb;
  --bg-card: #f2f4f7;
  --bg-elevated: #d8dce2;
  --text: #0f172a;
  --text-muted: #475569;
  --accent: #0d9488;
  --accent-dim: #0f766e;
  --border: #b8c0cc;
  --radius: 12px;
  --radius-sm: 8px;
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.12);
  --shadow-card: 0 2px 8px rgba(0, 0, 0, 0.1);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font-sans);
  font-weight: 400;
  color: var(--text);
  background: var(--bg);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.app {
  max-width: 720px;
  margin: 0 auto;
  padding: 2rem 1.5rem;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Header */
.header {
  text-align: left;
  margin-bottom: 2rem;
}

.logo {
  font-family: var(--font-mono);
  font-size: 1.25rem;
  font-weight: 400;
  letter-spacing: 0.04em;
  color: var(--text);
  margin: 0;
}

.tagline {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin: 0.25rem 0 0;
}

/* Tabs */
.tabs {
  display: flex;
  gap: 0;
  margin-bottom: 1.5rem;
  background: var(--bg-elevated);
  padding: 4px;
  border-radius: var(--radius);
}

.tab {
  flex: 1;
  padding: 0.65rem 1rem;
  font-family: var(--font-sans);
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-muted);
  background: transparent;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: color 0.2s, background 0.2s;
}

.tab:hover {
  color: var(--text);
}

.tab.active {
  color: #fff;
  background: var(--accent);
}

/* Panels */
.panel {
  display: none;
}

.panel.active {
  display: block;
}

/* Card */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.75rem;
  box-shadow: var(--shadow-card);
}

.card h2 {
  font-size: 1.1rem;
  font-weight: 500;
  margin: 0 0 0.25rem;
}

.card .hint {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin: 0 0 1.25rem;
}

/* Input */
.input-group {
  margin-bottom: 1rem;
}

.input-options {
  display: flex;
  gap: 1.5rem;
  margin-bottom: 1rem;
}

.radio-label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.9rem;
  color: var(--text-muted);
  cursor: pointer;
}

.radio-label input {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
}

.radio-label:has(input:checked) {
  color: var(--text);
}

/* Upload zone */
.file-upload {
  margin-top: 0.5rem;
}

.upload-zone {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 2rem;
  border: 2px dashed var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
}

.upload-zone:hover,
.upload-zone.dragover {
  border-color: var(--accent);
  background: rgba(13, 148, 136, 0.06);
}

.upload-icon {
  font-size: 1.5rem;
  color: var(--text-muted);
}

.upload-zone .upload-text {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.upload-zone:hover .upload-text,
.upload-zone.dragover .upload-text {
  color: var(--text);
}

.upload-zone.loading {
  pointer-events: none;
  opacity: 0.7;
}

.decode-status {
  margin-top: 0.75rem;
  font-size: 0.85rem;
  color: var(--accent);
  min-height: 1.2em;
}

.decode-status.error {
  color: #dc2626;
}

.decode-mode-hint,
.encode-duration-hint {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin: 0 0 0.5rem;
}

.encode-status {
  margin-top: 0.5rem;
  font-size: 0.85rem;
  min-height: 1.2em;
}

.encode-status.error {
  color: #dc2626;
}

/* Mode select */
.mode-select {
  margin-bottom: 1rem;
}

.mode-select label {
  display: block;
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 0.4rem;
}

.mode-select select {
  width: 100%;
  padding: 0.6rem 0.9rem;
  font-family: var(--font-sans);
  font-size: 0.9rem;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23475569' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.9rem center;
  padding-right: 2rem;
}

.mode-select select:focus {
  outline: none;
  border-color: var(--accent);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.6rem 1.2rem;
  font-family: var(--font-sans);
  font-size: 0.9rem;
  font-weight: 500;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  text-decoration: none;
  transition: background 0.2s, color 0.2s;
}

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

.btn-primary:hover:not(:disabled) {
  background: var(--accent-dim);
}

.btn-primary:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.btn-secondary {
  background: var(--bg-elevated);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-secondary:hover {
  background: #e0f2f1;
  border-color: #99f6e4;
}

.btn-outline {
  background: transparent;
  color: var(--accent);
  border: 1px solid var(--accent);
}

.btn-outline:hover {
  background: rgba(13, 148, 136, 0.08);
}

.btn-outline.playing {
  background: rgba(220, 38, 38, 0.1);
  border-color: #dc2626;
  color: #dc2626;
}

.btn-icon {
  font-size: 0.7em;
}

/* Mic controls */
.mic-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
  padding: 1rem 0;
}

.mic-status {
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* Result area */
.result-area {
  margin-top: 1.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
}

.result-area canvas,
.result-area img {
  max-width: 100%;
  height: auto;
  border-radius: var(--radius-sm);
  background: var(--bg);
  display: block;
}

.result-area canvas {
  border: 1px solid var(--border);
  margin-bottom: 1rem;
}

.preview-box {
  margin-bottom: 1rem;
}

.preview-box canvas {
  max-width: 280px;
  width: auto;
  height: auto;
  border-radius: var(--radius-sm);
  background: var(--bg);
  border: 1px solid var(--border);
}

.preview-label {
  display: block;
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.35rem;
}

.result-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}

/* Ad strip */
.ad-strip {
  margin-top: 1rem;
  margin-bottom: 0.5rem;
}

.ad-strip-inner {
  width: 100%;
  min-height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.4rem 0.6rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
  overflow: hidden;
}

.ad-strip-inner ins.adsbygoogle {
  display: block;
  width: 100%;
}

.ad-strip + .guide {
  margin-top: 0.75rem;
}

/* Guide */
.guide {
  margin-top: 2rem;
  padding: 1.5rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.guide h3 {
  font-size: 1rem;
  font-weight: 500;
  margin: 0 0 1rem;
  color: var(--text);
}

.guide h4 {
  font-size: 0.9rem;
  font-weight: 500;
  margin: 0 0 0.5rem;
  color: var(--accent);
}

.guide-section {
  margin-bottom: 1.25rem;
}

.guide-section:last-of-type {
  margin-bottom: 0;
}

.guide p {
  margin: 0 0 0.75rem;
  font-size: 0.85rem;
  color: var(--text-muted);
  line-height: 1.7;
}

.guide p:last-child {
  margin-bottom: 0;
}

.guide ul,
.guide ol {
  margin: 0 0 0.75rem;
  padding-left: 1.25rem;
  font-size: 0.85rem;
  color: var(--text-muted);
  line-height: 1.7;
}

.guide ul li,
.guide ol li {
  margin-bottom: 0.35rem;
}

.guide-table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin: 0.5rem 0 0.75rem;
}

.guide-table {
  width: 100%;
  min-width: 280px;
  border-collapse: collapse;
  font-size: 0.8rem;
}

.guide-table th,
.guide-table td {
  padding: 0.4rem 0.75rem;
  text-align: left;
  border: 1px solid var(--border);
}

.guide-table th {
  background: var(--bg-elevated);
  color: var(--accent-dim);
  font-weight: 500;
}

.guide-table td {
  color: var(--text-muted);
}

.guide-note {
  margin: 1rem 0 0;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* Footer */
.footer {
  margin-top: auto;
  padding-top: 2rem;
  text-align: center;
}

.footer p {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.footer a {
  color: var(--accent);
  text-decoration: none;
}

.footer a:hover {
  text-decoration: underline;
}

.footer .sep {
  margin: 0 0.4rem;
  color: var(--border);
}

.footer .brand {
  color: var(--accent);
  font-weight: 500;
}

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

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (max-width: 480px) {
  .app {
    padding: 1.25rem 1rem;
  }

  .card {
    padding: 1.25rem;
  }

}
