/* ShareMe styles. No inline styles are used anywhere, so a strict Content-Security-Policy works.
   Blue and cyan accent. Every control has a visible border or fill, in both themes. */

:root {
  color-scheme: light dark;
  --bg: #eef3ff;
  --glow-a: rgba(37, 99, 235, 0.22);
  --glow-b: rgba(6, 182, 212, 0.18);
  --surface: #ffffff;
  --surface-2: #e9effc;
  --field: #f7f9ff;
  --field-border: #7d8bb0;
  --ink: #0f172a;
  --muted: #475569;
  --line: #d3dcf0;
  --line-strong: #a3b1d1;
  --accent: #1d4ed8;
  --accent-2: #0891b2;
  --on-accent: #ffffff;
  --btn-top: #2f6df6;
  --btn-bottom: #1d4ed8;
  --btn-ink: #ffffff;
  --btn-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.28), 0 8px 18px -8px rgba(37, 99, 235, 0.65);
  --ring: rgba(29, 78, 216, 0.35);
  --tint: rgba(29, 78, 216, 0.12);
  --knob: #ffffff;
  --ok: #047857;
  --err: #c81e1e;
  --warn: #92400e;
  --warn-bg: #fef3c7;
  --warn-line: #f2d98a;
  --shadow: 0 1px 2px rgba(15, 23, 42, 0.06), 0 14px 30px -16px rgba(30, 64, 175, 0.35);
  --radius: 16px;
  --radius-sm: 12px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
}
:root[data-theme="light"] { color-scheme: light; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0a0f1f;
    --glow-a: rgba(59, 130, 246, 0.3);
    --glow-b: rgba(34, 211, 238, 0.16);
    --surface: #131a2d;
    --surface-2: #1e2845;
    --field: #0b1122;
    --field-border: #6272a0;
    --ink: #f1f5ff;
    --muted: #aab5d2;
    --line: #27314f;
    --line-strong: #44527f;
    --accent: #60a5fa;
    --accent-2: #22d3ee;
    --on-accent: #08111f;
    --btn-top: #2f6df6;
    --btn-bottom: #1d4ed8;
    --btn-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.22), 0 8px 20px -8px rgba(59, 130, 246, 0.7);
    --ring: rgba(96, 165, 250, 0.45);
    --tint: rgba(96, 165, 250, 0.16);
    --ok: #34d399;
    --err: #f87171;
    --warn: #fcd34d;
    --warn-bg: #33290f;
    --warn-line: #5c4a14;
    --shadow: 0 1px 0 rgba(255, 255, 255, 0.05) inset, 0 16px 36px -18px rgba(0, 0, 0, 0.85);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0a0f1f;
  --glow-a: rgba(59, 130, 246, 0.3);
  --glow-b: rgba(34, 211, 238, 0.16);
  --surface: #131a2d;
  --surface-2: #1e2845;
  --field: #0b1122;
  --field-border: #6272a0;
  --ink: #f1f5ff;
  --muted: #aab5d2;
  --line: #27314f;
  --line-strong: #44527f;
  --accent: #60a5fa;
  --accent-2: #22d3ee;
  --on-accent: #08111f;
  --btn-top: #2f6df6;
  --btn-bottom: #1d4ed8;
  --btn-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.22), 0 8px 20px -8px rgba(59, 130, 246, 0.7);
  --ring: rgba(96, 165, 250, 0.45);
  --tint: rgba(96, 165, 250, 0.16);
  --ok: #34d399;
  --err: #f87171;
  --warn: #fcd34d;
  --warn-bg: #33290f;
  --warn-line: #5c4a14;
  --shadow: 0 1px 0 rgba(255, 255, 255, 0.05) inset, 0 16px 36px -18px rgba(0, 0, 0, 0.85);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  background-color: var(--bg);
  background-image:
    radial-gradient(60rem 28rem at 20% -8rem, var(--glow-a), transparent 70%),
    radial-gradient(44rem 22rem at 100% -4rem, var(--glow-b), transparent 70%);
  background-repeat: no-repeat;
  color: var(--ink);
  font: 16px/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
}
[hidden] { display: none !important; }
h1, h2, h3, p { margin: 0; }
.sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.muted { color: var(--muted); font-size: 0.9rem; }
svg.i { width: 18px; height: 18px; flex: none; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* ---- top bar ---- */
.topbar { position: sticky; top: 0; z-index: 20; padding-top: env(safe-area-inset-top); background: var(--surface); border-bottom: 1.5px solid var(--line-strong); }
@supports (background: color-mix(in srgb, red 50%, blue)) {
  .topbar { background: color-mix(in srgb, var(--surface) 88%, transparent); -webkit-backdrop-filter: saturate(1.4) blur(14px); backdrop-filter: saturate(1.4) blur(14px); }
}
.topbar__inner { max-width: 720px; margin: 0 auto; padding: 10px 16px; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 10px; color: inherit; text-decoration: none; font-weight: 800; font-size: 1.15rem; letter-spacing: -0.02em; margin-right: auto; }
.brand img { width: 30px; height: 30px; border-radius: 9px; display: block; }
.topbar__tools { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-left: auto; }
@media (max-width: 560px) {
  .theme { order: 1; }
  .topbar__tools { order: 2; flex: 1 1 100%; margin-left: 0; flex-wrap: nowrap; }
  .topbar__tools .input--chip { flex: 1 1 auto; max-width: none; min-width: 0; }
}

/* ---- theme switch and tabs: the selected one is solid colour ---- */
.theme, .tabs { display: inline-flex; padding: 3px; gap: 2px; border: 1.5px solid var(--line-strong); border-radius: 12px; background: var(--surface-2); }
.theme button, .tabs button { border: 0; background: transparent; color: var(--muted); font: inherit; cursor: pointer; border-radius: 9px; transition: background 0.15s, color 0.15s; }
.theme button { padding: 8px 10px; line-height: 0; }
.tabs button { font-weight: 700; font-size: 0.9rem; padding: 9px 16px; }
.theme button:hover, .tabs button:hover { color: var(--ink); }
.theme button[aria-checked="true"], .tabs button[aria-selected="true"] { background: var(--accent); color: var(--on-accent); box-shadow: 0 2px 6px -2px var(--accent); }
.theme button:focus-visible, .tabs button:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--ring); }
.theme svg.i { width: 18px; height: 18px; }

