:root {
  color-scheme: light dark;
  --bg: #f6f7f9;
  --surface: #ffffff;
  --text: #1b1f24;
  --muted: #55606b;
  --border: #d5dbe2;
  --accent: #1d5fbf;
  --accent-text: #ffffff;
  --accent-hover: #174d9c;
  --warn-bg: #fff6e0;
  --warn-border: #c98a00;
  --warn-text: #4a3500;
  --ok: #17663a;
  --ok-bg: #e7f6ed;
  --err: #a41c1c;
  --err-bg: #fdeaea;
  --focus: #ffb000;
  --radius: 10px;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121417;
    --surface: #1b1f24;
    --text: #e8ebef;
    --muted: #a3adb8;
    --border: #353d47;
    --accent: #6aa6ff;
    --accent-text: #0b1020;
    --accent-hover: #8fbcff;
    --warn-bg: #3a2e12;
    --warn-border: #d9a53a;
    --warn-text: #ffe2a6;
    --ok: #8fe0ae;
    --ok-bg: #163222;
    --err: #ff9b9b;
    --err-bg: #3b1d1d;
    --focus: #ffd166;
  }
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  font-size: 16px;
  display: flex;
  flex-direction: column;
}

.skip-link {
  position: absolute;
  left: 12px;
  top: -48px;
  padding: 8px 12px;
  background: var(--surface);
  color: var(--text);
  border-radius: 6px;
  z-index: 10;
}

.skip-link:focus {
  top: 12px;
}

.site-header,
main,
.site-footer {
  width: 100%;
  max-width: 640px;
  margin: 0 auto;
  padding-left: 20px;
  padding-right: 20px;
}

.site-header {
  padding-top: 32px;
  padding-bottom: 8px;
}

h1 {
  font-size: clamp(1.4rem, 1.2rem + 1vw, 1.9rem);
  margin: 0 0 8px;
  line-height: 1.2;
}

h2 {
  font-size: 1.15rem;
  margin: 0 0 12px;
}

.lead {
  margin: 0;
  color: var(--muted);
}

main {
  flex: 1;
  padding-top: 20px;
  padding-bottom: 24px;
}

main:focus {
  outline: none;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}

.card + .card {
  margin-top: 16px;
}

.field {
  margin-bottom: 16px;
}

label {
  display: block;
  font-weight: 600;
  margin-bottom: 6px;
}

input[type="file"],
select,
textarea,
input[type="text"] {
  width: 100%;
  font: inherit;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  min-height: 44px;
}

input[type="file"] {
  padding: 8px;
  cursor: pointer;
}

input[type="file"]::file-selector-button {
  font: inherit;
  margin-right: 12px;
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
}

input[type="text"][readonly] {
  font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
  font-size: 0.9rem;
}

:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

.hint {
  color: var(--muted);
  font-size: 0.92rem;
  margin: 6px 0 0;
  overflow-wrap: anywhere;
}

.notice {
  border: 1px solid var(--border);
  border-left: 4px solid var(--accent);
  border-radius: 8px;
  padding: 12px 16px;
  margin: 0 0 20px;
  font-size: 0.95rem;
  background: var(--bg);
}

.notice ul {
  margin: 0;
  padding-left: 1.2em;
}

.notice li + li {
  margin-top: 4px;
}

.notice p {
  margin: 0;
}

.notice-title {
  font-weight: 600;
  margin-bottom: 6px !important;
}

.notice.warn {
  background: var(--warn-bg);
  border-color: var(--warn-border);
  color: var(--warn-text);
}

.btn {
  font: inherit;
  font-weight: 600;
  min-height: 44px;
  padding: 10px 18px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  transition: background-color 0.15s ease, border-color 0.15s ease;
}

.btn:hover:not(:disabled) {
  border-color: var(--accent);
}

.btn.primary {
  width: 100%;
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-text);
}

.btn.primary:hover:not(:disabled) {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.btn[aria-busy="true"] {
  cursor: progress;
}

.row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.row input[type="text"] {
  flex: 1 1 260px;
  min-width: 0;
}

.row .btn {
  flex: 0 0 auto;
}

.result {
  margin-top: 20px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
}

.check {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin: 0 0 20px;
}

.check input {
  width: 20px;
  height: 20px;
  margin: 2px 0 0;
  flex: 0 0 auto;
  accent-color: var(--accent);
}

.check label {
  margin: 0;
  font-weight: 500;
}

.status {
  border-radius: 8px;
  padding: 12px 16px;
  margin-bottom: 16px;
  border: 1px solid transparent;
  overflow-wrap: anywhere;
}

.status:empty {
  display: none;
}

.status[data-kind="info"],
.status.info {
  background: var(--surface);
  border-color: var(--border);
}

.status.success {
  background: var(--ok-bg);
  color: var(--ok);
  border-color: var(--ok);
}

.status.error {
  background: var(--err-bg);
  color: var(--err);
  border-color: var(--err);
}

.site-footer {
  padding-top: 8px;
  padding-bottom: 32px;
  color: var(--muted);
  font-size: 0.9rem;
  border-top: 1px solid var(--border);
  margin-top: 8px;
}

.site-footer h2 {
  font-size: 1rem;
  margin-top: 16px;
  color: var(--text);
}

.site-footer ul {
  padding-left: 1.2em;
  margin: 0;
}

.site-footer li + li {
  margin-top: 6px;
}

@media (min-width: 640px) {
  .card {
    padding: 28px;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
    animation: none !important;
  }
}

textarea {
  resize: vertical;
  font: inherit;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  width: 100%;
  box-sizing: border-box;
}

textarea.output[readonly] {
  font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
  font-size: 0.9rem;
  white-space: pre-wrap;
  margin-bottom: 8px;
}
