:root {
  color-scheme: light;
}

* {
  box-sizing: border-box;
}

body.app-body {
  margin: 0;
  height: 100vh;
  overflow: hidden;
  background: #f1f5f9;
  color: #0f172a;
  font-family: Inter, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

.app-shell {
  width: 100%;
  max-width: 1600px;
  margin: 0 auto;
  height: 100vh;
  padding: 0.9rem 1.1rem;
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr) auto;
  gap: 0.85rem;
}

.hero-card,
.panel,
.subtle-card,
.subtle-surface,
.bento-card {
  border-radius: 0.95rem;
  background: #ffffff;
  border: 1px solid #e2e8f0;
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.06);
}

.workspace {
  min-height: 0;
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr);
  gap: 0.85rem;
}

.sidebar {
  min-height: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 0.85rem;
}

.main-stage {
  min-height: 0;
  display: grid;
  grid-template-rows: minmax(220px, 1fr) auto auto;
  gap: 0.85rem;
}

.templates-card {
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.templates-body {
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.templates-scroll {
  flex: 1;
  min-height: 110px;
  overflow: auto;
  padding-right: 0.2rem;
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.55rem;
}

.preview-shell {
  border-radius: 0.8rem;
  border: 1px solid #e2e8f0;
  background: #f8fafc;
  overflow: hidden;
  min-height: 0;
  height: 100%;
}

.preview-empty {
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 0.95rem;
}

.preview-frame {
  width: 100%;
  height: 100%;
  min-height: 0;
  border: 0;
  background: #ffffff;
}

.primary-btn {
  border: 1px solid transparent;
  background: #0f172a;
  color: #ffffff;
  transition: transform 0.2s ease, background-color 0.2s ease, box-shadow 0.2s ease;
}

.primary-btn:hover {
  background: #1e293b;
  transform: translateY(-1px);
  box-shadow: 0 10px 20px rgba(15, 23, 42, 0.22);
}

.secondary-btn {
  border: 1px solid #cbd5e1 !important;
  background: #ffffff !important;
  color: #334155;
}

.secondary-btn:hover {
  border-color: #94a3b8 !important;
  background: #f8fafc !important;
}

.success-btn {
  border: 1px solid #0f766e !important;
  background: #0f766e !important;
  color: #ffffff;
}

.success-btn:hover {
  border-color: #115e59 !important;
  background: #115e59 !important;
}

input,
select,
textarea {
  border-radius: 0.75rem;
  border: 1px solid #cbd5e1;
  background: #ffffff;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

input:focus,
select:focus,
textarea:focus {
  border-color: #6366f1 !important;
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.14) !important;
  outline: none;
}

.dropzone {
  position: relative;
  border: 2px dashed #cbd5e1;
  border-radius: 0.85rem;
  background: #f8fafc;
  padding: 0.95rem;
  min-height: 198px;
  transition: border-color 0.2s ease, background-color 0.2s ease, transform 0.2s ease;
}

.dropzone:hover {
  border-color: #6366f1;
  background: #eff6ff;
}

.dropzone.dragover {
  border-color: #4f46e5;
  background: #eef2ff;
  transform: scale(0.995);
}

.template-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 0.7rem;
}

.template-card {
  position: relative;
  min-height: 116px;
  border: 1px solid #dbe2ef;
  border-radius: 0.9rem;
  background: #ffffff;
  padding: 0.82rem;
  text-align: left;
  transition: border-color 0.16s ease, box-shadow 0.16s ease, transform 0.16s ease;
}

.template-card:hover {
  border-color: #a5b4fc;
  box-shadow: 0 8px 18px rgba(79, 70, 229, 0.12);
  transform: translateY(-1px);
}

.template-card.is-active {
  border-color: #4f46e5;
  box-shadow: 0 10px 20px rgba(79, 70, 229, 0.16);
  background: #f8faff;
}

.template-card-icon {
  height: 2rem;
  width: 2rem;
  border-radius: 0.65rem;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  background: #e8eefb;
}

.template-card-title {
  margin-top: 0.52rem;
  color: #0f172a;
  font-size: 0.9rem;
  font-weight: 600;
}

.template-card-desc {
  margin-top: 0.25rem;
  color: #64748b;
  font-size: 0.74rem;
  line-height: 1.3;
}

.template-card-check {
  position: absolute;
  top: 0.52rem;
  right: 0.52rem;
  width: 1.08rem;
  height: 1.08rem;
  border-radius: 999px;
  background: #4f46e5;
  color: #ffffff;
  font-size: 0.7rem;
  display: none;
  align-items: center;
  justify-content: center;
}

.template-card.is-active .template-card-check {
  display: inline-flex;
}

.status-top {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.5rem;
  align-items: center;
}

.query-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.5rem;
  align-items: center;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: rgba(15, 23, 42, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.modal-card {
  width: min(560px, 100%);
  border-radius: 0.95rem;
  background: #ffffff;
  box-shadow: 0 24px 46px rgba(15, 23, 42, 0.24);
  border: 1px solid #e2e8f0;
}

.progress-overlay-card {
  width: min(460px, 100%);
  border-radius: 0.95rem;
  background: #ffffff;
  box-shadow: 0 26px 52px rgba(15, 23, 42, 0.26);
  border: 1px solid #e2e8f0;
}

.mini-muted {
  color: #64748b;
  font-size: 0.76rem;
}

@media (max-width: 1200px), (max-height: 760px) {
  body.app-body {
    height: auto;
    overflow: auto;
  }

  .app-shell {
    height: auto;
    min-height: 100vh;
    grid-template-rows: auto auto auto auto;
    padding: 0.7rem;
  }

  .workspace {
    grid-template-columns: 1fr;
    min-height: auto;
  }

  .sidebar,
  .main-stage {
    min-height: auto;
    grid-template-rows: auto;
  }

  .templates-scroll {
    max-height: 320px;
  }

  .preview-frame {
    min-height: 240px;
    height: 320px;
  }
}

