:root {
  --main: #14213D;
  --accent: #FCA412;
  --bg: #f7f7f8;
  --card: #ffffff;
  --text: #14213D;
  --muted: #555;
  --border: #e5e7eb;
  --radius: 16px;
  --radius-sm: 12px;
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

.container {
  max-width: 720px;
  margin: 0 auto;
  padding: 16px;
}

header {
  text-align: center;
  margin-bottom: 24px;
}

h1 {
  font-size: 1.6rem;
  margin: 0 0 8px;
  color: var(--main);
}

.desc {
  margin: 0 0 12px;
  color: var(--muted);
  font-size: 0.95rem;
}

.lang-toggle {
  background: var(--card);
  border: 1px solid var(--border);
  color: var(--main);
  padding: 10px 16px;
  border-radius: 999px;
  font-size: 0.85rem;
  cursor: pointer;
  min-height: 44px;
}

.card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 16px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}

.dropzone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 32px 16px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
  min-height: 160px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.dropzone.dragover {
  border-color: var(--accent);
  background: #fff9e6;
}

.dropzone-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  font-size: 1rem;
}

.dropzone .icon {
  font-size: 2.2rem;
}

.dropzone .hint {
  font-size: 0.8rem;
  color: var(--muted);
}

.preview-wrap {
  margin-top: 16px;
  text-align: center;
}

.preview-wrap img,
.result-item img {
  max-width: 100%;
  max-height: 420px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  display: block;
  margin: 0 auto;
}

.preview-label {
  font-size: 0.8rem;
  color: var(--muted);
  margin-bottom: 6px;
  text-align: center;
}

.segmented {
  display: flex;
  background: #f1f3f5;
  border-radius: 999px;
  padding: 4px;
  margin-bottom: 16px;
}

.segmented button {
  flex: 1;
  padding: 12px 16px;
  border: none;
  background: transparent;
  border-radius: 999px;
  font-size: 1rem;
  cursor: pointer;
  color: var(--text);
  transition: all 0.15s;
  min-height: 48px;
}

.segmented button.active {
  background: var(--accent);
  color: var(--main);
  font-weight: 600;
  box-shadow: 0 1px 2px rgba(0,0,0,0.1);
}

.primary-btn {
  width: 100%;
  padding: 14px 20px;
  font-size: 1.05rem;
  background: var(--accent);
  color: var(--main);
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-weight: 600;
  min-height: 52px;
  transition: opacity 0.2s;
}

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

.status {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-top: 12px;
  color: var(--muted);
  font-size: 0.95rem;
}

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

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

.error {
  margin-top: 12px;
  padding: 12px;
  background: #fff0f0;
  color: #9f2a2a;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  border: 1px solid #ffcccc;
}

.result-card {
  margin-top: 8px;
}

.result-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
  margin-bottom: 16px;
}

@media (min-width: 560px) {
  .result-grid {
    grid-template-columns: 1fr 1fr;
  }
}

footer {
  text-align: center;
  margin-top: 32px;
  font-size: 0.8rem;
  color: var(--muted);
}

/* Language visibility */
html[lang="ar"] .lang-en,
html[dir="rtl"] .lang-en {
  display: none;
}
html[lang="en"] .lang-ar,
html[dir="ltr"] .lang-ar {
  display: none;
}

html[lang="en"],
html[dir="ltr"] {
  direction: ltr;
  text-align: left;
}
