:root {
  --primary: #10b981;
  --primary-hover: #059669;
  --text: #0a0a0a;
  --text-secondary: #404040;
  --text-muted: #737373;
  --bg: #fafafa;
  --bg-dark: #0a0a0a;
  --border: #e5e5e5;
  --sidebar-width: 260px;
}

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

body {
  font-family: "Inter", system-ui, sans-serif;
  background: var(--bg-dark);
  min-height: 100vh;
  overflow: hidden;
}

/* Layout */
.app-layout {
  display: flex;
  min-height: 100vh;
}

/* Sidebar */
.sidebar {
  width: var(--sidebar-width);
  background: #fff;
  display: flex;
  flex-direction: column;
  position: relative;
}

.sidebar-close {
  display: none;
  position: absolute;
  top: 12px;
  right: 12px;
  width: 32px;
  height: 32px;
  border: none;
  background: var(--bg);
  border-radius: 6px;
  cursor: pointer;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  z-index: 10;
}

.sidebar-close:hover {
  background: var(--border);
  color: var(--text);
}

.sidebar-content {
  flex: 1;
  padding: 28px 24px;
  overflow-y: auto;
}

.sidebar-header {
  margin-bottom: 24px;
}

.header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}

.sidebar-header h1 {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
}

.sidebar-header p {
  font-size: 0.8125rem;
  color: var(--text-muted);
  line-height: 1.5;
}

.sidebar-section {
  margin-bottom: 24px;
}

.sidebar-section:last-child {
  margin-bottom: 0;
}

.sidebar-desc {
  font-size: 0.8125rem;
  color: var(--text-muted);
  line-height: 1.6;
  margin: 0;
}

.sidebar-desc strong {
  color: var(--text);
  font-weight: 500;
}

.section-label {
  font-size: 0.625rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 12px;
}

.tech-item {
  margin-bottom: 12px;
}

.tech-item:last-child {
  margin-bottom: 0;
}

.tech-item strong {
  display: block;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text);
  margin-bottom: 2px;
}

.tech-item p {
  font-size: 0.75rem;
  color: var(--text-muted);
  line-height: 1.5;
  margin: 0;
}

/* Sidebar Footer */
.sidebar-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 12px;
}

.sponsor-logo {
  width: 32px;
  height: 32px;
  border-radius: 6px;
  object-fit: cover;
}

.footer-text {
  flex: 1;
}

.footer-text p {
  font-size: 0.6875rem;
  color: var(--text-muted);
  line-height: 1.4;
  margin: 0;
}

.footer-text a {
  color: var(--text-secondary);
  text-decoration: none;
  font-weight: 500;
}

.footer-text a:hover {
  color: var(--primary);
  text-decoration: underline;
}

.footer-text strong {
  font-weight: 500;
  color: var(--text-secondary);
}

.lang-switcher {
  display: flex;
  background: var(--bg);
  border-radius: 6px;
  padding: 2px;
  gap: 2px;
}

.lang-option {
  padding: 6px 10px;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  text-decoration: none;
  border-radius: 4px;
  transition: all 0.15s;
}

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

.lang-option.active {
  background: var(--primary);
  color: #fff;
}

