:root {
  color-scheme: light;
  --page-bg: #f4f7f5;
  --panel-bg: #ffffff;
  --panel-subtle: #fafcfb;
  --preview-bg: #eef3ef;
  --text: #17202a;
  --muted: #5d6b62;
  --muted-strong: #68776d;
  --primary: #203a2d;
  --primary-text: #ffffff;
  --accent: #3f7658;
  --eyebrow: #4b8063;
  --border: #dce5de;
  --border-strong: #b8c7bd;
  --secondary-bg: #e6efe9;
  --secondary-border: #c8d8ce;
  --secondary-text: #203a2d;
  --danger: #b42318;
  --shadow: rgba(22, 34, 28, 0.08);
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --page-bg: #101512;
  --panel-bg: #18201b;
  --panel-subtle: #1d2721;
  --preview-bg: #111713;
  --text: #eef5f0;
  --muted: #a8b7ad;
  --muted-strong: #9baca1;
  --primary: #88c9a2;
  --primary-text: #102117;
  --accent: #91d2aa;
  --eyebrow: #87cba1;
  --border: #34443a;
  --border-strong: #51665a;
  --secondary-bg: #26372d;
  --secondary-border: #42584a;
  --secondary-text: #dcebe1;
  --danger: #ff958d;
  --shadow: rgba(0, 0, 0, 0.3);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text);
  background: var(--page-bg);
  transition: background-color 160ms ease, color 160ms ease;
}

.shell {
  width: min(920px, calc(100% - 32px));
  margin: 0 auto;
  padding: 56px 0;
}

.panel {
  position: relative;
  background: var(--panel-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 28px;
  box-shadow: 0 18px 55px var(--shadow);
}

.theme-switcher {
  display: flex;
  justify-content: flex-end;
  gap: 4px;
  margin-bottom: 22px;
}

.theme-switcher button {
  min-height: 32px;
  border: 1px solid var(--border);
  padding: 0 10px;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.theme-switcher button[aria-pressed="true"] {
  border-color: var(--secondary-border);
  background: var(--secondary-bg);
  color: var(--secondary-text);
}

.heading { margin-bottom: 26px; }

.eyebrow {
  margin: 0 0 8px;
  color: var(--eyebrow);
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
}

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

.help-text {
  margin: -4px 0 18px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
}

.resolver label {
  display: block;
  margin-bottom: 8px;
  font-size: 14px;
  font-weight: 700;
}

.input-row {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 10px;
}

.url-field {
  position: relative;
  min-width: 0;
}

input {
  width: 100%;
  min-height: 46px;
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  padding: 0 48px 0 14px;
  font-size: 15px;
  background: var(--panel-bg);
  color: var(--text);
}

.clear-url {
  position: absolute;
  top: 1px;
  right: 1px;
  width: 44px;
  min-height: 44px;
  padding: 0;
  border-radius: 0 5px 5px 0;
  background: transparent;
  color: var(--muted-strong);
  font-size: 24px;
  line-height: 1;
}

.clear-url:hover,
.clear-url:focus-visible {
  background: var(--preview-bg);
  color: var(--primary);
}

.clear-url[hidden] { display: none; }

button {
  min-height: 46px;
  border: 0;
  border-radius: 6px;
  padding: 0 18px;
  background: var(--primary);
  color: var(--primary-text);
  font-weight: 800;
  cursor: pointer;
}

button:disabled { opacity: 0.58; cursor: wait; }

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

.status {
  min-height: 24px;
  margin-top: 18px;
  color: var(--muted);
  font-size: 14px;
}

.status.error { color: var(--danger); }

.link-kind {
  min-height: 21px;
  margin-top: 8px;
  color: var(--muted-strong);
  font-size: 13px;
}

.link-kind.valid { color: var(--accent); font-weight: 700; }
.link-kind.invalid { color: var(--danger); }

.result { margin-top: 20px; }

.result-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  border-top: 1px solid var(--border);
  padding-top: 20px;
}

.shortcode {
  margin: 0;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 14px;
  color: var(--text);
}

.result-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 5px;
}

.kind-badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 999px;
  padding: 0 9px;
  background: var(--secondary-bg);
  color: var(--secondary-text);
  font-size: 12px;
  font-weight: 800;
}

a { color: var(--accent); font-weight: 700; }

.media-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 12px;
  margin-top: 18px;
}

.media-card {
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  background: var(--panel-subtle);
}

.media-card img,
.media-card video {
  display: block;
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  background: var(--preview-bg);
}

.media-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  border-top: 1px solid var(--border);
}

.media-actions a {
  display: block;
  padding: 10px;
  font-size: 13px;
  text-align: center;
  text-decoration: none;
}

.media-actions a + a { border-left: 1px solid var(--border); }

@media (max-width: 640px) {
  .shell { width: min(100% - 20px, 920px); padding: 20px 0; }
  .panel { padding: 18px; }
  .theme-switcher { justify-content: stretch; }
  .theme-switcher button { flex: 1; padding: 0 6px; }
  .input-row { grid-template-columns: 1fr; }
  #paste-url { order: 2; }
  #resolve-button { order: 3; }
  .result-head { align-items: stretch; flex-direction: column; }
}
