:root{
  --bg: #0D0E12;
  --panel: #11131A;
  --panel-alt: #161920;
  --border: #222530;
  --text: #E2E8F0;
  --text-dim: #94A3B8;
  --gold: #D4AF37;
  --gold-dark: #B8860B;
  --success: #34D399;
  --success-soft: #A7F3D0;
  --warning: #FCA5A5;
}

*{ box-sizing: border-box; }

html, body{
  margin:0;
  padding:0;
  background: var(--bg);
  color: var(--text);
  font-family: "Vazirmatn", Tahoma, sans-serif;
  height: 100%;
}

.hidden{ display: none !important; }

.topbar{
  height: 60px;
  background: var(--panel-alt);
  display:flex;
  align-items:center;
  padding: 0 20px;
  border-bottom: 1px solid var(--border);
}
.brand{
  color: var(--gold);
  font-weight: 700;
  font-size: 1.05rem;
  letter-spacing: .3px;
}

.app-shell{
  display:flex;
  gap: 16px;
  padding: 16px;
  height: calc(100vh - 60px);
  min-height: 560px;
}

.panel{
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 6px;
}

.image-panel{
  flex: 1 1 60%;
  padding: 10px;
  min-width: 0;
}

.canvas-wrap{
  position: relative;
  height: 100%;
  width: 100%;
  display:flex;
  align-items:center;
  justify-content:center;
  overflow:hidden;
  border-radius: 4px;
  background:
    linear-gradient(var(--panel), var(--panel)) padding-box,
    repeating-linear-gradient(45deg, #14161d 0 10px, #11131a 10px 20px) border-box;
}

.result-image, .camera-feed{
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  border-radius: 4px;
}
.camera-feed{ transform: scaleX(-1); }

.placeholder{
  color: var(--text-dim);
  text-align: center;
  padding: 20px;
  line-height: 1.9;
  font-size: .95rem;
}

.loading-overlay{
  position:absolute;
  inset:0;
  background: rgba(13,14,18,.82);
  display:flex;
  flex-direction:column;
  align-items:center;
  justify-content:center;
  gap: 14px;
  color: var(--gold);
  font-size: .95rem;
}
.spinner{
  width: 34px; height: 34px;
  border-radius: 50%;
  border: 3px solid rgba(212,175,55,.25);
  border-top-color: var(--gold);
  animation: spin 0.85s linear infinite;
}
@keyframes spin{ to{ transform: rotate(360deg); } }

.controls-panel{
  flex: 0 0 420px;
  display:flex;
  flex-direction:column;
  overflow:hidden;
}

.control-card{
  background: var(--panel-alt);
  border-radius: 6px;
  margin: 15px;
  padding: 18px 15px;
}

.action-row{
  display:flex;
  gap: 8px;
  margin-bottom: 12px;
}

.btn-primary{
  flex:1;
  background: var(--gold);
  color: var(--bg);
  border:0;
  border-radius: 5px;
  padding: 11px 8px;
  font-family: inherit;
  font-weight: 700;
  font-size: .88rem;
  cursor: pointer;
  transition: background .15s ease;
}
.btn-primary:hover{ background: var(--gold-dark); }

.btn-secondary{
  flex:1;
  background: #222530;
  color: var(--gold);
  border: 1px solid var(--gold);
  border-radius: 5px;
  padding: 10px 8px;
  font-family: inherit;
  font-weight: 600;
  font-size: .88rem;
  cursor: pointer;
}
.btn-ghost{
  flex:1;
  background: transparent;
  color: var(--text-dim);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 10px 8px;
  font-family: inherit;
  font-size: .88rem;
  cursor: pointer;
}

.option-row{
  display:flex;
  align-items:center;
  gap: 10px;
  padding: 10px 0;
  border-top: 1px solid var(--border);
  flex-wrap: wrap;
}
.option-label{
  color: var(--text-dim);
  font-size: .85rem;
  margin-left: 4px;
}
.radio-pill{
  display:flex;
  align-items:center;
  gap:5px;
  font-size: .85rem;
  cursor:pointer;
  color: var(--text);
}
.radio-pill input{ accent-color: var(--gold); cursor:pointer; }

.report-box{
  flex:1;
  overflow-y:auto;
  margin: 0 15px 15px 15px;
  background: var(--panel-alt);
  border-radius: 6px;
  padding: 18px;
  line-height: 2;
  font-size: .92rem;
}
.report-box::-webkit-scrollbar{ width:8px; }
.report-box::-webkit-scrollbar-thumb{ background: var(--border); border-radius: 4px; }

.welcome-text{
  color: var(--text-dim);
  text-align: right;
  margin:0;
}

.report-entry{ margin: 0 0 8px 0; text-align: right; }
.report-entry.title{ color: var(--gold); font-weight: 700; font-size: 1.02rem; border-bottom: 1px solid var(--border); padding-bottom: 10px; }
.report-entry.section{ color: var(--success-soft); font-weight: 700; margin-top: 14px; }
.report-entry.success{ color: var(--success); font-weight: 600; }
.report-entry.warning{ color: var(--warning); font-weight: 600; }
.report-entry.plain{ color: var(--text); }
.report-entry.error{ color: var(--warning); font-weight: 600; text-align:center; }

@media (max-width: 900px){
  .app-shell{
    flex-direction: column;
    height: auto;
  }
  .image-panel{ height: 380px; }
  .controls-panel{ flex: 1 1 auto; }
  .control-card{ margin: 12px; }
  .report-box{ margin: 0 12px 12px 12px; max-height: 420px; }
}
