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

/* Light theme (default) */
:root {
  --bg: #fafafa;
  --surface: #fff;
  --border: #ddd;
  --text: #1a1a1a;
  --text-secondary: #555;
  --accent: #0066cc;
  --accent-hover: #0052a3;
  --error-bg: #fef2f2;
  --error-text: #b91c1c;
  --radius: 6px;
}

/* Dark theme values */
[data-theme="dark"] {
  --bg: #111;
  --surface: #1a1a1a;
  --border: #333;
  --text: #e5e5e5;
  --text-secondary: #999;
  --accent: #4da3ff;
  --accent-hover: #7dbdff;
  --error-bg: #2d1515;
  --error-text: #f87171;
}

/* System preference when no explicit choice */
@media (prefers-color-scheme: dark) {
  [data-theme="system"] {
    --bg: #111;
    --surface: #1a1a1a;
    --border: #333;
    --text: #e5e5e5;
    --text-secondary: #999;
    --accent: #4da3ff;
    --accent-hover: #7dbdff;
    --error-bg: #2d1515;
    --error-text: #f87171;
  }
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
}

main {
  max-width: 700px;
  margin: 0 auto;
  padding: 3rem 1rem;
}

/* Top bar */
.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

h1 {
  font-size: 1.8rem;
  font-weight: 700;
  margin-bottom: 0.25rem;
}

#theme-toggle {
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 1.1rem;
  width: 2.2rem;
  height: 2.2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  line-height: 1;
}

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

.subtitle {
  color: var(--text-secondary);
  margin-bottom: 2rem;
  font-size: 0.95rem;
}

/* Explainer */
.explainer {
  margin-bottom: 1.5rem;
  font-size: 0.9rem;
  color: var(--text-secondary);
  line-height: 1.6;
}

.explainer p + p {
  margin-top: 0.5rem;
}

.explainer code {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 0.1rem 0.3rem;
  font-size: 0.85em;
}

/* Mode tabs */
.mode-tabs {
  display: flex;
  gap: 0;
  margin-bottom: 1rem;
  border-bottom: 2px solid var(--border);
}

.tab {
  background: none;
  border: none;
  padding: 0.5rem 1.2rem;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
}

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

.tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

/* Text input */
#text-input {
  width: 100%;
  padding: 0.8rem;
  font-size: 1rem;
  font-family: inherit;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  outline: none;
  resize: vertical;
  min-height: 80px;
}

#text-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(0, 102, 204, 0.2);
}

/* File input */
#drop-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 2rem;
  text-align: center;
  color: var(--text-secondary);
  transition: border-color 0.15s, background 0.15s;
}

#drop-zone.drag-over {
  border-color: var(--accent);
  background: rgba(0, 102, 204, 0.05);
}

.file-label {
  color: var(--accent);
  cursor: pointer;
  text-decoration: underline;
}

.file-label:hover {
  color: var(--accent-hover);
}

#file-info {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-top: 0.75rem;
  padding: 0.6rem 0.8rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.9rem;
}

#file-name {
  font-weight: 600;
  word-break: break-all;
}

#file-size {
  color: var(--text-secondary);
  white-space: nowrap;
}

#file-clear {
  margin-left: auto;
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 1.2rem;
  cursor: pointer;
  padding: 0 0.3rem;
  line-height: 1;
}

#file-clear:hover {
  color: var(--error-text);
}

/* Options bar */
#options-bar {
  margin-top: 1rem;
  margin-bottom: 1rem;
}

.option {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.9rem;
  color: var(--text-secondary);
  cursor: pointer;
}

.option input[type="checkbox"] {
  cursor: pointer;
}

/* Results */
#results {
  margin-top: 0.5rem;
}

.hash-row {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.8rem 1rem;
  margin-bottom: 0.5rem;
}

.hash-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  margin-bottom: 0.3rem;
}

.hash-value {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
}

.hash-value code {
  flex: 1;
  font-family: "SF Mono", "Fira Code", "Fira Mono", "Roboto Mono", monospace;
  font-size: 0.85rem;
  word-break: break-all;
  line-height: 1.4;
  color: var(--text);
  min-height: 1.2em;
}

.copy-btn {
  flex-shrink: 0;
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-secondary);
  font-size: 0.75rem;
  padding: 0.2rem 0.5rem;
  cursor: pointer;
  white-space: nowrap;
}

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

.copy-btn.copied {
  color: #16a34a;
  border-color: #16a34a;
}

/* Loading */
#hashing-status {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-top: 1rem;
  color: var(--text-secondary);
}

.spinner {
  width: 20px;
  height: 20px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

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

/* Footer */
footer {
  max-width: 700px;
  margin: 2rem auto 0;
  padding: 1rem 1rem;
  text-align: center;
  color: var(--text-secondary);
  font-size: 0.8rem;
  border-top: 1px solid var(--border);
}

footer a {
  color: var(--accent);
  text-decoration: none;
}

footer a:hover {
  text-decoration: underline;
}

/* Utility */
.hidden {
  display: none !important;
}

@media (max-width: 500px) {
  .hash-value {
    flex-direction: column;
  }

  .copy-btn {
    align-self: flex-start;
  }
}