/* Main Content */
.main-content {
  flex: 1;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* States */
.state-container {
  position: absolute;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
}

.state-container.active {
  display: flex;
}

/* Upload */
.upload-wrapper {
  text-align: center;
  max-width: 560px;
  width: 100%;
  padding: 20px;
}

.upload-card {
  margin-bottom: 32px;
}

.upload-zone {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 48px 40px;
  border: 2px dashed rgba(255,255,255,0.15);
  border-radius: 16px;
  cursor: pointer;
  transition: all 0.25s;
  background: rgba(255,255,255,0.02);
}

.upload-zone:hover,
.upload-zone.dragover {
  border-color: var(--primary);
  background: rgba(16, 185, 129, 0.08);
}

.upload-zone.dragover {
  transform: scale(1.01);
}

.upload-icon {
  color: rgba(255,255,255,0.25);
  margin-bottom: 16px;
  transition: all 0.25s;
}

.upload-zone:hover .upload-icon,
.upload-zone.dragover .upload-icon {
  color: var(--primary);
  transform: translateY(-4px);
}

.upload-text {
  font-size: 1rem;
  font-weight: 500;
  color: rgba(255,255,255,0.9);
  margin-bottom: 6px;
}

.upload-hint {
  font-size: 0.8rem;
  color: rgba(255,255,255,0.4);
}

.examples-section {
  text-align: center;
}

.examples-label {
  display: block;
  font-size: 0.75rem;
  font-weight: 500;
  color: rgba(255,255,255,0.4);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 12px;
}

.examples-grid {
  display: flex;
  justify-content: center;
  gap: 10px;
}

.example-thumb {
  position: relative;
  width: 64px;
  height: 64px;
  border-radius: 10px;
  border: 2px solid transparent;
  background: transparent;
  padding: 0;
  cursor: pointer;
  overflow: hidden;
  transition: all 0.2s;
}

.example-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 8px;
  transition: all 0.2s;
}

.example-thumb:hover {
  border-color: var(--primary);
  transform: translateY(-2px);
}

.example-thumb:hover img {
  opacity: 0.8;
}

.example-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,0.4);
  color: #fff;
  font-size: 0.85rem;
  font-weight: 600;
  opacity: 0;
  transition: opacity 0.2s;
}

.example-thumb:hover .example-overlay {
  opacity: 1;
}

.example-thumb.active {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.2);
}

/* Crop */
.crop-wrapper {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  padding: 24px;
}

.crop-header {
  text-align: center;
  margin-bottom: 20px;
}

.crop-step {
  margin-bottom: 12px;
}

.step-badge {
  display: inline-block;
  padding: 4px 12px;
  background: rgba(255,255,255,0.1);
  border-radius: 20px;
  font-size: 0.7rem;
  font-weight: 600;
  color: rgba(255,255,255,0.6);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.crop-header h2 {
  font-size: 1.1rem;
  font-weight: 600;
  color: #fff;
  margin-bottom: 6px;
}

.crop-header p {
  font-size: 0.85rem;
  color: rgba(255,255,255,0.5);
}

.crop-area {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 0;
  overflow: hidden;
  background: rgba(0,0,0,0.3);
  border-radius: 12px;
  position: relative;
}

.crop-area img {
  max-width: calc(100% - 80px);
  max-height: calc(100% - 80px);
}

.crop-actions {
  display: flex;
  justify-content: center;
  gap: 12px;
  margin-top: 20px;
}

/* Processing */
.processing-wrapper {
  display: flex;
  align-items: center;
  justify-content: center;
}

.processing-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 24px;
}

.processing-image-container {
  position: relative;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 20px 60px rgba(0,0,0,0.5);
}

.processing-image-container img {
  max-width: 70vw;
  max-height: 60vh;
  display: block;
}

.tile-grid-overlay {
  position: absolute;
  inset: 0;
  display: grid;
  pointer-events: none;
}

.tile-cell {
  border: 1px solid rgba(255,255,255,0.1);
  background: rgba(0,0,0,0.3);
  transition: all 0.3s ease-out;
}

.tile-cell.processing {
  background: rgba(16, 185, 129, 0.3);
  border-color: var(--primary);
  box-shadow: inset 0 0 20px rgba(16, 185, 129, 0.4);
  animation: pulse-tile 0.6s ease-in-out infinite;
}

.tile-cell.completed {
  background: transparent;
  border-color: rgba(16, 185, 129, 0.3);
}

@keyframes pulse-tile {
  0%, 100% {
    background: rgba(16, 185, 129, 0.2);
  }
  50% {
    background: rgba(16, 185, 129, 0.4);
  }
}

