:root {
  color-scheme: light;
  --bg: #eef2f5;
  --panel: #ffffff;
  --panel-2: #f7f9fb;
  --text: #17202a;
  --muted: #647181;
  --line: #c9d3df;
  --accent: #0b7f7a;
  --accent-strong: #055f5b;
  --danger: #b42318;
  --shadow: 0 18px 44px rgba(33, 47, 62, 0.14);
  --radius: 8px;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body {
  min-height: 100%;
  margin: 0;
}

body {
  color: var(--text);
  background:
    linear-gradient(180deg, rgba(11, 127, 122, 0.1), transparent 300px),
    var(--bg);
}

button {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 14px;
  color: var(--text);
  background: #ffffff;
  font: 650 14px/1 var(--font, inherit);
  cursor: pointer;
}

button:hover:not(:disabled) {
  border-color: var(--accent);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.48;
}

.primary-button {
  color: #ffffff;
  border-color: var(--accent);
  background: var(--accent);
}

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

.app-shell {
  width: min(1180px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 20px 0 30px;
}

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

.brand {
  margin: 0 0 7px;
  color: var(--accent);
  font-size: 14px;
  font-weight: 850;
}

h1 {
  margin: 0;
  font-size: clamp(30px, 4vw, 48px);
  line-height: 1.05;
  letter-spacing: 0;
}

.topbar p {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 16px;
}

.topbar-actions,
.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 0.95fr);
  gap: 16px;
}

.panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: var(--shadow);
}

.panel-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 48px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  font-size: 15px;
  font-weight: 760;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 24px;
  border-radius: 999px;
  padding: 0 9px;
  font-size: 12px;
  font-weight: 700;
}

.status-pill.idle {
  color: #4d5966;
  background: #ecf0f3;
}

.status-pill.ok {
  color: #0f5f3a;
  background: #dbf5e7;
}

.status-pill.warn {
  color: #7a4c00;
  background: #fff1c7;
}

.status-pill.error {
  color: #8f1f14;
  background: #ffe0dc;
}

.video-frame,
.meme-frame {
  position: relative;
  display: grid;
  place-items: center;
  overflow: hidden;
  background: #101820;
}

.video-frame {
  aspect-ratio: 4 / 3;
}

.video-frame video {
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center center;
  transform: scaleX(-1);
}

.video-placeholder,
.meme-empty {
  position: absolute;
  inset: 0;
  z-index: 1;
  display: flex;
  flex-direction: column;
  gap: 16px;
  align-items: center;
  justify-content: center;
  padding: 24px;
  color: #cdd7df;
  text-align: center;
  font-size: 17px;
  font-weight: 760;
}

.video-start-button {
  min-width: 160px;
}

.permission-help {
  margin: 10px 12px 0;
  border: 1px solid #f0a9a2;
  border-radius: 8px;
  padding: 12px;
  color: #69190f;
  background: #fff0ed;
}

.permission-help strong {
  color: #69190f;
  font-size: 14px;
}

.permission-help p {
  margin: 6px 0 0;
  font-size: 14px;
  line-height: 1.55;
}

.meme-frame {
  min-height: 476px;
  background:
    linear-gradient(45deg, #f5f7f9 25%, transparent 25%),
    linear-gradient(-45deg, #f5f7f9 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #f5f7f9 75%),
    linear-gradient(-45deg, transparent 75%, #f5f7f9 75%),
    #ffffff;
  background-position:
    0 0,
    0 10px,
    10px -10px,
    -10px 0;
  background-size: 20px 20px;
}

.meme-frame img {
  width: 100%;
  max-height: 476px;
  object-fit: contain;
  background: #ffffff;
}

.meme-empty {
  color: var(--muted);
}

.gesture-strip,
.debug-readout,
.meme-meta {
  display: grid;
  gap: 1px;
  border-top: 1px solid var(--line);
  background: var(--line);
}

.gesture-strip {
  grid-template-columns: auto 1fr;
  align-items: center;
  padding: 14px;
  background: var(--panel-2);
}

.gesture-strip span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 760;
}

.gesture-strip strong {
  justify-self: end;
  color: var(--accent-strong);
  font-size: 18px;
}

.debug-readout {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.meme-meta {
  grid-template-columns: 1fr 1fr;
}

.debug-readout > div,
.meme-meta > div {
  min-width: 0;
  padding: 12px;
  background: var(--panel-2);
}

.label {
  display: block;
  margin-bottom: 5px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 680;
}

strong {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--text);
  font-size: 15px;
  line-height: 1.25;
  white-space: nowrap;
}

.button-row {
  padding: 12px 14px 14px;
}

.share-button {
  color: #ffffff;
  border-color: var(--accent);
  background: var(--accent);
}

.share-button:hover:not(:disabled) {
  background: var(--accent-strong);
}

.log-panel {
  margin-top: 16px;
  overflow: hidden;
}

.log-panel summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 48px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
  font-size: 14px;
  font-weight: 760;
  list-style: none;
}

.log-panel summary::-webkit-details-marker {
  display: none;
}

.summary-hint {
  color: var(--muted);
  font-size: 12px;
  font-weight: 680;
}

.log-actions {
  display: flex;
  justify-content: flex-end;
  padding: 10px 14px 0;
}

.event-log {
  max-height: 168px;
  margin: 0;
  padding: 10px 14px 14px 38px;
  overflow: auto;
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 12px;
  line-height: 1.55;
}

.event-log li + li {
  margin-top: 4px;
}

.seo-content {
  display: grid;
  gap: 22px;
  margin: 30px 0 0;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.7;
}

.seo-content h2 {
  margin: 0 0 8px;
  color: var(--text);
  font-size: 22px;
  line-height: 1.25;
}

.seo-content p {
  max-width: 820px;
  margin: 0;
}

.faq-section {
  display: grid;
  gap: 0;
}

.faq-item {
  max-width: 860px;
  border-top: 1px solid var(--line);
  padding: 14px 0;
}

.faq-item:last-child {
  border-bottom: 1px solid var(--line);
}

.faq-item summary {
  cursor: pointer;
  color: var(--text);
  font-weight: 760;
}

.faq-item p {
  margin-top: 10px;
}

@media (max-width: 860px) {
  .app-shell {
    width: min(100vw - 20px, 680px);
    padding-top: 12px;
  }

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

  .topbar-actions {
    justify-content: stretch;
  }

  .topbar-actions button,
  .button-row button {
    flex: 1 1 0;
  }

  .button-row .share-button {
    flex-basis: 100%;
    order: -1;
  }

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

  .meme-frame {
    min-height: 320px;
  }

  .debug-readout,
  .meme-meta {
    grid-template-columns: 1fr;
  }
}

@media (min-width: 861px) and (max-width: 1120px) {
  .debug-readout {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}
