* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

:root {
  --green: #1a6b4a;
  --green-light: #e8f5ee;
  --green-dark: #114d35;
  --text-primary: #1a1a1a;
  --text-secondary: #555;
  --bg: #f7f9f7;
  --white: #ffffff;
  --radius: 16px;
  --shadow: 0 4px 20px rgba(0,0,0,0.08);
}

html, body {
  height: 100%;
  font-family: 'Segoe UI', Tahoma, 'Arial', sans-serif;
  background: var(--bg);
  color: var(--text-primary);
  direction: rtl;
}

/* ─── Screens ─── */
.screen {
  display: none;
  min-height: 100vh;
  padding: 24px 20px;
  flex-direction: column;
}
.screen.active {
  display: flex;
}

/* ─── Home Screen ─── */
#screen-home {
  justify-content: space-between;
  align-items: center;
  background: linear-gradient(160deg, var(--green-light) 0%, var(--white) 60%);
}

.logo-area {
  text-align: center;
  padding-top: 40px;
}
.logo-icon {
  font-size: 72px;
  margin-bottom: 12px;
  display: block;
}
.app-name {
  font-size: 52px;
  font-weight: 700;
  color: var(--green);
  letter-spacing: -1px;
  line-height: 1;
}
.app-tagline {
  font-size: 18px;
  color: var(--text-secondary);
  margin-top: 8px;
}

.home-content {
  width: 100%;
  max-width: 400px;
  text-align: center;
  padding-bottom: 48px;
}
.instruction {
  font-size: 18px;
  color: var(--text-secondary);
  line-height: 1.7;
  margin-bottom: 32px;
}

/* ─── Buttons ─── */
.btn-primary {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  padding: 20px;
  background: var(--green);
  color: white;
  border: none;
  border-radius: var(--radius);
  font-size: 20px;
  font-weight: 600;
  cursor: pointer;
  margin-bottom: 14px;
  box-shadow: 0 6px 24px rgba(26,107,74,0.35);
  transition: transform 0.15s, box-shadow 0.15s;
}
.btn-primary:active {
  transform: scale(0.97);
  box-shadow: 0 3px 12px rgba(26,107,74,0.25);
}

.btn-secondary {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  padding: 18px;
  background: var(--white);
  color: var(--green);
  border: 2px solid var(--green);
  border-radius: var(--radius);
  font-size: 18px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}
.btn-secondary:active {
  background: var(--green-light);
}

.btn-icon {
  font-size: 22px;
}

/* ─── Loading Screen ─── */
#screen-loading {
  justify-content: center;
  align-items: center;
  background: var(--white);
}
.loading-content {
  text-align: center;
  width: 100%;
  max-width: 340px;
}
.loading-spinner {
  width: 72px;
  height: 72px;
  border: 5px solid var(--green-light);
  border-top-color: var(--green);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
  margin: 0 auto 28px;
}
@keyframes spin {
  to { transform: rotate(360deg); }
}
.loading-text {
  font-size: 20px;
  color: var(--text-primary);
  margin-bottom: 28px;
  font-weight: 500;
}
.loading-steps {
  display: flex;
  flex-direction: column;
  gap: 10px;
  text-align: right;
}
.step {
  padding: 12px 16px;
  border-radius: 10px;
  font-size: 15px;
  color: var(--text-secondary);
  background: var(--bg);
  transition: all 0.3s;
}
.step.active {
  background: var(--green-light);
  color: var(--green-dark);
  font-weight: 600;
}
.step.done {
  background: var(--green);
  color: white;
}

/* ─── Result Screen ─── */
#screen-result {
  background: var(--white);
}
.result-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
}
.btn-back {
  background: none;
  border: none;
  font-size: 18px;
  color: var(--green);
  cursor: pointer;
  padding: 4px 0;
  font-weight: 600;
}
.result-title {
  font-size: 22px;
  color: var(--text-primary);
}

.image-preview {
  width: 100%;
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 20px;
  max-height: 180px;
  display: none;
}
.image-preview img {
  width: 100%;
  height: 180px;
  object-fit: cover;
}

.result-cards {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-bottom: 24px;
}

.result-card {
  display: flex;
  align-items: center;
  gap: 16px;
  background: var(--white);
  border: 1px solid rgba(26, 107, 74, 0.15);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.02);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.result-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(26, 107, 74, 0.08);
}

.card-icon {
  font-size: 26px;
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--green-light);
  border-radius: 50%;
  color: var(--green);
  flex-shrink: 0;
}

.card-content {
  display: flex;
  flex-direction: column;
  gap: 4px;
  text-align: right;
}