.tile-progress {
  position: absolute;
  top: 16px;
  right: 16px;
  padding: 8px 14px;
  background: rgba(0,0,0,0.7);
  border-radius: 20px;
  font-size: 0.85rem;
  font-weight: 600;
  color: #fff;
  backdrop-filter: blur(10px);
}

.tile-current {
  color: var(--primary);
}

.tile-separator {
  color: rgba(255,255,255,0.4);
  margin: 0 2px;
}

.tile-total {
  color: rgba(255,255,255,0.6);
}

.processing-info {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 16px 28px;
  background: rgba(255,255,255,0.05);
  border-radius: 16px;
  border: 1px solid rgba(255,255,255,0.1);
  min-width: 280px;
}

.progress-bar-container {
  width: 100%;
  height: 6px;
  background: rgba(255,255,255,0.1);
  border-radius: 3px;
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--primary), #34d399);
  border-radius: 3px;
  transition: width 0.3s ease-out;
}

.processing-text {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

.processing-title {
  font-size: 0.9rem;
  font-weight: 500;
  color: #fff;
}

.processing-subtitle {
  font-size: 0.75rem;
  color: rgba(255,255,255,0.5);
}

/* Results */
.results-wrapper {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
}

.results-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  background: rgba(0,0,0,0.6);
  border-bottom: 1px solid rgba(255,255,255,0.08);
  backdrop-filter: blur(10px);
  position: relative;
}

.results-left {
  display: flex;
  align-items: center;
  gap: 16px;
}

.results-center {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
}

.results-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn-back {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  background: rgba(255,255,255,0.08);
  border: none;
  border-radius: 8px;
  color: rgba(255,255,255,0.7);
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
}

.btn-back:hover {
  background: rgba(255,255,255,0.15);
  color: #fff;
}

.btn-back span {
  display: inline;
}

.results-count {
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.count-number {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--primary);
  line-height: 1;
}

.count-label {
  font-size: 0.8rem;
  color: rgba(255,255,255,0.5);
}

.view-tabs {
  display: flex;
  background: rgba(255,255,255,0.08);
  border-radius: 10px;
  padding: 4px;
  gap: 4px;
}

.view-tab {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border: none;
  background: transparent;
  color: rgba(255,255,255,0.5);
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  border-radius: 7px;
  transition: all 0.2s;
}

.view-tab svg {
  opacity: 0.7;
}

.view-tab:hover {
  color: rgba(255,255,255,0.8);
  background: rgba(255,255,255,0.05);
}

.view-tab.active {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 2px 8px rgba(16, 185, 129, 0.3);
}

.view-tab.active svg {
  opacity: 1;
}

.btn-action {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  background: rgba(255,255,255,0.08);
  border: none;
  border-radius: 8px;
  color: rgba(255,255,255,0.8);
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
}

.btn-action:hover {
  background: var(--primary);
  color: #fff;
}

/* Results Image - Centered with free movement */
.results-image-container {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  position: relative;
  background: rgba(0,0,0,0.2);
}

.results-image-container img {
  max-width: 90%;
  max-height: 90%;
  cursor: grab;
  border-radius: 8px;
  box-shadow: 0 10px 40px rgba(0,0,0,0.4);
}

.results-image-container img:active {
  cursor: grabbing;
}

.zoom-controls {
  position: absolute;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  background: rgba(0,0,0,0.7);
  border-radius: 24px;
  border: 1px solid rgba(255,255,255,0.1);
  backdrop-filter: blur(10px);
}

.zoom-btn {
  width: 32px;
  height: 32px;
  border: none;
  background: rgba(255,255,255,0.1);
  color: rgba(255,255,255,0.8);
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
}

.zoom-btn:hover {
  background: var(--primary);
  color: #fff;
}

.zoom-level {
  font-size: 0.75rem;
  font-weight: 600;
  color: rgba(255,255,255,0.6);
  min-width: 44px;
  text-align: center;
}

