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

body {
  font-family: var(--font-family);
  background-color: var(--bg-main);
  color: var(--text-main);
  min-height: 100vh;
  padding: var(--spacing-lg);
  line-height: 1.5;
  transition:
    background-color var(--transition-speed),
    color var(--transition-speed);
}

@media (min-width: 1024px) {
  body {
    padding: var(--spacing-2xl);
  }
}

.container {
  max-width: var(--container-max-width);
  width: 100%;
  margin: 0 auto;
}

/* Header */
header {
  margin-bottom: var(--spacing-2xl);
}

.header-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.header-brand {
  display: flex;
  align-items: center;
  gap: var(--spacing-md);
}

.logo {
  width: 2rem;
  height: 2rem;
  object-fit: contain;
}

@media (min-width: 768px) {
  .logo {
    width: 2.5rem;
    height: 2.5rem;
  }
}

header h1 {
  font-size: 1.5rem;
  font-weight: 800;
  letter-spacing: -0.025em;
  color: var(--primary-colour);
}

@media (min-width: 768px) {
  header h1 {
    font-size: 1.875rem;
  }
}

.theme-toggle {
  background: none;
  border: 2px solid var(--border-colour);
  border-radius: var(--border-radius-md);
  padding: var(--spacing-sm);
  cursor: pointer;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-speed);
}

.theme-toggle:hover {
  background-color: var(--bg-subtle);
  color: var(--accent-colour);
}

.theme-toggle .moon-icon {
  display: none;
}

[data-theme="dark"] .theme-toggle .sun-icon {
  display: none;
}

[data-theme="dark"] .theme-toggle .moon-icon {
  display: block;
}

.header-accent {
  height: 0.25rem;
  width: 5rem;
  background-color: var(--accent-colour);
  margin-top: var(--spacing-md);
}

/* Main Layout */
main {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--spacing-xl);
}

@media (min-width: 1024px) {
  main {
    grid-template-columns: 1fr 1fr;
  }
}

.editor-section {
  background-color: var(--bg-subtle);
  padding: var(--spacing-xl);
  border-radius: var(--border-radius-lg);
  box-shadow: var(--shadow-md);
  display: flex;
  flex-direction: column;
  gap: var(--spacing-lg);
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.section-header h2 {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--primary-colour);
}

.editor-container {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-md);
  flex: 1;
}

.field-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--spacing-xs);
}

label {
  font-weight: 600;
  font-size: 0.875rem;
  color: var(--text-main);
}

textarea {
  width: 100%;
  min-height: 200px;
  padding: 0.75rem;
  border: 1px solid var(--border-colour);
  border-radius: var(--border-radius-md);
  background-color: var(--bg-input);
  color: var(--text-main);
  font-family:
    "SFMono-Regular", Consolas, "Liberation Mono", Menlo, Courier, monospace;
  font-size: 0.9rem;
  resize: vertical;
  transition: border-color 0.2s;
}

textarea:focus {
  outline: none;
  border-color: var(--accent-colour);
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.1);
}

textarea.invalid-input {
  border-color: var(--error-colour);
}

textarea.invalid-input:focus {
  border-color: var(--error-colour);
  box-shadow: 0 0 0 2px rgba(239, 68, 68, 0.1);
}

#header-editor,
#signature-editor {
  min-height: 100px;
}

#payload-editor {
  min-height: 300px;
}

.btn-icon {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  padding: var(--spacing-xs);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color var(--transition-speed), transform var(--transition-speed);
}

.btn-icon:hover {
  color: var(--accent-colour);
  transform: scale(1.1);
}

footer {
  margin-top: calc(var(--spacing-unit) * 4);
  padding: calc(var(--spacing-unit) * 2) 0;
  text-align: center;
  color: var(--text-secondary);
  font-size: 0.875rem;
}

/* Signature Verification */
.signature-verification {
  margin-top: var(--spacing-lg);
  padding: var(--spacing-md);
  border: 1px solid var(--border-colour);
  border-radius: var(--border-radius-md);
  background-color: var(--bg-main);
  display: flex;
  flex-direction: column;
  gap: var(--spacing-sm);
}

.signature-status {
  padding: 0.25rem 0.5rem;
  border-radius: var(--border-radius-sm);
  font-size: 0.7rem;
  font-weight: 800;
  text-transform: uppercase;
  background-color: var(--text-muted);
  color: white;
}

.signature-status.verified {
  background-color: var(--success-colour);
}

.signature-status.invalid {
  background-color: var(--error-colour);
}

.signature-status.missing {
  background-color: var(--accent-colour);
}

.secret-input {
  width: 100%;
  padding: 0.5rem;
  border: 1px solid var(--border-colour);
  border-radius: var(--border-radius-sm);
  background-color: var(--bg-input);
  color: var(--text-main);
  font-family: inherit;
}

.secret-input:focus {
  outline: none;
  border-color: var(--accent-colour);
}

.verification-note {
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* Toast Notification Styles */
#toast-container {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.toast {
  padding: 1rem 1.5rem;
  background-color: var(--bg-subtle);
  color: var(--text-main);
  border-radius: var(--border-radius-md);
  box-shadow: var(--shadow-md);
  border-left: 4px solid var(--accent-colour);
  min-width: 250px;
  animation: slideIn 0.3s ease-out;
}

.toast-success {
  border-left-color: var(--success-colour);
}

.toast-error {
  border-left-color: var(--error-colour);
}

.toast-fade-out {
  opacity: 0;
  transform: translateX(1rem);
  transition: opacity 0.3s, transform 0.3s;
}

@keyframes slideIn {
  from {
    transform: translateX(100%);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}
