:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-alt: #eef1f4;
  --ink: #1b2430;
  --ink-muted: #5b6675;
  --border: #dce1e7;
  --accent: #1f6f64;
  --accent-strong: #175a51;
  --accent-ink: #ffffff;
  --accent-soft: #e3f1ee;
  --warn: #8a5e18;
  --warn-soft: #fbf1df;
  --danger: #a73a31;
  --danger-soft: #fbeae8;
  --shadow: 0 1px 2px rgba(20, 26, 34, 0.04), 0 8px 24px rgba(20, 26, 34, 0.06);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #10151b;
    --surface: #1a212b;
    --surface-alt: #212a36;
    --ink: #e7ebf2;
    --ink-muted: #8e99a8;
    --border: #2b3543;
    --accent: #52a79a;
    --accent-strong: #6cbdb0;
    --accent-ink: #08201c;
    --accent-soft: #16302a;
    --warn: #dcac51;
    --warn-soft: #2a2410;
    --danger: #e2817a;
    --danger-soft: #2e1817;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 24px rgba(0, 0, 0, 0.35);
  }
}

:root[data-theme="dark"] {
  --bg: #10151b;
  --surface: #1a212b;
  --surface-alt: #212a36;
  --ink: #e7ebf2;
  --ink-muted: #8e99a8;
  --border: #2b3543;
  --accent: #52a79a;
  --accent-strong: #6cbdb0;
  --accent-ink: #08201c;
  --accent-soft: #16302a;
  --warn: #dcac51;
  --warn-soft: #2a2410;
  --danger: #e2817a;
  --danger-soft: #2e1817;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 24px rgba(0, 0, 0, 0.35);
}

* {
  box-sizing: border-box;
}

body {
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  display: flex;
  justify-content: center;
  padding: 10vh 20px 10vh;
  min-height: 100vh;
}

.page {
  width: 100%;
  max-width: 540px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 28px;
}

.brand svg {
  width: 22px;
  height: 22px;
  flex-shrink: 0;
  color: var(--accent);
}

.brand .wordmark {
  font-family: Georgia, "Iowan Old Style", "Palatino Linotype", serif;
  font-size: 1.15rem;
  letter-spacing: 0.01em;
  color: var(--ink);
}

.brand .tagline {
  color: var(--ink-muted);
  font-size: 0.82rem;
  margin-left: auto;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 32px;
}

h1 {
  font-family: Georgia, "Iowan Old Style", "Palatino Linotype", serif;
  font-size: 1.5rem;
  font-weight: 600;
  margin: 0 0 6px;
  text-wrap: balance;
}

.sub {
  color: var(--ink-muted);
  font-size: 0.92rem;
  margin: 0 0 24px;
}

label.field-label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--ink-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 8px;
}

textarea,
input[type="text"],
input[type="password"] {
  width: 100%;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
  color: var(--ink);
  font-size: 0.95rem;
  font-family: inherit;
  resize: vertical;
}

textarea {
  min-height: 96px;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  font-size: 0.9rem;
}

textarea:focus,
input:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.field {
  margin-bottom: 20px;
}

.pill-group {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.pill {
  border: 1px solid var(--border);
  background: var(--surface-alt);
  color: var(--ink);
  border-radius: 999px;
  padding: 7px 14px;
  font-size: 0.85rem;
  cursor: pointer;
  font-family: inherit;
}

.pill[aria-pressed="true"] {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
}

.switch-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 4px 0;
}

.switch-row .label-group {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.switch-row .label-group span.title {
  font-size: 0.9rem;
  font-weight: 600;
}

.switch-row .label-group span.hint {
  font-size: 0.8rem;
  color: var(--ink-muted);
}

.switch {
  position: relative;
  width: 42px;
  height: 24px;
  flex-shrink: 0;
}

.switch input {
  opacity: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  cursor: pointer;
  position: absolute;
  z-index: 1;
}

.switch .track {
  position: absolute;
  inset: 0;
  background: var(--border);
  border-radius: 999px;
  transition: background 0.15s;
}

.switch .thumb {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--surface);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.25);
  transition: transform 0.15s;
}

.switch input:checked ~ .track {
  background: var(--accent);
}

.switch input:checked ~ .thumb {
  transform: translateX(18px);
}

.switch input:focus-visible ~ .track {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.disclosure {
  border: none;
  background: none;
  color: var(--accent);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  padding: 4px 0;
  font-family: inherit;
}

.optional-password {
  margin-top: 10px;
}

.optional-password[hidden] {
  display: none;
}

button.primary {
  width: 100%;
  background: var(--accent);
  color: var(--accent-ink);
  border: none;
  border-radius: 10px;
  padding: 13px 18px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  margin-top: 8px;
}

button.primary:hover {
  background: var(--accent-strong);
}

button.primary:disabled {
  opacity: 0.6;
  cursor: default;
}

button.secondary {
  background: var(--surface-alt);
  color: var(--ink);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
}

.copy-row {
  display: flex;
  gap: 8px;
}

.copy-row input {
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  font-size: 0.82rem;
}

#create-another {
  margin-top: 18px;
}

.result-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 14px 0 0;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: var(--accent-soft);
  color: var(--accent);
  border-radius: 999px;
  padding: 5px 11px;
  font-size: 0.78rem;
  font-weight: 600;
}

.chip.warn {
  background: var(--warn-soft);
  color: var(--warn);
}

.history {
  margin-top: 24px;
}

.history h2 {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--ink-muted);
  font-weight: 600;
  margin: 0 0 10px;
}

.history-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 0;
  border-top: 1px solid var(--border);
  font-size: 0.85rem;
}

.history-item .meta {
  flex: 1;
  min-width: 0;
}

.history-item .meta .status {
  font-weight: 600;
}

.history-item .meta .detail {
  color: var(--ink-muted);
  font-size: 0.78rem;
}

.history-item button {
  flex-shrink: 0;
  background: none;
  border: 1px solid var(--danger);
  color: var(--danger);
  border-radius: 8px;
  padding: 5px 10px;
  font-size: 0.76rem;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
}

.secret-box {
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  font-size: 0.95rem;
  word-break: break-all;
  white-space: pre-wrap;
  margin-bottom: 16px;
  font-variant-numeric: tabular-nums;
}

.state-icon {
  width: 40px;
  height: 40px;
  margin-bottom: 14px;
  color: var(--ink-muted);
}

.state-icon.danger {
  color: var(--danger);
}

.state-icon.accent {
  color: var(--accent);
}

.note {
  font-size: 0.82rem;
  color: var(--ink-muted);
  margin-top: 14px;
}

.error-text {
  color: var(--danger);
  font-size: 0.85rem;
  margin-top: 8px;
  min-height: 1.2em;
}

[hidden] {
  display: none !important;
}

footer.app-footer {
  text-align: center;
  color: var(--ink-muted);
  font-size: 0.78rem;
  margin-top: 20px;
}

@media (max-width: 480px) {
  body {
    padding: 6vh 14px;
  }
  .card {
    padding: 24px;
  }
}
