/* ===================================================================
   NullShare — Monochrome, system-font, minimal CSS
   =================================================================== */

/* --- Theme Variables --- */

:root {
  color-scheme: light;
  --bg: #ffffff;
  --text: #111111;
  --text-secondary: #333333;
  --text-muted: #555555;
  --text-faint: #666666;
  --text-placeholder: #999999;
  --border: #cccccc;
  --border-light: #dddddd;
  --border-strong: #999999;
  --card: #f5f5f5;
  --card-alt: #f9f9f9;
  --input-bg: #ffffff;
  --hover-bg: #eeeeee;
  --button-bg: #111111;
  --button-text: #ffffff;
  --button-hover: #333333;
  --focus-ring: rgba(0, 0, 0, 0.15);
}

[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0f0f0f;
  --text: #f5f5f5;
  --text-secondary: #cccccc;
  --text-muted: #999999;
  --text-faint: #888888;
  --text-placeholder: #666666;
  --border: #2a2a2a;
  --border-light: #222222;
  --border-strong: #444444;
  --card: #1a1a1a;
  --card-alt: #1a1a1a;
  --input-bg: #1a1a1a;
  --hover-bg: #222222;
  --button-bg: #f5f5f5;
  --button-text: #111111;
  --button-hover: #dddddd;
  --focus-ring: rgba(255, 255, 255, 0.2);
}

/* --- Reset & Base --- */

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

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji";
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* --- Layout --- */

header {
  text-align: center;
  padding: 2rem 1rem 1rem;
  border-bottom: 1px solid var(--border);
  position: relative;
}

header h1 {
  font-size: 1.5rem;
  letter-spacing: 0.15em;
  font-weight: 700;
}

header h1 a {
  color: var(--text);
  text-decoration: none;
}

header h1 a:hover,
header h1 a:focus-visible {
  text-decoration: underline;
}

.tagline {
  font-size: 0.85rem;
  color: var(--text-faint);
  margin-top: 0.25rem;
}

/* --- Theme Toggle --- */

.theme-toggle {
  position: absolute;
  top: 1rem;
  right: 1rem;
}

.theme-toggle-label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-faint);
}

main {
  flex: 1;
  width: 100%;
  max-width: 640px;
  margin: 0 auto;
  padding: 2rem 1rem;
}

footer {
  text-align: center;
  padding: 1.5rem 1rem;
  border-top: 1px solid var(--border);
  font-size: 0.75rem;
  color: var(--text-placeholder);
}

/* --- Views --- */

.view {
  display: none;
}

.view.active {
  display: block;
}

/* --- Forms & Fields --- */

.field {
  margin-bottom: 1.25rem;
}

.field.compact {
  margin-bottom: 1rem;
}

label {
  display: block;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 0.35rem;
}

textarea,
input[type="text"],
input[type="password"],
input[type="number"],
input[type="datetime-local"] {
  width: 100%;
  padding: 0.6rem 0.75rem;
  font-size: 0.9375rem;
  font-family: inherit;
  color: var(--text);
  background: var(--input-bg);
  border: 1px solid var(--border-strong);
  border-radius: 3px;
  outline: none;
}

textarea {
  resize: vertical;
  min-height: 6rem;
}

textarea:focus,
input[type="text"]:focus,
input[type="password"]:focus,
input[type="number"]:focus,
input[type="datetime-local"]:focus {
  border-color: var(--text);
  box-shadow: 0 0 0 2px var(--focus-ring);
}

input[type="number"] {
  max-width: 140px;
}

/* --- Validation errors --- */

.field-error {
  display: block;
  font-size: 0.8rem;
  color: var(--text-secondary);
  font-weight: 600;
  min-height: 1.25rem;
  margin-top: 0.25rem;
}

.field-error:empty {
  visibility: hidden;
}

.field-error::before {
  content: "⚠ ";
}

.field-error:empty::before {
  content: "";
}

/* --- Duration Buttons --- */

