.app-card {
  background: var(--bg-card);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-xl);
  border: 1px solid var(--border-color);
  overflow: hidden;
  position: relative;
  min-height: 520px;
  display: flex;
  flex-direction: column;
}

.card-body {
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  flex: 1;
}

@media (min-width: 640px) {
  .card-body {
    padding: 2rem;
  }
}

.drop-zone {
  border: 2.5px dashed #cbd5e1;
  border-radius: var(--radius-lg);
  padding: 4rem 2rem;
  text-align: center;
  cursor: pointer;
  background-color: #fafafc;
  transition: all 0.2s ease;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex: 1;
  min-height: 460px;
}

.drop-zone:hover, .drop-zone.dragover {
  border-color: var(--border-hover);
  background-color: var(--primary-light);
}

.drop-zone-icon {
  width: 76px;
  height: 76px;
  color: var(--text-main);
  margin-bottom: 1.5rem;
}

.drop-title {
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 0.35rem;
}

.drop-select-link {
  color: var(--primary);
  text-decoration: underline;
  cursor: pointer;
}

.drop-subtitle {
  font-size: 0.95rem;
  color: var(--text-light);
  margin-top: 0.65rem;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.75rem 1.5rem;
  font-size: 0.95rem;
  font-weight: 600;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.2s ease;
  text-decoration: none;
  font-family: inherit;
  white-space: nowrap;
}

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

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

.btn-outline {
  background-color: transparent;
  border-color: var(--border-color);
  color: var(--text-main);
}

.btn-outline:hover {
  background-color: #f1f5f9;
}

.btn-ghost {
  background-color: transparent;
  color: var(--text-main);
  padding: 0.5rem 0.75rem;
}

.btn-ghost:hover {
  background-color: #f1f5f9;
}

.state-container {
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  flex: 1;
  width: 100%;
  min-height: 460px;
}

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

.loading-preview-wrapper {
  position: relative;
  width: 100%;
  max-height: 300px;
  overflow: hidden;
  border-radius: var(--radius-md);
  display: flex;
  justify-content: center;
}

.loading-preview-img {
  max-width: 100%;
  max-height: 280px;
  object-fit: contain;
  border-radius: var(--radius-md);
  opacity: 0.4;
}

.loading-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
}

.loading-title {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-main);
}

.loading-sub {
  font-size: 0.9rem;
  color: var(--text-muted);
}

.result-image-box {
  width: 100%;
  max-height: 360px;
  border-radius: var(--radius-lg);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 1.5rem;
  padding: 0.5rem;
}

.result-img {
  max-width: 100%;
  max-height: 340px;
  object-fit: contain;
}

.button-group {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  width: 100%;
  max-width: 360px;
}

@media (min-width: 480px) {
  .button-group {
    flex-direction: row;
  }
  .button-group .btn {
    flex: 1;
  }
}

.error-icon-box {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background-color: var(--danger-bg);
  color: var(--danger-text);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 1rem;
}

.dropdown {
  position: relative;
  display: inline-block;
}

.dropdown-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--text-main);
  background: none;
  border: none;
  cursor: pointer;
  padding: 0.5rem;
  border-radius: var(--radius-sm);
}

.dropdown-toggle:hover {
  background-color: #f1f5f9;
}

.dropdown-menu {
  position: absolute;
  top: 100%;
  left: 0;
  min-width: 220px;
  background-color: #ffffff;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-xl);
  padding: 0.5rem 0;
  display: none;
  z-index: 50;
  margin-top: 0.25rem;
}

.dropdown-menu.show {
  display: block;
}

.dropdown-item {
  display: block;
  padding: 0.6rem 1.25rem;
  color: var(--text-main);
  text-decoration: none;
  font-size: 0.9rem;
  transition: background 0.15s ease;
}

.dropdown-item:hover {
  background-color: #f1f5f9;
  color: var(--primary);
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background-color: rgba(0, 0, 0, 0.5);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 1rem;
  overflow-y: auto;
}

.modal-backdrop.show {
  display: flex;
}

.modal-dialog {
  background: #ffffff;
  border-radius: var(--radius-xl);
  max-width: 680px;
  width: 100%;
  padding: 2rem;
  box-shadow: var(--shadow-xl);
  position: relative;
  max-height: calc(100vh - 2rem);
  overflow-y: auto;
}

