:root {
  --color-primary: #1a73e8;
  --color-border: #dadce0;
  --color-muted: #666;
  --color-surface: #ffffff;
  --color-bg: #f1f3f4;
  --color-text: #1f2937;
  --font-base: 'Segoe UI', system-ui, sans-serif;
  --space-xs: 0.25rem;
  --space-sm: 0.5rem;
  --space-md: 1rem;
  --space-lg: 1.5rem;
}

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-base);
  background-color: var(--color-bg);
  color: var(--color-text);
  padding: var(--space-lg) var(--space-md);
  transition: background-color 0.3s ease, color 0.3s ease;
}

[data-theme="dark"] {
  --color-bg:      #0d1117;
  --color-surface: #161b22;
  --color-text:    #e6edf3;
  --color-muted:   #8b949e;
  --color-border:  #30363d;
  --color-primary: #58a6ff;
}

.app-header {
  text-align: center;
  margin-bottom: 1.5rem;
  max-width: 680px;
  margin-inline: auto;
}

.header-top {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  margin-bottom: 0.5rem;
}

.subtitle {
  color: var(--color-muted);
  font-size: 0.95rem;
}

.card {
  background: var(--color-surface);
  border-radius: 8px;
  padding: 1.5rem;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.06);
  margin-bottom: 1.5rem;
  max-width: 680px;
  margin-inline: auto;
  transition: background-color 0.3s ease;
}

.field-group {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  margin-bottom: 1.2rem;
}

label {
  font-weight: 600;
  font-size: 0.9rem;
}

input,
select,
textarea {
  width: 100%;
  padding: 0.6rem 0.8rem;
  border: 1px solid var(--color-border);
  border-radius: 6px;
  font-size: 1rem;
  font-family: inherit;
  background-color: var(--color-surface);
  color: var(--color-text);
  transition: background-color 0.3s ease, color 0.3s ease;
}

input:focus,
select:focus,
textarea:focus {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
  border-color: transparent;
}

.input-row {
  display: flex;
  gap: 0.5rem;
}

.input-row input {
  flex: 1;
}

.input-row button {
  width: 110px;
}

small {
  color: var(--color-muted);
  font-size: 0.8rem;
}

.btn-primary {
  background: var(--color-primary);
  color: #fff;
  border: none;
  padding: 0.7rem 1.4rem;
  border-radius: 6px;
  font-size: 1rem;
  cursor: pointer;
  width: 100%;
}

.btn-primary:hover {
  background: #1765c9;
}

.output-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
}

#output-text {
  white-space: pre-wrap;
  line-height: 1.7;
  font-size: 1rem;
  max-height: 480px;
  overflow-y: auto;
  padding: 0.75rem;
  background: var(--color-surface);
  border-radius: 6px;
  border: 1px solid var(--color-border);
}

#copy-btn,
#toggle-key {
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  color: var(--color-text);
  border-radius: 6px;
  padding: 0.6rem 0.8rem;
  font-size: 0.9rem;
  cursor: pointer;
}

#copy-btn:hover,
#toggle-key:hover {
  background: var(--color-bg);
}

.output-header #copy-btn {
  width: 110px;
}

#theme-toggle {
  background: none;
  border: 1px solid var(--color-border);
  border-radius: 6px;
  padding: 0.3rem 0.6rem;
  font-size: 1.1rem;
  cursor: pointer;
}

#theme-toggle:hover {
  background: var(--color-border);
}

#copy-btn.copied {
  background-color: #2e7d32;
  color: white;
  border-color: #2e7d32;
}

.btn-primary:disabled {
  opacity: 0.7;
  cursor: not-allowed;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255, 255, 255, 0.4);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  vertical-align: middle;
  margin-right: 8px;
}

@media (max-width: 480px) {
  .card {
    padding: 1rem;
  }
}