.duration-buttons {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.duration-btn {
  padding: 0.45rem 0.9rem;
  font-size: 0.8125rem;
  font-family: inherit;
  font-weight: 500;
  color: var(--text-secondary);
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 3px;
  cursor: pointer;
}

.duration-btn:hover {
  background: var(--hover-bg);
  border-color: var(--border-strong);
}

.duration-btn:focus-visible {
  outline: 2px solid var(--text);
  outline-offset: 2px;
}

.duration-btn.selected {
  background: var(--button-bg);
  color: var(--button-text);
  border-color: var(--button-bg);
}

/* --- Preset Buttons --- */

.preset-group {
  border: none;
  margin-bottom: 1.25rem;
}

.preset-group legend {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 0.35rem;
}

.preset-buttons {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.preset-btn {
  flex: 1;
  min-width: 100px;
  padding: 0.55rem 0.75rem;
  font-size: 0.8125rem;
  font-family: inherit;
  font-weight: 600;
  color: var(--text-secondary);
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 3px;
  cursor: pointer;
  text-align: center;
}

.preset-btn:hover {
  background: var(--hover-bg);
  border-color: var(--border-strong);
}

.preset-btn:focus-visible {
  outline: 2px solid var(--text);
  outline-offset: 2px;
}

.preset-btn.selected {
  background: var(--button-bg);
  color: var(--button-text);
  border-color: var(--button-bg);
}

/* --- Security Options (collapsible) --- */

.security-options {
  margin-bottom: 1.5rem;
  border: 1px solid var(--border);
  border-radius: 3px;
}

.security-options summary {
  padding: 0.65rem 0.75rem;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  user-select: none;
  list-style: none;
}

.security-options summary::-webkit-details-marker {
  display: none;
}

.security-options summary::before {
  content: "▸ ";
}

.security-options[open] summary::before {
  content: "▾ ";
}

.security-options summary:focus-visible {
  outline: 2px solid var(--text);
  outline-offset: -2px;
}

.options-panel {
  padding: 0.75rem;
  border-top: 1px solid var(--border);
}

/* --- Toggle Switches --- */

.toggle-field {
  margin-bottom: 0.85rem;
}

.toggle-field label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  font-weight: 500;
}

.toggle-label-text {
  font-size: 0.875rem;
  color: var(--text-secondary);
}

.toggle-switch {
  position: relative;
  display: inline-block;
  width: 40px;
  height: 22px;
  flex-shrink: 0;
}

.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
  position: absolute;
}

.toggle-track {
  position: absolute;
  inset: 0;
  background: var(--border);
  border-radius: 11px;
  cursor: pointer;
}

.toggle-track::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 18px;
  height: 18px;
  background: var(--bg);
  border-radius: 50%;
  transition: transform 0.15s ease;
}

.toggle-switch input:checked + .toggle-track {
  background: var(--button-bg);
}

.toggle-switch input:checked + .toggle-track::after {
  transform: translateX(18px);
}

.toggle-switch input:focus-visible + .toggle-track {
  outline: 2px solid var(--text);
  outline-offset: 2px;
}

/* --- Buttons --- */

.btn-primary {
  display: block;
  width: 100%;
  padding: 0.75rem;
  font-size: 1rem;
  font-family: inherit;
  font-weight: 700;
  color: var(--button-text);
  background: var(--button-bg);
  border: 1px solid var(--button-bg);
  border-radius: 3px;
  cursor: pointer;
  margin-top: 0.5rem;
}

.btn-primary:hover {
  background: var(--button-hover);
  border-color: var(--button-hover);
}

.btn-primary:focus-visible {
  outline: 2px solid var(--text);
  outline-offset: 2px;
}

.btn-primary:disabled {
  background: var(--text-placeholder);
  border-color: var(--text-placeholder);
  cursor: not-allowed;
}

.btn-secondary {
  padding: 0.5rem 1rem;
  font-size: 0.875rem;
  font-family: inherit;
  font-weight: 600;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--text);
  border-radius: 3px;
  cursor: pointer;
}

.btn-secondary:hover {
  background: var(--card);
}

.btn-secondary:focus-visible {
  outline: 2px solid var(--text);
  outline-offset: 2px;
}

.btn-danger {
  padding: 0.5rem 1rem;
  font-size: 0.875rem;
  font-family: inherit;
  font-weight: 600;
  color: var(--button-text);
  background: var(--button-hover);
  border: 1px solid var(--button-hover);
  border-radius: 3px;
  cursor: pointer;
}

.btn-danger:hover {
  background: var(--button-bg);
  border-color: var(--button-bg);
}

.btn-danger:focus-visible {
  outline: 2px solid var(--text);
  outline-offset: 2px;
}

.btn-link {
  display: inline-block;
  color: var(--text);
  font-size: 0.875rem;
  font-weight: 600;
  text-decoration: underline;
  margin-top: 1rem;
}

.btn-link:hover {
  color: var(--text-secondary);
}

.btn-link:focus-visible {
  outline: 2px solid var(--text);
  outline-offset: 2px;
}

/* --- Success Panel --- */

.success-panel {
  margin-top: 1.5rem;
  padding: 1rem;
  border: 1px solid var(--border);
  border-radius: 3px;
  background: var(--card-alt);
}

.success-label {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 0.5rem;
}

.link-display {
  display: flex;
  gap: 0.5rem;
  align-items: stretch;
}

.link-display output {
  flex: 1;
  padding: 0.5rem 0.75rem;
  font-size: 0.8125rem;
  font-family: "SF Mono", "Cascadia Code", "Consolas", monospace;
  color: var(--text);
  background: var(--input-bg);
  border: 1px solid var(--border-strong);
  border-radius: 3px;
  word-break: break-all;
  display: flex;
  align-items: center;
}

