/* Theme tokens */
:root {
  --bg: #0b1220;
  --panel: #0f172a;
  --text: #e5e7eb;
  --muted: #9ca3af;
  --primary: #0ea5e9;
  --primary-contrast: #06121a;
  --border: #1f2937;
}

[data-theme="light"] {
  --bg: #f8fafc;
  --panel: #ffffff;
  --text: #111827;
  --muted: #6b7280;
  --primary: #0284c7;
  --primary-contrast: #ffffff;
  --border: #e5e7eb;
}

/* Reset */
* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

/* Base */
body {
  margin: 0;
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Ubuntu, Cantarell, Noto Sans, "Helvetica Neue", Arial, "Apple Color Emoji", "Segoe UI Emoji";
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Header/Footer */
.app-header,
.app-footer {
  display: block;
  padding: 28px 0;
}

.container {
  max-width: 720px;
  margin: 0 auto;
  padding: 0 16px;
}

/* Extra vertical breathing room for main content */
main.container {
  padding-top: 24px;
  padding-bottom: 36px;
}

.header-inner,
.footer-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

/* Header */
.app-header h1 {
  margin: 0;
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: 0.3px;
  color: var(--text);
}

.header-actions {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.icon-button {
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text);
  border-radius: 10px;
  padding: 8px 10px;
  cursor: pointer;
}

.icon-button:hover {
  border-color: var(--muted);
}

/* Layout */
.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 20px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15), inset 0 1px 0 rgba(255, 255, 255, 0.03);
}

.card h2 {
  margin-top: 0;
  font-size: 1.1rem;
  font-weight: 600;
  color: #cbd5e1;
}

[data-theme="light"] .card h2 {
  color: #374151;
}

/* Form */
.label {
  display: block;
  margin: 12px 0 8px;
  color: var(--muted);
}

.info {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  margin-left: 6px;
  border-radius: 50%;
  background: var(--primary);
  color: var(--primary-contrast);
  font-size: 12px;
  font-weight: 700;
  cursor: help;
}

.input-row {
  display: grid;
  grid-template-columns: 48px 1fr;
  align-items: center;
  border: 1px solid var(--border);
  border-radius: 14px;
  overflow: hidden;
  background: #0F172A;
  min-height: 56px;
}

.prefix {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #94a3b8;
  font-size: 1rem;
}

input[type="text"] {
  width: 100%;
  border: 0;
  outline: none;
  padding: 16px 14px;
  background: transparent;
  color: #e5e7eb;
  font-size: 1.1rem;
}

.help {
  color: var(--muted);
  margin: 8px 2px 0;
  font-size: 0.9rem;
}

.error-text {
  color: #ef4444;
  margin: 6px 2px 0;
  font-size: 0.9rem;
}

.input-row.error {
  border-color: #ef4444;
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.15);
}

/* Actions */
.actions {
  display: flex;
  gap: 10px;
  margin-top: 16px;
}

.button {
  appearance: none;
  -webkit-appearance: none;
  cursor: pointer;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text);
  padding: 10px 14px;
  border-radius: 12px;
  font-weight: 600;
}

.button:hover {
  border-color: var(--muted);
}

.button.primary {
  background: var(--primary);
  color: var(--primary-contrast);
  border-color: transparent;
}

.button.primary:hover {
  filter: brightness(0.95);
}

.button.ghost {
  background: transparent;
}

/* Language */
.lang-select {
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text);
  padding: 8px 10px;
  border-radius: 10px;
}

.visually-hidden {
  position: absolute !important;
  height: 1px;
  width: 1px;
  overflow: hidden;
  clip: rect(1px, 1px, 1px, 1px);
  white-space: nowrap;
}

/* Results */
.results {
  margin-top: 18px;
}

.result-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 0;
}

.result-row + .result-row {
  border-top: 1px dashed var(--border);
}

.result-row.total {
  font-size: 1.1rem;
  font-weight: 700;
}

/* Ad */
.ad-slot {
  margin-top: 18px;
  display: grid;
  place-items: center;
}

.ad-placeholder {
  width: 100%;
  min-height: 90px;
  border: 1px dashed var(--border);
  border-radius: 12px;
  color: var(--muted);
  display: grid;
  place-items: center;
  font-size: 0.95rem;
}

/* Footer */
.app-footer small {
  color: var(--muted);
}

.kofi-link {
  color: var(--primary);
  text-decoration: none;
  font-weight: 700;
}

.kofi-link::before {
  content: "☕ ";
}

.kofi-link:hover {
  text-decoration: underline;
}

.footer-inner {
  display: flex;
  align-items: flex-start;
  justify-content: flex-start;
  flex-direction: column;
  gap: 8px;
}

.footer-inner .kofi-link {
  margin-top: 12px;
}

/* Support */
.support {
  margin-top: 16px;
  display: flex;
  justify-content: center;
}

.support .kofi-link {
  color: var(--primary);
  font-weight: 700;
  text-decoration: none;
}

.support .kofi-link::before {
  content: "☕ ";
}

.support .kofi-link:hover {
  text-decoration: underline;
}
