:root {
  --bg: #050506;
  --panel: #10141e;
  --panel-border: #273040;
  --text: #f0f1f2;
  --muted: #8f98a7;
  --accent: #5ce35a;
  --accent-dark: #4ccc4c;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: 'Archivo', sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at 20% -5%, rgba(92, 227, 90, 0.14), transparent 26%),
    radial-gradient(circle at 120% 120%, rgba(92, 227, 90, 0.08), transparent 40%),
    var(--bg);
}

.page {
  width: min(1150px, 92vw);
  margin: 0 auto;
  padding: 36px 0 54px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}

.brand {
  font-size: clamp(2.2rem, 5vw, 3.2rem);
  font-weight: 900;
  letter-spacing: -0.06em;
  color: var(--text);
  text-decoration: none;
}

.brand span {
  color: var(--accent);
}

.mode-nav {
  display: flex;
  align-items: center;
  gap: 10px;
}

.mode-link {
  min-height: 44px;
  border: 1px solid #2a3344;
  border-radius: 10px;
  background: #0b0f18;
  color: var(--text);
  text-decoration: none;
  font-weight: 800;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
}

.mode-link span {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
}

.hero h1 {
  margin: 64px 0 36px;
  font-size: clamp(2.8rem, 9vw, 7.2rem);
  line-height: 0.9;
  letter-spacing: -0.04em;
}

.search-row {
  display: grid;
  grid-template-columns: 1fr 290px;
  gap: 24px;
  align-items: stretch;
}

.search-row input {
  width: 100%;
  border: 2px solid var(--panel-border);
  background: linear-gradient(180deg, #161c28 0%, #111622 100%);
  color: var(--text);
  border-radius: 28px;
  height: 110px;
  padding: 0 38px;
  font-size: clamp(1rem, 2.5vw, 2rem);
  outline: none;
}

.search-row input::placeholder {
  color: #7f8692;
}

.search-row button,
.primary-btn {
  border: none;
  border-radius: 28px;
  font-size: clamp(1.35rem, 2.3vw, 2.7rem);
  font-weight: 800;
  color: #000000 !important;
  background: var(--accent);
  cursor: pointer;
  transition: transform 0.2s ease, background-color 0.2s ease;
}

.search-row button:hover,
.primary-btn:hover {
  background: var(--accent-dark);
  transform: translateY(-2px);
}

.primary-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
}

.upload-actions {
  margin-top: 18px;
}

.upload-actions .primary-btn {
  min-width: 220px;
  min-height: 76px;
  padding: 0 26px;
}

.status {
  min-height: 1.5rem;
  color: var(--muted);
  margin: 14px 8px;
}

.results {
  display: grid;
  gap: 16px;
}

.result {
  margin-top: 18px;
  display: grid;
  grid-template-columns: minmax(220px, 340px) 1fr;
  gap: 26px;
  border: 1px solid #2a3344;
  border-radius: 22px;
  background: #0b0f18;
  padding: 24px;
  overflow: hidden;
}

.hidden {
  display: none;
}

.preview-wrap {
  border-radius: 16px;
  overflow: hidden;
  border: 1px solid #2a3445;
  background: #050607;
  aspect-ratio: 16/9;
  align-self: start;
  width: 100%;
  max-width: 100%;
}

.preview-wrap img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center;
  display: block;
}

.meta h2 {
  margin: 0 0 10px;
  font-size: clamp(1.3rem, 2vw, 2rem);
  letter-spacing: -0.01em;
  overflow-wrap: anywhere;
}

.meta p {
  margin: 0 0 8px;
  color: var(--muted);
  overflow-wrap: anywhere;
}

.meta a {
  color: #96dfff;
  text-decoration: none;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.meta {
  min-width: 0;
}

.table-head,
.format-item {
  display: grid;
  grid-template-columns: minmax(90px, 140px) minmax(90px, 140px) minmax(140px, 1fr);
  align-items: center;
  gap: 16px;
}

.table-head {
  margin-top: 20px;
  font-size: 0.9rem;
  color: var(--muted);
}

.table-head span:last-child {
  justify-self: end;
}

.format-list {
  margin-top: 8px;
  display: grid;
  gap: 10px;
}

.format-item {
  padding: 12px;
  border: 1px solid #273142;
  border-radius: 12px;
  background: #111727;
  overflow: hidden;
}

.format-item > span {
  min-width: 0;
  overflow-wrap: anywhere;
}

.transcript-panel {
  margin-top: 22px;
  border-top: 1px solid #273142;
  padding-top: 18px;
}

.transcript-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.transcript-panel h3 {
  margin: 0 0 6px;
  font-size: 1.1rem;
}

.transcript-panel p {
  margin: 0;
  color: var(--muted);
}

.transcript-list {
  margin-top: 12px;
  display: grid;
  gap: 10px;
}

.transcript-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(140px, auto);
  align-items: center;
  gap: 14px;
  padding: 12px;
  border: 1px solid #273142;
  border-radius: 12px;
  background: #101722;
}