/* Compare View */
.results-compare-container {
  flex: 1;
  display: flex;
  align-items: stretch;
  overflow: hidden;
  background: rgba(0,0,0,0.2);
}

.compare-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 20px;
  position: relative;
  overflow: hidden;
}

.compare-label {
  position: absolute;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  padding: 6px 14px;
  background: rgba(0,0,0,0.6);
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 500;
  color: rgba(255,255,255,0.8);
  z-index: 1;
}

.compare-panel img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  border-radius: 8px;
  box-shadow: 0 10px 40px rgba(0,0,0,0.4);
}

.compare-divider {
  width: 2px;
  background: rgba(255,255,255,0.1);
}

/* Buttons */
.btn {
  padding: 8px 16px;
  border: none;
  border-radius: 6px;
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
}

.btn-primary:hover {
  background: var(--primary-hover);
}

.btn-ghost {
  background: rgba(255,255,255,0.1);
  color: #fff;
}

.btn-ghost:hover {
  background: rgba(255,255,255,0.15);
}

.btn-icon {
  width: 36px;
  height: 36px;
  padding: 0;
  background: rgba(255,255,255,0.1);
  color: #fff;
  border-radius: 6px;
}

.btn-icon:hover {
  background: rgba(255,255,255,0.15);
}

/* Mobile Toggle */
.sidebar-toggle {
  display: none;
  position: fixed;
  top: 12px;
  left: 12px;
  width: 40px;
  height: 40px;
  border: none;
  background: #fff;
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
  cursor: pointer;
  z-index: 200;
  align-items: center;
  justify-content: center;
  transition: opacity 0.2s;
}

/* Cropper overrides */
.cropper-container {
  max-width: 100%;
  max-height: 100%;
}

.cropper-view-box {
  outline-color: var(--primary);
  outline-width: 2px;
}

.cropper-line {
  background: var(--primary);
}

.cropper-point {
  background: var(--primary);
  width: 14px;
  height: 14px;
  opacity: 1;
  border-radius: 2px;
}

.cropper-point.point-e,
.cropper-point.point-w {
  margin-top: -7px;
}

.cropper-point.point-n,
.cropper-point.point-s {
  margin-left: -7px;
}

.cropper-point.point-ne,
.cropper-point.point-nw,
.cropper-point.point-se,
.cropper-point.point-sw {
  width: 16px;
  height: 16px;
}

.cropper-modal {
  background: rgba(0, 0, 0, 0.5);
}

/* Mobile */
@media (max-width: 768px) {
  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    transform: translateX(-100%);
    transition: transform 0.25s;
    z-index: 100;
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .sidebar-toggle {
    display: flex;
  }

  .sidebar-close {
    display: flex;
  }

  .main-content {
    padding-top: 56px;
  }

  .results-header {
    flex-wrap: wrap;
    gap: 12px;
    padding: 12px 16px;
  }

  .results-left {
    order: 1;
  }

  .results-center {
    position: static;
    transform: none;
    order: 3;
    width: 100%;
  }

  .results-right {
    order: 2;
    margin-left: auto;
  }

  .view-tabs {
    width: 100%;
    justify-content: center;
    flex-wrap: wrap;
    gap: 4px;
  }

  .view-tab {
    flex: 1;
    min-width: 0;
    justify-content: center;
    padding: 10px 6px;
  }

  .view-tab span {
    display: none;
  }

  .btn-action span,
  .btn-back span {
    display: none;
  }

  .btn-back {
    padding: 8px;
  }

  .examples-grid {
    gap: 8px;
  }

  .example-thumb {
    width: 56px;
    height: 56px;
  }

  .upload-zone {
    padding: 36px 24px;
  }

  .count-number {
    font-size: 1.5rem;
  }

  /* Compare view on mobile */
  .results-compare-container {
    flex-direction: column;
  }

  .compare-divider {
    width: 100%;
    height: 2px;
  }

  .compare-panel {
    padding: 16px;
  }
}