/* ---- layout ---- */
main { max-width: 720px; margin: 0 auto; padding: 26px 16px calc(40px + env(safe-area-inset-bottom)); }
.hero { margin-bottom: 20px; }
.hero h1 { font-size: clamp(1.8rem, 6vw, 2.5rem); line-height: 1.1; letter-spacing: -0.03em; font-weight: 800; }
.grad { background: linear-gradient(100deg, var(--accent), var(--accent-2)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.hero p { margin-top: 10px; color: var(--muted); max-width: 52ch; }
.card { background: var(--surface); border: 1.5px solid var(--line-strong); border-radius: var(--radius); box-shadow: var(--shadow); }

/* ---- composer ---- */
.composer { padding: 16px; }
.label, .field > label { display: block; font-size: 0.82rem; font-weight: 700; color: var(--ink); margin-bottom: 6px; }
.field > label { margin-bottom: 0; }
.composer__text { display: block; width: 100%; min-height: 9.5rem; resize: vertical; font: inherit; color: var(--ink); background: var(--field); border: 1.5px solid var(--field-border); border-radius: var(--radius-sm); padding: 14px; transition: border-color 0.15s, box-shadow 0.15s; }
.composer__text::placeholder, .input::placeholder { color: var(--muted); opacity: 0.85; }
.composer__text:focus, .input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--ring); }
.composer__bar { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 12px; flex-wrap: wrap; }
.composer__side { display: flex; gap: 10px; }
@media (max-width: 520px) {
  .composer__bar { flex-direction: column-reverse; align-items: stretch; }
  .composer__side .btn { flex: 1; }
  .composer__bar .btn--primary { width: 100%; padding: 14px 16px; font-size: 1rem; }
}

/* ---- buttons: always a visible shape ---- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px;
  font: inherit; font-weight: 700; font-size: 0.95rem; line-height: 1;
  padding: 11px 18px; border-radius: 12px;
  border: 1.5px solid var(--line-strong); background: var(--surface-2); color: var(--ink);
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.1);
  cursor: pointer; text-decoration: none; white-space: nowrap;
  transition: transform 0.08s, background 0.15s, border-color 0.15s, box-shadow 0.15s, filter 0.15s;
}
.btn:hover { border-color: var(--accent); }
.btn:active { transform: scale(0.98); }
.btn:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--ring); }
.btn:disabled { opacity: 0.55; cursor: default; transform: none; }
.btn--primary { border-color: transparent; color: var(--btn-ink); background: linear-gradient(180deg, var(--btn-top), var(--btn-bottom)); box-shadow: var(--btn-shadow); }
.btn--primary:hover { border-color: transparent; filter: brightness(1.08); }
.btn--sm { min-height: 38px; padding: 8px 14px; font-size: 0.88rem; border-radius: 10px; }
.btn--icon { min-width: 44px; padding: 10px; }
.btn--danger { color: var(--err); }
.btn--danger:hover { border-color: var(--err); }
.btn--danger.is-armed { background: var(--err); border-color: var(--err); color: #fff; }
.btn--accent { border-color: var(--accent); color: var(--accent); }
.spin { display: none; width: 16px; height: 16px; border-radius: 50%; border: 2px solid currentColor; border-right-color: transparent; animation: spin 0.7s linear infinite; }
.btn.is-busy .spin { display: inline-block; }
.btn.is-busy svg.i { display: none; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---- form fields: always a visible box ---- */
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.input {
  width: 100%; min-height: 46px; font: inherit; color: var(--ink); background: var(--field);
  border: 1.5px solid var(--field-border); border-radius: var(--radius-sm); padding: 11px 13px;
  transition: border-color 0.15s, box-shadow 0.15s;
}
textarea.input { resize: vertical; line-height: 1.45; }
select.input {
  appearance: none; -webkit-appearance: none; padding-right: 38px; cursor: pointer;
  background-repeat: no-repeat; background-position: right 13px center; background-size: 15px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
}
.input--chip { width: auto; min-height: 40px; max-width: 170px; padding: 8px 34px 8px 12px; font-size: 0.9rem; font-weight: 700; border-radius: 10px; background-color: var(--surface-2); border-color: var(--line-strong); }
.grid { display: grid; grid-template-columns: 1fr; gap: 14px; }
@media (min-width: 560px) { .grid { grid-template-columns: 1fr 1fr; } .span-2 { grid-column: 1 / -1; } }
.inline { display: flex; gap: 8px; }
.inline .input { flex: 1 1 auto; min-width: 0; }
.pick { margin-top: 8px; }

