:root {
  color-scheme: light;
  --background: #f7f7f8;
  --card: #fff;
  --foreground: #111113;
  --muted: #71717a;
  --border: #e4e4e7;
  --input: #fff;
  --subtle: #f4f4f5;
  --ring: rgba(24, 24, 27, .15);
  --primary: #18181b;
  --primary-fg: #fafafa;
  --success: #22c55e;
  --danger: #dc2626;
}

* { box-sizing: border-box; }
html, body { min-height: 100%; }

body {
  margin: 0;
  color: var(--foreground);
  background: var(--background);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}

button, input, select { font: inherit; }

.page {
  width: min(100% - 32px, 540px);
  margin: 0 auto;
  padding: 28px 0 80px;
}

.topbar {
  height: 40px;
  margin-bottom: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
  font-weight: 650;
  letter-spacing: -.01em;
}

.brand-mark {
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border-radius: 9px;
  color: var(--primary-fg);
  background: var(--primary);
}

.brand-mark svg { width: 17px; fill: none; stroke: currentColor; stroke-width: 1.8; }

.online {
  display: flex;
  align-items: center;
  gap: 7px;
  color: var(--muted);
  font-size: 12px;
}

.online i {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 0 3px rgba(34,197,94,.13);
}

.card {
  padding: 32px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--card);
  box-shadow: 0 1px 2px rgba(0,0,0,.03), 0 16px 40px rgba(0,0,0,.035);
}

.card-head { margin-bottom: 28px; }

h1 {
  margin: 0;
  font-size: 22px;
  line-height: 1.3;
  letter-spacing: -.025em;
}

.card-head p { margin: 7px 0 0; color: var(--muted); font-size: 13px; }

label {
  display: block;
  margin-bottom: 8px;
  font-size: 13px;
  font-weight: 550;
}

input, select {
  width: 100%;
  height: 42px;
  padding: 0 12px;
  color: var(--foreground);
  border: 1px solid var(--border);
  border-radius: 8px;
  outline: none;
  background: var(--input);
  font-size: 14px;
  transition: border-color .15s, box-shadow .15s;
}

input:focus, select:focus { border-color: var(--foreground); box-shadow: 0 0 0 3px var(--ring); }
input::placeholder { color: #a1a1aa; }

select {
  appearance: none;
  padding-right: 32px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%2371717a' stroke-width='2'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
}

.field-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 16px;
}

#submit-button {
  width: 100%;
  height: 42px;
  margin-top: 12px;
  padding: 0 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: var(--primary-fg);
  border: 0;
  border-radius: 8px;
  background: var(--primary);
  font-size: 14px;
  font-weight: 550;
  cursor: pointer;
  transition: opacity .15s, transform .15s;
}

#submit-button:hover { opacity: .9; }
#submit-button:active { transform: scale(.995); }
#submit-button:disabled { opacity: .55; cursor: wait; }
#submit-button svg { width: 16px; fill: none; stroke: currentColor; stroke-width: 2; }

.status { min-height: 0; margin-top: 0; color: var(--muted); font-size: 12px; }
.status:not(:empty) { margin-top: 12px; }
.status.error { color: var(--danger); }

.result {
  margin-top: 28px;
  padding-top: 24px;
  border-top: 1px solid var(--border);
  animation: enter .2s ease-out both;
}

@keyframes enter {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

.result-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
  font-size: 13px;
  font-weight: 550;
}

.result-meta {
  max-width: 58%;
  overflow: hidden;
  color: var(--muted);
  font: 12px/1.2 ui-monospace, SFMono-Regular, Menlo, monospace;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 3px;
  margin-bottom: 10px;
  padding: 3px;
  border-radius: 8px;
  background: var(--subtle);
}

.tab {
  height: 32px;
  color: var(--muted);
  border: 0;
  border-radius: 6px;
  background: transparent;
  font-size: 12px;
  cursor: pointer;
}

.tab.active {
  color: var(--foreground);
  background: var(--card);
  box-shadow: 0 1px 2px rgba(0,0,0,.08);
  font-weight: 550;
}

.output-row { position: relative; }

#output-url {
  padding-right: 45px;
  color: var(--muted);
  font: 12px/1 ui-monospace, SFMono-Regular, Menlo, monospace;
  text-overflow: ellipsis;
}

.icon-button {
  position: absolute;
  top: 5px;
  right: 5px;
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  color: var(--muted);
  border: 0;
  border-radius: 6px;
  background: var(--card);
  cursor: pointer;
}

.icon-button:hover { color: var(--foreground); background: var(--subtle); }
.icon-button svg, .open-button svg { width: 16px; fill: none; stroke: currentColor; stroke-width: 1.8; }

.open-button {
  width: 100%;
  height: 40px;
  margin-top: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: var(--foreground);
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--card);
  font-size: 13px;
  font-weight: 550;
  text-decoration: none;
}

.open-button:hover { background: var(--subtle); }

@media (max-width: 560px) {
  .page { width: min(100% - 24px, 540px); padding-top: 16px; }
  .topbar { margin-bottom: 28px; }
  .card { padding: 24px 18px; }
  .field-grid { grid-template-columns: 1fr; }
}

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --background: #09090b;
    --card: #111113;
    --foreground: #fafafa;
    --muted: #a1a1aa;
    --border: #27272a;
    --input: #111113;
    --subtle: #1c1c1f;
    --ring: rgba(250,250,250,.15);
    --primary: #fafafa;
    --primary-fg: #18181b;
  }
  .card { box-shadow: 0 18px 50px rgba(0,0,0,.28); }
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