.transcript-item strong,
.transcript-item span {
  display: block;
}

.transcript-item strong {
  font-size: 0.98rem;
}

.transcript-item span {
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.88rem;
}

.download-btn {
  justify-self: end;
  border: none;
  border-radius: 10px;
  background: var(--accent);
  color: #000000 !important;
  padding: 10px 16px;
  text-decoration: none;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-width: 148px;
  justify-content: center;
  transition: background-color 0.2s ease, transform 0.2s ease;
}

.download-btn svg {
  stroke: #000000 !important;
  fill: none;
}

.download-btn:hover {
  background: var(--accent-dark);
  transform: translateY(-1px);
}

.download-btn .icon {
  width: 16px;
  height: 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.download-btn .spinner {
  width: 14px;
  height: 14px;
  border: 2px solid rgba(0, 0, 0, 0.28);
  border-top-color: #000000;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  display: none;
}

.download-btn.loading .download-icon {
  display: none;
}

.download-btn.loading .spinner {
  display: inline-block;
}

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

.mode-link.active {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent) inset;
}

.hero-sub {
  margin: -18px 0 0;
  max-width: 640px;
  color: var(--muted);
  font-size: clamp(0.95rem, 1.6vw, 1.15rem);
  font-weight: 500;
}

.dropzone {
  margin-top: 30px;
  border: 2px dashed #2f3a4d;
  border-radius: 22px;
  background: linear-gradient(180deg, #0d1320 0%, #0a0e17 100%);
  cursor: pointer;
  transition: border-color 0.18s ease, background-color 0.18s ease, transform 0.18s ease;
  outline: none;
}

.dropzone:hover,
.dropzone:focus-visible {
  border-color: var(--accent);
}

.dropzone.dragover {
  border-color: var(--accent);
  background: linear-gradient(180deg, #11321a 0%, #0a1a10 100%);
  transform: translateY(-2px);
}

.dropzone-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  text-align: center;
  padding: 48px 24px;
}

.dropzone-icon {
  color: var(--accent);
}

.dropzone-inner strong {
  font-size: 1.3rem;
}

.dropzone-hint {
  color: var(--muted);
  font-size: 0.92rem;
  max-width: 460px;
}

.mdata-results {
  margin-top: 22px;
}

.mdata-toolbar {
  display: grid;
  grid-template-columns: minmax(220px, 360px) 1fr;
  gap: 22px;
  align-items: start;
  margin-bottom: 22px;
}

.mdata-preview {
  border: 1px solid #2a3445;
  border-radius: 16px;
  background: #050607;
  overflow: hidden;
  aspect-ratio: 16 / 9;
  display: flex;
  align-items: center;
  justify-content: center;
}

.mdata-preview img,
.mdata-preview video {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.mdata-preview .audio-badge {
  color: var(--muted);
  font-weight: 700;
  letter-spacing: 0.04em;
}

.mdata-controls {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

#filterInput {
  width: 100%;
  height: 52px;
  border: 2px solid var(--panel-border);
  background: #111622;
  color: var(--text);
  border-radius: 14px;
  padding: 0 18px;
  font-family: inherit;
  font-size: 1rem;
  outline: none;
}

#filterInput:focus {
  border-color: var(--accent);
}

.mdata-toggles {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
}

.switch {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-weight: 700;
  font-size: 0.9rem;
  cursor: pointer;
}

.switch input {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
  cursor: pointer;
}

.ghost-btn {
  border: 1px solid #2a3344;
  background: #0b0f18;
  color: var(--text);
  font-family: inherit;
  font-weight: 700;
  font-size: 0.9rem;
  border-radius: 10px;
  padding: 10px 16px;
  cursor: pointer;
  transition: border-color 0.18s ease, color 0.18s ease;
}

.ghost-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.mdata-export {
  border: 1px solid #2a3344;
  border-radius: 14px;
  background: #0b0f18;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.mdata-export-title {
  font-weight: 800;
  font-size: 0.82rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

.mdata-export-btns {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.export-btn {
  flex: 1 1 160px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  border: 1px solid var(--accent);
  background: rgba(120, 255, 170, 0.08);
  color: var(--accent);
  font-family: inherit;
  font-weight: 800;
  font-size: 0.95rem;
  border-radius: 12px;
  padding: 12px 16px;
  cursor: pointer;
  transition: background 0.18s ease, opacity 0.18s ease;
}

.export-btn small {
  font-weight: 600;
  font-size: 0.74rem;
  opacity: 0.75;
  letter-spacing: 0.02em;
}

.export-btn.alt {
  border-color: #2a3344;
  background: #111622;
  color: var(--text);
}

.export-btn:hover:not(:disabled) {
  background: rgba(120, 255, 170, 0.16);
}

.export-btn.alt:hover:not(:disabled) {
  border-color: var(--accent);
}

.export-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.export-btn.busy {
  opacity: 0.7;
  cursor: progress;
}

.mdata-export-note {
  margin: 0;
  font-size: 0.78rem;
  line-height: 1.45;
  color: var(--muted);
}

.mdata-sections {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.m-card {
  border: 1px solid #2a3344;
  border-radius: 18px;
  background: #0b0f18;
  overflow: hidden;
}

.m-card-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px 18px;
  border-bottom: 1px solid transparent;
  background: #0e1422;
  cursor: pointer;
  user-select: none;
  list-style: none;
}

.m-card-head::-webkit-details-marker {
  display: none;
}

.m-card-head:hover {
  background: #111a2b;
}

.m-card[open] > .m-card-head {
  border-bottom-color: #1c2433;
}

.m-caret {
  margin-left: auto;
  flex: none;
  width: 9px;
  height: 9px;
  border-right: 2px solid var(--muted);
  border-bottom: 2px solid var(--muted);
  transform: rotate(-45deg);
  transition: transform 0.18s ease;
}

.m-card[open] > .m-card-head .m-caret {
  transform: rotate(45deg);
}

.m-card-head h3 {
  margin: 0;
  font-size: 1.05rem;
  letter-spacing: -0.01em;
}

.m-chip {
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 4px 9px;
  border-radius: 999px;
  background: rgba(92, 227, 90, 0.14);
  color: var(--accent);
}

.m-chip.audio {
  background: rgba(150, 223, 255, 0.14);
  color: #96dfff;
}

.m-chip.subtitle {
  background: rgba(255, 196, 120, 0.16);
  color: #ffc478;
}

.m-chip.data,
.m-chip.attachment {
  background: rgba(180, 180, 200, 0.16);
  color: #c7cbe0;
}

.m-rows {
  display: grid;
}

.m-row {
  display: grid;
  grid-template-columns: minmax(120px, 0.9fr) 1.4fr;
  gap: 14px;
  padding: 11px 18px;
  border-top: 1px solid #141b28;
}

.m-row:first-child {
  border-top: none;
}

.m-key {
  min-width: 0;
}

.m-label {
  display: block;
  font-weight: 700;
  font-size: 0.92rem;
  color: #d7dbe3;
}

.m-desc {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.35;
}

body.explain-off .m-desc {
  display: none;
}

.m-val {
  min-width: 0;
  display: flex;
  align-items: flex-start;
  gap: 8px;
  font-size: 0.95rem;
  overflow-wrap: anywhere;
}

.m-val .m-val-text {
  flex: 1;
  min-width: 0;
}

.m-val a {
  color: var(--accent);
  text-decoration: none;
  border-bottom: 1px solid rgba(92, 227, 90, 0.35);
}

.m-val a:hover {
  border-bottom-color: var(--accent);
}

.m-copy {
  flex: none;
  border: none;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  padding: 2px;
  border-radius: 6px;
  line-height: 0;
  opacity: 0;
  transition: opacity 0.15s ease, color 0.15s ease;
}

.m-row:hover .m-copy {
  opacity: 1;
}

.m-copy:hover {
  color: var(--accent);
}

.m-copy.copied {
  color: var(--accent);
  opacity: 1;
}

.m-empty {
  color: var(--muted);
  padding: 14px 18px;
}

.m-card.full {
  grid-column: 1 / -1;
}

.m-raw {
  margin: 0;
  padding: 16px 18px;
  max-height: 420px;
  overflow: auto;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.82rem;
  color: #b9c2d0;
  white-space: pre;
}

.m-details {
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.m-details > summary {
  cursor: pointer;
  list-style: none;
  padding: 12px 18px;
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--accent);
  user-select: none;
  transition: background 0.15s ease;
}

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

.m-details > summary::before {
  content: "+ ";
  font-weight: 700;
}

.m-details[open] > summary::before {
  content: "\2212 ";
}

.m-details > summary:hover {
  background: rgba(92, 227, 90, 0.08);
}

.m-details .m-rows {
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}

@media (max-width: 980px) {
  .mdata-toolbar {
    grid-template-columns: 1fr;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .search-row {
    grid-template-columns: 1fr;
  }

  .search-row button {
    height: 88px;
  }

  .result {
    grid-template-columns: 1fr;
  }

  .table-head,
  .format-item {
    grid-template-columns: 1fr 1fr;
    gap: 10px;
  }

  .download-btn {
    justify-self: start;
    grid-column: 1 / span 2;
  }
}

@media (max-width: 640px) {
  .page {
    width: min(1150px, 94vw);
    padding-top: 22px;
  }

  .mode-nav {
    width: 100%;
    display: grid;
    grid-template-columns: 1fr;
  }

  .mode-link {
    width: 100%;
    justify-content: center;
  }

  .result {
    padding: 14px;
    border-radius: 16px;
    gap: 14px;
  }

  .table-head,
  .format-item {
    grid-template-columns: 1fr;
  }

  .download-btn {
    grid-column: auto;
    width: 100%;
  }

  .transcript-item {
    grid-template-columns: 1fr;
  }
}