.switch { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; font-size: 0.95rem; font-weight: 600; color: var(--ink); user-select: none; width: fit-content; min-height: 32px; }
.switch input {
  appearance: none; -webkit-appearance: none; margin: 0; flex: none; position: relative; cursor: pointer;
  width: 44px; height: 26px; border-radius: 999px; background: var(--line-strong); transition: background 0.2s;
}
.switch input::before { content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: var(--knob); box-shadow: 0 1px 3px rgba(0, 0, 0, 0.35); transition: transform 0.2s; }
.switch input:checked { background: linear-gradient(180deg, var(--btn-top), var(--btn-bottom)); }
.switch input:checked::before { transform: translateX(18px); }
.switch input:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--ring); }

/* ---- status ---- */
.status { display: flex; align-items: center; gap: 8px; margin: 14px 2px 0; font-size: 0.92rem; font-weight: 500; color: var(--muted); }
.status.is-empty { display: none; }
.status--ok { color: var(--ok); }
.status--err { color: var(--err); }
.status--busy { color: var(--accent); }
.status svg.i, .status .spin { width: 16px; height: 16px; flex: none; }
.status .spin { display: inline-block; }

/* ---- results ---- */
.results { display: grid; gap: 16px; margin-top: 18px; }
.results:empty { display: none; }
.result { padding: 20px 18px 18px; scroll-margin-top: 76px; animation: rise 0.28s cubic-bezier(0.2, 0.8, 0.2, 1) both; background: linear-gradient(90deg, var(--accent), var(--accent-2)) top / 100% 5px no-repeat, var(--surface); }
.result:nth-child(2) { animation-delay: 0.06s; }
.result:nth-child(3) { animation-delay: 0.12s; }
@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
.result__head { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; }
.result__head h2 { font-size: 1.1rem; letter-spacing: -0.01em; }
.result__head p { font-size: 0.85rem; color: var(--muted); }
.badge { width: 42px; height: 42px; flex: none; border-radius: 12px; display: grid; place-items: center; color: var(--accent); background: var(--tint); }
.note { display: flex; gap: 8px; align-items: flex-start; background: var(--warn-bg); color: var(--warn); border: 1.5px solid var(--warn-line); border-radius: var(--radius-sm); padding: 10px 12px; font-size: 0.88rem; font-weight: 500; margin-top: 14px; }
.note svg.i { width: 16px; height: 16px; margin-top: 2px; }
.actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-top: 18px; }
.actions .btn--primary { flex: 1 1 auto; }
.openin { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 14px; font-size: 0.88rem; font-weight: 600; color: var(--muted); }

/* ---- empty state ---- */
.steps { display: grid; gap: 12px; margin-top: 24px; grid-template-columns: 1fr; }
@media (min-width: 640px) { .steps { grid-template-columns: repeat(3, 1fr); } }
.step { padding: 16px; border-radius: var(--radius); border: 1.5px solid var(--line-strong); background: var(--surface); }
.step__n, .how li::before { width: 28px; height: 28px; flex: none; border-radius: 50%; display: grid; place-items: center; font-size: 0.85rem; font-weight: 800; color: var(--on-accent); background: var(--accent); }
.step__n { margin-bottom: 10px; }
.step h3 { font-size: 1rem; }
.step p { font-size: 0.88rem; color: var(--muted); margin-top: 4px; }
.foot { display: flex; gap: 8px; align-items: center; justify-content: center; color: var(--muted); font-size: 0.82rem; margin-top: 30px; text-align: center; }
.foot svg.i { width: 14px; height: 14px; }

