:root {
  color-scheme: light;
  --bg: #f3f0e8;
  --card: #fffcf7;
  --ink: #1c1915;
  --muted: #5c564e;
  --line: #e3dcd0;
  --accent: #1b6b4a;
  --accent-ink: #f4fff8;
  --danger: #8d2f2f;
  --danger-bg: #fdecec;
  --shadow: 0 1px 0 rgba(28, 25, 21, 0.04);
}

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --bg: #141311;
    --card: #211e1a;
    --ink: #f4efe6;
    --muted: #b7aea3;
    --line: #3a342c;
    --accent: #3dae78;
    --accent-ink: #062016;
    --danger: #ffb4b4;
    --danger-bg: #3a2222;
    --shadow: none;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(900px 280px at 50% -80px, rgba(255, 255, 255, 0.7), transparent 60%),
    var(--bg);
  color: var(--ink);
  font-family: "Avenir Next", "PingFang SC", "Hiragino Sans GB", "Noto Sans SC", "Microsoft YaHei", sans-serif;
  font-size: 16px;
  line-height: 1.5;
}

.wrap {
  width: min(640px, calc(100% - 32px));
  margin: 0 auto;
  padding: 56px 0 calc(40px + env(safe-area-inset-bottom));
}

.brand {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin: 0;
}

.logo {
  font-family: "Iowan Old Style", Palatino, "Songti SC", "Noto Serif SC", serif;
  font-size: 28px;
  font-weight: 600;
  letter-spacing: -0.04em;
}

.brand span:last-child {
  color: var(--muted);
  font-size: 13px;
}

h1 {
  margin: 18px 0 8px;
  font-size: 22px;
  font-weight: 650;
  letter-spacing: -0.02em;
}

.lede {
  margin: 0 0 28px;
  color: var(--muted);
}

form {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

label {
  font-size: 13px;
  font-weight: 650;
}

input[type="url"] {
  width: 100%;
  min-height: 52px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--card);
  color: var(--ink);
  font: inherit;
  box-shadow: var(--shadow);
}

input[type="url"]::placeholder { color: #958d83; }

input[type="url"]:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(27, 107, 74, 0.16);
}

button {
  min-height: 46px;
  border: 0;
  border-radius: 12px;
  background: var(--accent);
  color: var(--accent-ink);
  font: inherit;
  font-weight: 650;
  cursor: pointer;
}

button:hover { filter: brightness(0.96); }
button:disabled { opacity: 0.55; cursor: wait; }

button:focus-visible,
a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

.msg {
  margin: 18px 0 0;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--card);
  color: var(--ink);
  overflow-wrap: anywhere;
}

.msg.error {
  background: var(--danger-bg);
  border-color: transparent;
  color: var(--danger);
}

.results {
  list-style: none;
  margin: 14px 0 0;
  padding: 0;
  display: grid;
  gap: 10px;
}

.item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 14px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
}

.title {
  font-weight: 650;
  overflow-wrap: anywhere;
}

.meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
  overflow-wrap: anywhere;
}

.tag {
  padding: 0 6px;
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 11px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

button.dl {
  background: var(--ink);
  color: var(--bg);
  border-radius: 10px;
  padding: 8px 14px;
  white-space: nowrap;
}

footer {
  margin-top: 36px;
  color: var(--muted);
  font-size: 12px;
}

footer p { margin: 0 0 6px; }

@media (max-width: 560px) {
  .wrap { padding-top: 32px; }
  .item { grid-template-columns: 1fr; }
  button.dl { width: 100%; }
}

@media (prefers-color-scheme: dark) {
  body {
    background:
      radial-gradient(900px 280px at 50% -80px, rgba(255, 255, 255, 0.04), transparent 60%),
      var(--bg);
  }
  button.dl { background: #f4efe6; color: #171512; }
  input[type="url"]::placeholder { color: #8a8176; }
}