.card-label {
  font-size: 13px;
  color: var(--text-secondary);
  font-weight: 500;
}

.card-value {
  font-size: 19px;
  font-weight: 600;
  color: var(--text-primary);
}

.voice-selector-container {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 20px;
  text-align: right;
}

.voice-label {
  font-size: 14px;
  font-weight: 600;
  color: var(--green-dark);
}

.voice-select {
  width: 100%;
  padding: 14px;
  border-radius: var(--radius);
  border: 1px solid rgba(26, 107, 74, 0.2);
  background: var(--green-light);
  color: var(--green-dark);
  font-size: 16px;
  font-weight: 600;
  outline: none;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%231a6b4a' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: left 14px center;
  background-size: 20px;
  padding-left: 40px;
}

.action-buttons {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.btn-audio {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  padding: 18px;
  background: var(--green);
  color: white;
  border: none;
  border-radius: var(--radius);
  font-size: 18px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(26,107,74,0.3);
}
.btn-audio:active { opacity: 0.85; }

.btn-new {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  padding: 16px;
  background: var(--white);
  color: var(--green);
  border: 2px solid var(--green);
  border-radius: var(--radius);
  font-size: 17px;
  font-weight: 600;
  cursor: pointer;
}

/* ─── Error Screen ─── */
#screen-error {
  justify-content: center;
  align-items: center;
  background: var(--white);
}
.error-content {
  text-align: center;
  max-width: 320px;
}
.error-icon {
  font-size: 64px;
  margin-bottom: 20px;
}
.error-text {
  font-size: 18px;
  color: var(--text-secondary);
  margin-bottom: 28px;
  line-height: 1.6;
}

/* ─── Live Camera Screen ─── */
#screen-camera {
  background: #0b0f0c;
  padding: 16px;
  justify-content: space-between;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
}
#screen-camera .btn-back {
  color: var(--white);
}
#screen-camera .result-title {
  color: var(--white);
  font-size: 20px;
}
.camera-header {
  display: flex;
  align-items: center;
  width: 100%;
  padding-bottom: 12px;
}
.camera-container {
  position: relative;
  flex: 1;
  width: 100%;
  border-radius: var(--radius);
  overflow: hidden;
  background: #000;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: inset 0 0 20px rgba(0,0,0,0.8);
}
#video-feed {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.camera-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  pointer-events: none;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.focus-brackets {
  width: 80%;
  height: 65%;
  border: 2px dashed rgba(255, 255, 255, 0.4);
  border-radius: var(--radius);
  box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.4); /* Darkened scanning mask */
}
.camera-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 20px 10px 10px;
}
.btn-switch {
  background: rgba(255, 255, 255, 0.15);
  border: none;
  color: white;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  font-size: 20px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
}
.btn-switch:active {
  background: rgba(255, 255, 255, 0.3);
}
.btn-capture {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: white;
  border: 5px solid rgba(255, 255, 255, 0.35);
  cursor: pointer;
  transition: transform 0.1s;
}
.btn-capture:active {
  transform: scale(0.9);
}

/* ─── Responsive ─── */
@media (min-width: 480px) {
  .home-content, .loading-content, .result-content, .error-content, .camera-header, .camera-container, .camera-controls {
    max-width: 420px;
    margin: 0 auto;
    width: 100%;
  }
}

/* ─── Premium Features ─── */
.scanner-container {
  position: relative;
  width: 100%;
  max-width: 280px;
  height: 160px;
  margin: 0 auto 24px;
  border-radius: var(--radius);
  overflow: hidden;
  border: 2.5px solid rgba(26, 107, 74, 0.25);
  background: #000;
  display: none;
  box-shadow: 0 8px 32px rgba(0,0,0,0.12);
}
#scanner-preview {
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0.65;
}
.scanner-laser {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 4px;
  background: linear-gradient(180deg, rgba(0, 255, 0, 0) 0%, #00ff00 50%, rgba(0, 255, 0, 0) 100%);
  box-shadow: 0 0 10px #00ff00, 0 0 20px #00ff00;
  animation: scan-move 2.2s linear infinite;
}
@keyframes scan-move {
  0% { top: 0%; }
  50% { top: 100%; }
  100% { top: 0%; }
}

@keyframes pulse-glow {
  0% { box-shadow: 0 4px 16px rgba(26,107,74,0.3); }
  50% { box-shadow: 0 4px 28px rgba(26,107,74,0.65); transform: scale(1.015); }
  100% { box-shadow: 0 4px 16px rgba(26,107,74,0.3); }
}
.btn-audio.playing {
  animation: pulse-glow 1.5s infinite;
  background: var(--green-dark) !important;
}