/* ---- settings sheet ---- */
dialog.sheet {
  border: 1.5px solid var(--line-strong); border-radius: 22px; background: var(--surface); color: var(--ink);
  width: min(580px, calc(100vw - 24px)); max-height: min(88vh, 820px); max-height: min(88dvh, 820px);
  padding: 20px; overflow: auto; box-shadow: 0 30px 80px -20px rgba(0, 0, 0, 0.55);
}
dialog.sheet[open] { animation: pop 0.22s cubic-bezier(0.2, 0.8, 0.2, 1); }
dialog.sheet::backdrop { background: rgba(5, 10, 25, 0.6); -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px); }
@keyframes pop { from { opacity: 0; transform: translateY(12px) scale(0.98); } to { opacity: 1; transform: none; } }
@media (max-width: 600px) {
  dialog.sheet { margin: auto 0 0; width: 100%; max-width: none; border-radius: 22px 22px 0 0; max-height: 90vh; max-height: 90dvh; padding-bottom: calc(20px + env(safe-area-inset-bottom)); }
}
.sheet__head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 6px; }
.sheet__head h2 { font-size: 1.25rem; letter-spacing: -0.02em; }
.eplist { display: grid; gap: 10px; margin: 14px 0; }
.ep { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 12px; border: 1.5px solid var(--line-strong); border-radius: 14px; background: var(--surface-2); }
.ep__name { flex: 1 1 180px; min-width: 0; font-weight: 700; overflow-wrap: anywhere; }
.ep__name small { display: block; font-weight: 500; color: var(--muted); font-size: 0.82rem; }
.ep__actions { display: flex; gap: 6px; flex-wrap: wrap; }
.pill { font-size: 0.68rem; font-weight: 800; letter-spacing: 0.05em; text-transform: uppercase; padding: 3px 8px; border-radius: 999px; color: var(--on-accent); background: var(--accent); margin-left: 6px; vertical-align: 1px; }
.form { border-top: 1.5px solid var(--line); padding-top: 16px; margin-top: 6px; }
.form h3 { font-size: 1rem; margin-bottom: 12px; }

/* ---- setup guide ---- */
.setup { padding: 20px; margin-top: 26px; }
.setup__head { display: flex; flex-wrap: wrap; gap: 12px; justify-content: space-between; align-items: flex-start; margin-bottom: 14px; }
.setup__head h2 { font-size: 1.15rem; letter-spacing: -0.01em; }
.setup__head .muted { margin-top: 4px; max-width: 46ch; }
.setup__why { margin-bottom: 16px; }
.how { list-style: none; counter-reset: step; margin: 0; padding: 0; display: grid; gap: 16px; }
.how li { counter-increment: step; display: flex; gap: 14px; align-items: flex-start; }
.how li::before { content: counter(step); margin-top: 1px; }
.how strong { display: block; font-size: 1rem; }
.how p { margin-top: 3px; font-size: 0.92rem; line-height: 1.55; color: var(--muted); }
.how b { color: var(--ink); font-weight: 700; }
.codechip { display: flex; align-items: center; gap: 8px; margin-top: 10px; padding: 8px 8px 8px 12px; background: var(--field); border: 1.5px solid var(--field-border); border-radius: var(--radius-sm); }
.codechip .muted { flex: 1; min-width: 0; }
.codechip code { flex: 1; min-width: 0; overflow-wrap: anywhere; font: 0.85rem ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; color: var(--ink); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; scroll-behavior: auto !important; }
}

/* ---- images ---- */
.composer__side { flex-wrap: wrap; }
.composer.is-drop { border-color: var(--accent); box-shadow: 0 0 0 4px var(--ring), var(--shadow); }
.attach { display: flex; align-items: center; gap: 12px; margin-top: 12px; padding: 10px; border: 1.5px solid var(--line-strong); border-radius: var(--radius-sm); background: var(--surface-2); }
.attach__thumb { width: 56px; height: 56px; flex: none; object-fit: cover; border-radius: 8px; border: 1.5px solid var(--line-strong); background: var(--field); }
.attach__meta { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.attach__meta strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hint { margin-top: 2px; font-size: 0.84rem; }
.ocrtext { margin-top: 14px; padding: 10px 14px; border: 1.5px solid var(--line-strong); border-radius: var(--radius-sm); background: var(--surface); }
.ocrtext summary { cursor: pointer; font-weight: 700; }
.ocrtext pre { margin: 10px 0 0; max-height: 14rem; overflow: auto; white-space: pre-wrap; overflow-wrap: anywhere; font: 0.85rem/1.5 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; color: var(--muted); }
