:root {
  --ink: #1b1b1f;
  --muted: #5d6270;
  --accent: #2b6cff;
  --panel: #ffffff;
  --bg: #f4f5f8;
  --line: #d8dbe3;
  --error: #b3261e;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --ink: #eceef4;
    --muted: #a3a9b8;
    --accent: #7ea8ff;
    --panel: #1b1e27;
    --bg: #0f1117;
    --line: #303544;
    --error: #ff8a80;
  }
}

:root[data-theme="dark"] {
  --ink: #eceef4;
  --muted: #a3a9b8;
  --accent: #7ea8ff;
  --panel: #1b1e27;
  --bg: #0f1117;
  --line: #303544;
  --error: #ff8a80;
}

html, body { background: var(--bg); }

body {
  margin: 0;
  color: var(--ink);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif;
}

.top, main, footer {
  max-width: 880px;
  margin: 0 auto;
  padding: 0 16px;
  box-sizing: border-box;
}

.top { padding-top: 32px; }
.top h1 { margin: 0 0 4px; font-size: 32px; }
.top p, footer p, .muted { color: var(--muted); margin: 0; }

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 16px;
  margin: 16px 0;
}

label { display: block; font-weight: 600; margin-bottom: 6px; }

input[type="url"] {
  width: 100%;
  box-sizing: border-box;
  padding: 10px 12px;
  font: inherit;     /* 16px minimum avoids iOS zoom on focus */
  color: var(--ink);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 8px;
}

fieldset.era { border: 0; padding: 0; margin: 16px 0; }
fieldset.era legend { font-weight: 600; margin-bottom: 6px; padding: 0; }

.segmented {
  position: relative;
  display: inline-flex;
  border: 1px solid var(--line);
  border-radius: 999px;
  overflow: hidden;
}
.segmented input[type="radio"] {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}
.segmented label {
  margin: 0;
  padding: 8px 18px;
  cursor: pointer;
  font-weight: 500;
}
.segmented input:checked + label { background: var(--accent); color: #fff; }
.segmented input:focus-visible + label { outline: 2px solid var(--accent); outline-offset: -2px; }

button {
  font: inherit;
  font-weight: 600;
  color: #fff;
  background: var(--accent);
  border: 0;
  border-radius: 8px;
  padding: 10px 18px;
  cursor: pointer;
}
button:focus-visible, a:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

form button[type="submit"] { margin-top: 4px; }

.error { color: var(--error); margin: 12px 0 0; }

.result-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
  justify-content: space-between;
  align-items: center;
}
.result-bar > span { word-break: break-all; font-weight: 600; }
.result-actions { display: flex; gap: 12px; align-items: center; }
.result-actions a { color: var(--accent); }

#share-status { margin: 8px 0; min-height: 1.5em; word-break: break-all; }

.frame-wrap { position: relative; }
#loading { margin: 8px 0; }

iframe {
  display: block;
  width: 100%;
  height: 70vh;
  min-height: 420px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

@media (max-width: 600px) {
  .top h1 { font-size: 26px; }
  .result-bar { flex-direction: column; align-items: flex-start; }
  iframe { min-height: 360px; }
}