.modal-close-btn {
  position: absolute;
  top: 1.25rem;
  right: 1.25rem;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-light);
}

.modal-close-btn:hover {
  color: var(--text-main);
}

.steps-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
  margin-top: 1.5rem;
}

@media (min-width: 640px) {
  .steps-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

.step-card {
  background-color: #f8fafc;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.25rem 1rem;
  text-align: center;
}

.step-num {
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--primary);
  margin-bottom: 0.5rem;
}

.step-icon-wrapper {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 0.75rem auto;
}

.step-title {
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: 0.25rem;
  color: var(--text-main);
}

.step-desc {
  font-size: 0.85rem;
  color: var(--text-muted);
  line-height: 1.4;
}

.step-1-icon { background: #dbeafe; color: #2563eb; }
.step-2-icon { background: #dcfce7; color: #16a34a; }
.step-3-icon { background: #f3e8ff; color: #9333ea; }

.auth-modal-dialog {
  max-width: 380px;
  padding: 1.85rem 1.65rem;
}

.auth-header {
  text-align: center;
  margin-bottom: 1.5rem;
}

.auth-icon-badge {
  width: 48px;
  height: 48px;
  border-radius: 14px;
  background: var(--primary-light);
  color: var(--primary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 0.75rem;
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.12);
}

.auth-title {
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 0.3rem;
}

.auth-subtitle {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.floating-group {
  position: relative;
  margin-bottom: 1.25rem;
}

.floating-input {
  width: 100%;
  height: 46px;
  padding: 0 2.4rem 0 0.95rem;
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--text-main);
  background-color: #ffffff;
  border: 1.5px solid var(--border-color);
  border-radius: var(--radius-md);
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
  font-family: inherit;
}

.floating-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.floating-input.has-error {
  border-color: var(--danger-text);
  background-color: #fff8f8;
}

.floating-label {
  position: absolute;
  top: 50%;
  left: 0.95rem;
  transform: translateY(-50%);
  font-size: 0.92rem;
  color: var(--text-muted);
  pointer-events: none;
  transition: all 0.18s cubic-bezier(0.16, 1, 0.3, 1);
  transform-origin: left top;
  user-select: none;
  padding: 0 4px;
  background: transparent;
  z-index: 2;
}

.floating-input:focus ~ .floating-label,
.floating-input:not(:placeholder-shown) ~ .floating-label,
.floating-input:-webkit-autofill ~ .floating-label {
  top: 0;
  left: 0.75rem;
  transform: translateY(-50%) scale(0.82);
  color: var(--primary);
  background-color: #ffffff;
  font-weight: 600;
}

.floating-input.has-error ~ .floating-label {
  color: var(--danger-text);
}

.input-icon-left {
  position: absolute;
  left: 0.9rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-light);
  display: flex;
  align-items: center;
  pointer-events: none;
  transition: color 0.2s ease;
}

.floating-input:focus ~ .input-icon-left {
  color: var(--primary);
}

.input-action-right {
  position: absolute;
  right: 0.75rem;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: var(--text-light);
  cursor: pointer;
  padding: 0.35rem;
  display: flex;
  align-items: center;
  border-radius: var(--radius-sm);
  transition: color 0.15s ease;
}

.input-action-right:hover {
  color: var(--text-main);
}

.auth-alert {
  display: none;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1rem;
  border-radius: var(--radius-md);
  font-size: 0.875rem;
  margin-bottom: 1.25rem;
  animation: fadeIn 0.2s ease;
}

.auth-alert.error {
  display: flex;
  background-color: var(--danger-bg);
  color: var(--danger-text);
  border: 1px solid rgba(220, 38, 38, 0.2);
}

.auth-alert.success {
  display: flex;
  background-color: #dcfce7;
  color: #15803d;
  border: 1px solid rgba(21, 128, 61, 0.2);
}

.btn-block {
  width: 100%;
}

.btn-auth-submit {
  height: 48px;
  font-size: 1rem;
  position: relative;
}

.btn-auth-submit .btn-spinner {
  display: none;
  width: 20px;
  height: 20px;
  border: 2.5px solid rgba(255, 255, 255, 0.3);
  border-left-color: #ffffff;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

.btn-auth-submit.loading .btn-spinner {
  display: inline-block;
}

.btn-auth-submit.loading .btn-text {
  display: none;
}

.user-badge-container {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

.user-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.4rem 0.85rem;
  background-color: var(--primary-light);
  color: var(--primary);
  border-radius: 9999px;
  font-size: 0.85rem;
  font-weight: 600;
  border: 1px solid rgba(37, 99, 235, 0.15);
}

.btn-logout {
  padding: 0.4rem 0.65rem;
  font-size: 0.85rem;
  color: var(--text-muted);
  background: none;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-logout:hover {
  background-color: var(--danger-bg);
  color: var(--danger-text);
  border-color: transparent;
}

.photopea-mode {
  background: #ffffff;
  min-height: 100vh;
  height: 100vh;
  margin: 0;
  padding: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.photopea-mode .site-header,
.photopea-mode .hero-column,
.photopea-mode .footer,
.photopea-mode .drop-zone,
.photopea-mode .web-result-content {
  display: none !important;
}

.photopea-mode .main-content {
  padding: 1rem;
  margin: 0;
  max-width: 100%;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.photopea-mode .card-column {
  max-width: 100%;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
}

.photopea-mode .app-card {
  box-shadow: none;
  border: none;
  background: transparent;
  border-radius: 0;
  min-height: auto;
  width: 100%;
  height: auto;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.photopea-mode .card-body {
  padding: 0;
  height: auto;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 0.6rem;
}

.photopea-mode .state-container {
  min-height: auto;
  height: auto;
  display: none;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  width: 100%;
}

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

.photopea-mode .photopea-auth-bar {
  width: 100%;
  margin-bottom: 0.6rem;
  padding-bottom: 0.6rem;
  border-bottom: 1px solid var(--border-color);
}

.photopea-mode .btn-photopea-main {
  width: 100%;
  padding: 0.75rem 1rem;
  font-size: 0.92rem;
  font-weight: 600;
  border-radius: var(--radius-md);
}

.photopea-mode .photopea-success-box {
  display: flex !important;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 0;
  width: 100%;
}

.photopea-mode .photopea-success-icon {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background-color: #dcfce7;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 0.35rem;
}

.photopea-mode .photopea-success-box h3 {
  font-size: 0.95rem;
  margin-bottom: 0.15rem;
}

.photopea-mode .photopea-success-box p {
  font-size: 0.78rem;
  margin-bottom: 0.5rem;
}

.photopea-mode #btnPhotopeaReset {
  padding: 0.4rem;
  font-size: 0.82rem;
}
/* Photopea-mode Auth Modal Fixes */
.photopea-mode .modal-backdrop {
  align-items: flex-start;
  padding: 0.5rem;
  overflow-y: auto;
}

.photopea-mode .auth-modal-dialog {
  padding: 1rem;
  margin: 10px auto;
}

.photopea-mode .auth-icon-badge {
  display: none;
}

.photopea-mode .auth-header {
  margin-bottom: 0.75rem;
}

.photopea-mode .auth-title {
  font-size: 1.15rem;
  margin-bottom: 0;
}

.photopea-mode .auth-subtitle {
  display: none;
}

.photopea-mode .floating-group {
  margin-bottom: 0.75rem;
}

.photopea-mode .floating-input {
  height: 42px;
}
.photopea-mode .auth-modal-dialog {
  width: 90%;
  max-width: 320px;
}
.photopea-mode .main-content {
  flex: 1;
}

.photopea-mode .modal-backdrop {
  align-items: center;
}

.photopea-mode .auth-alert {
  position: static;
  width: 100%;
  max-width: 100%;
  font-size: 0.8rem;
  padding: 0.45rem 0.65rem;
  margin-bottom: 0.65rem;
  text-align: center;
  justify-content: center;
  box-shadow: none;
}

.photopea-mode .loading-preview-img {
  display: none;
}

.photopea-mode .loading-preview-wrapper {
  min-height: 120px;
}

.photopea-mode .loading-overlay {
  position: static;
  padding: 20px 0;
}