.copy-feedback {
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin-top: 0.35rem;
  min-height: 1.2rem;
}

/* --- Nav Bar --- */

.nav-bar {
  display: flex;
  justify-content: center;
  gap: 1.5rem;
  margin-top: 0.75rem;
}

.nav-link {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-faint);
  text-decoration: none;
  padding: 0.25rem 0;
  border-bottom: 2px solid transparent;
}

.nav-link:hover {
  color: var(--text);
}

.nav-link.active {
  color: var(--text);
  border-bottom-color: var(--text);
}

.nav-link:focus-visible {
  outline: 2px solid var(--text);
  outline-offset: 2px;
}

/* --- Share Instructions --- */

.success-heading {
  font-size: 1.125rem;
  font-weight: 700;
  margin-bottom: 0.75rem;
}

.share-instructions {
  margin-top: 1rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border-light);
  font-size: 0.8125rem;
  color: var(--text-muted);
  line-height: 1.7;
}

.share-instructions p {
  margin-bottom: 0.25rem;
}

/* --- Mnemonic Display --- */

.mnemonic-display {
  padding: 0.75rem;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 3px;
  margin-bottom: 0.75rem;
}

.mnemonic-display output {
  display: block;
  font-family: "SF Mono", "Cascadia Code", "Consolas", monospace;
  font-size: 0.9375rem;
  line-height: 1.8;
  color: var(--text);
  word-spacing: 0.15em;
}

.mnemonic-actions {
  margin-bottom: 0.5rem;
}

.mnemonic-warning {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-top: 0.5rem;
  margin-bottom: 0.5rem;
}

/* --- Secret ID Section --- */

.secret-id-section {
  margin-top: 1rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border-light);
}

.secret-id-field {
  display: flex;
  gap: 0.5rem;
  align-items: stretch;
  margin-bottom: 0.75rem;
}

.secret-id-field input {
  flex: 1;
  padding: 0.5rem 0.75rem;
  font-family: "SF Mono", "Cascadia Code", "Consolas", monospace;
  font-size: 0.8125rem;
  color: var(--text);
  background: var(--input-bg);
  border: 1px solid var(--border-strong);
  border-radius: 3px;
}

.btn-toggle-vis {
  padding: 0.5rem 0.75rem;
  font-size: 0.8125rem;
  font-family: inherit;
  font-weight: 600;
  color: var(--text-secondary);
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 3px;
  cursor: pointer;
  white-space: nowrap;
}

.btn-toggle-vis:hover {
  background: var(--hover-bg);
  border-color: var(--border-strong);
}

.btn-toggle-vis:focus-visible {
  outline: 2px solid var(--text);
  outline-offset: 2px;
}

/* --- Retrieve View --- */

.retrieve-intro {
  font-size: 1rem;
  color: var(--text-secondary);
  margin-bottom: 1.5rem;
}

.status-message {
  margin-top: 1rem;
  padding: 0.75rem;
  font-size: 0.875rem;
  border: 1px solid var(--border);
  border-radius: 3px;
  background: var(--card-alt);
  color: var(--text-secondary);
}

.status-message.error {
  border-color: var(--text-faint);
  background: var(--card);
}

/* --- Result View --- */

#view-result h2 {
  font-size: 1.125rem;
  font-weight: 700;
  margin-bottom: 1rem;
}

#result-container {
  padding: 1rem;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 3px;
  margin-bottom: 0.75rem;
  overflow-x: auto;
}

#result-plaintext {
  font-family: "SF Mono", "Cascadia Code", "Consolas", monospace;
  font-size: 0.875rem;
  white-space: pre-wrap;
  word-break: break-word;
  color: var(--text);
  margin: 0;
  width: 100%;
  border: none;
  background: transparent;
  outline: none;
  resize: vertical;
  min-height: 6rem;
  line-height: 1.6;
  padding: 0;
}

.result-meta {
  font-size: 0.8rem;
  color: var(--text-faint);
  margin-bottom: 1rem;
}

.result-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-bottom: 0.5rem;
}

.cleared-notice {
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 0.25rem;
}

/* --- Responsive --- */

@media (max-width: 480px) {
  main {
    padding: 1.25rem 0.75rem;
  }

  .duration-buttons {
    gap: 0.35rem;
  }

  .duration-btn {
    flex: 1;
    min-width: 0;
    padding: 0.45rem 0.5rem;
    font-size: 0.75rem;
    text-align: center;
  }

  .preset-btn {
    min-width: 0;
    font-size: 0.75rem;
  }

  .link-display {
    flex-direction: column;
  }

  .result-actions {
    flex-direction: column;
  }

  .result-actions button {
    width: 100%;
  }
}

/* --- Reduced motion --- */

@media (prefers-reduced-motion: reduce) {
  .toggle-track::after {
    transition: none;
  }
}
