:root {
  color-scheme: light;
  --ink: #10171a;
  --muted: #667579;
  --paper: #f5f8f7;
  --surface: #ffffff;
  --line: #dce7e4;
  --charcoal: #071014;
  --panel: #0e1a1e;
  --teal: #21c7b8;
  --blue: #376df4;
  --green: #21835f;
  --amber: #c88726;
  --coral: #ee7154;
  --radius: 8px;
  --sidebar-width: 280px;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  color: var(--ink);
  background: var(--paper);
  letter-spacing: 0;
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  display: grid;
  grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
  min-height: 100svh;
}

.case-sidebar {
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
  height: 100svh;
  padding: 14px;
  color: #f7fbfa;
  background: #0a1418;
  border-right: 1px solid rgba(255, 255, 255, 0.1);
}

.sidebar-top,
.header-actions,
.model-toolbar {
  display: flex;
  align-items: center;
}

.sidebar-top {
  justify-content: space-between;
  min-height: 42px;
}

.app-brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  color: inherit;
  font-weight: 780;
  text-decoration: none;
}

.brand-mark {
  width: 26px;
  height: 26px;
  flex: 0 0 auto;
  border: 2px solid var(--teal);
  border-radius: 50%;
  background:
    radial-gradient(circle at 70% 35%, var(--coral) 0 12%, transparent 13%),
    radial-gradient(circle at 50% 50%, rgba(33, 199, 184, 0.2), transparent 58%);
  box-shadow: 0 0 22px rgba(33, 199, 184, 0.34);
}

.icon-button {
  width: 36px;
  height: 36px;
  display: inline-grid;
  place-items: center;
  color: rgba(247, 251, 250, 0.72);
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 999px;
}

.new-case-button,
.primary-button,
.ghost-button {
  min-height: 44px;
  border-radius: 999px;
  font-weight: 780;
}

.new-case-button {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  margin: 20px 0 14px;
  color: var(--charcoal);
  background: var(--teal);
  border: 0;
}

.new-case-button .label-text {
  color: inherit;
}

.new-case-button span:first-child {
  font-size: 20px;
  line-height: 1;
}

.case-search {
  display: grid;
  gap: 8px;
  margin-bottom: 14px;
  color: rgba(247, 251, 250, 0.56);
  font-size: 12px;
  font-weight: 720;
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.case-search input {
  width: 100%;
  min-height: 40px;
  padding: 0 12px;
  color: #f7fbfa;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 999px;
  outline: none;
}

.case-search input::placeholder {
  color: rgba(247, 251, 250, 0.36);
}

.case-list {
  display: grid;
  gap: 8px;
  overflow: auto;
  padding-right: 2px;
}

.case-item {
  display: grid;
  grid-template-columns: 10px minmax(0, 1fr);
  gap: 12px;
  align-items: center;
  width: 100%;
  min-height: 68px;
  padding: 12px;
  color: rgba(247, 251, 250, 0.78);
  text-align: left;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius);
}

.case-item:hover,
.case-item.active {
  background: rgba(255, 255, 255, 0.07);
  border-color: rgba(255, 255, 255, 0.12);
}

.case-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.case-dot.waiting {
  background: var(--teal);
  box-shadow: 0 0 14px rgba(33, 199, 184, 0.55);
}

.case-dot.done {
  background: var(--green);
}

.case-dot.review {
  background: var(--amber);
}

.case-copy {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.case-copy strong,
.case-copy small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.case-copy strong {
  color: #ffffff;
  font-size: 14px;
}

.case-copy small {
  color: rgba(247, 251, 250, 0.56);
  font-size: 12px;
}

.sidebar-foot {
  display: grid;
  gap: 5px;
  margin-top: auto;
  padding: 14px;
  color: rgba(247, 251, 250, 0.55);
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.sidebar-foot strong {
  color: rgba(247, 251, 250, 0.82);
  font-size: 13px;
}

.case-workspace {
  display: grid;
  grid-template-rows: auto 1fr;
  min-width: 0;
  min-height: 100svh;
  background: var(--paper);
}

.workspace-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  min-height: 78px;
  padding: 18px 28px;
  background: rgba(245, 248, 247, 0.9);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(14px);
}

.workspace-header p,
.status-label {
  margin: 0 0 5px;
  color: var(--green);
  font-size: 12px;
  font-weight: 840;
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.workspace-header h1 {
  margin: 0;
  color: var(--ink);
  font-size: clamp(22px, 3vw, 34px);
  line-height: 1.05;
  letter-spacing: 0;
}

.header-actions {
  gap: 10px;
  flex: 0 0 auto;
}

.primary-button,
.ghost-button {
  padding: 0 18px;
}

.primary-button {
  color: var(--charcoal);
  background: var(--teal);
  border: 1px solid var(--teal);
}

.primary-button.small,
.ghost-button {
  min-height: 38px;
  font-size: 14px;
}

.ghost-button {
  color: var(--ink);
  background: #ffffff;
  border: 1px solid var(--line);
}

.view {
  display: none;
  min-height: 0;
}

.view.active {
  display: grid;
}

.empty-panel,
.processing-panel {
  place-items: center;
  padding: 32px;
}

.upload-card,
.processing-card {
  width: min(760px, 100%);
}

.upload-target {
  position: relative;
  display: grid;
  justify-items: center;
  padding: clamp(34px, 6vw, 64px);
  text-align: center;
  background: #ffffff;
  border: 1px dashed #b9cbc6;
  border-radius: var(--radius);
  box-shadow: 0 20px 60px rgba(16, 23, 26, 0.08);
}

.upload-target.dragging {
  border-color: var(--teal);
  background: #effbf9;
}

.upload-target input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.upload-icon {
  width: 74px;
  height: 74px;
  margin-bottom: 20px;
  border: 2px solid var(--teal);
  border-radius: 50%;
  background:
    linear-gradient(var(--teal), var(--teal)) center 25px / 30px 3px no-repeat,
    linear-gradient(var(--teal), var(--teal)) center 25px / 3px 30px no-repeat,
    radial-gradient(circle at 50% 50%, rgba(33, 199, 184, 0.12), transparent 62%);
}

.upload-target h2,
.processing-card h2,
.review-panel h2 {
  margin: 0 0 12px;
  color: var(--ink);
  font-size: clamp(30px, 5vw, 54px);
  line-height: 1;
  letter-spacing: 0;
}

.upload-target p,
.processing-card p,
.review-panel p {
  max-width: 540px;
  margin: 0 0 24px;
  color: var(--muted);
  font-size: 17px;
  line-height: 1.55;
}

.processing-card {
  display: grid;
  gap: 22px;
  justify-items: center;
  padding: clamp(30px, 5vw, 54px);
  text-align: center;
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 20px 60px rgba(16, 23, 26, 0.08);
}

.processing-visual {
  position: relative;
  width: 160px;
  height: 160px;
}

.scan-ring {
  position: absolute;
  inset: 20px;
  border: 2px solid rgba(33, 199, 184, 0.22);
  border-top-color: var(--teal);
  border-radius: 50%;
  animation: spin 1.2s linear infinite;
}

.scan-ring.delayed {
  inset: 42px;
  border-top-color: var(--blue);
  animation-duration: 1.8s;
  animation-direction: reverse;
}

.scan-line {
  position: absolute;
  left: 44px;
  right: 44px;
  top: 28px;
  height: 2px;
  background: var(--teal);
  box-shadow: 0 0 18px rgba(33, 199, 184, 0.76);
  animation: scan 1.8s ease-in-out infinite;
}

.progress-track {
  width: min(520px, 100%);
  height: 9px;
  overflow: hidden;
  background: #e3eeeb;
  border-radius: 999px;
}

.progress-track span {
  display: block;
  width: 8%;
  height: 100%;
  background: linear-gradient(90deg, var(--teal), var(--blue));
  border-radius: inherit;
  transition: width 320ms ease;
}

.processing-steps {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  width: min(640px, 100%);
  margin: 0;
  padding: 0;
  list-style: none;
}

.step {
  min-height: 42px;
  display: grid;
  place-items: center;
  padding: 0 10px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 760;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 999px;
}

.step.active {
  color: var(--charcoal);
  background: rgba(33, 199, 184, 0.18);
  border-color: rgba(33, 199, 184, 0.5);
}

.case-panel {
  grid-template-columns: minmax(0, 1fr) minmax(280px, 360px);
  gap: 18px;
  padding: 22px;
}

.model-stage,
.review-panel {
  overflow: hidden;
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 14px 42px rgba(16, 23, 26, 0.08);
}

.model-stage {
  display: grid;
  grid-template-rows: auto 1fr;
  min-height: 0;
}

.model-toolbar {
  justify-content: space-between;
  min-height: 52px;
  padding: 0 16px;
  color: var(--muted);
  font-size: 13px;
  border-bottom: 1px solid var(--line);
}

.model-toolbar span:first-child {
  color: var(--ink);
  font-weight: 780;
}

.model-frame {
  position: relative;
  min-height: 0;
  background: var(--charcoal);
}

.model-frame img {
  width: 100%;
  height: 100%;
  min-height: 520px;
  object-fit: cover;
  object-position: 62% center;
  opacity: 0;
  transform: scale(1.02);
  animation: modelIn 720ms ease forwards;
}

.model-badge {
  position: absolute;
  left: 18px;
  bottom: 18px;
  padding: 9px 12px;
  color: #071014;
  font-size: 13px;
  font-weight: 820;
  background: var(--teal);
  border-radius: 999px;
}

.review-panel {
  padding: 22px;
}

.summary-list {
  margin: 18px 0 22px;
}

.summary-list div {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  padding: 13px 0;
  border-bottom: 1px solid var(--line);
}

.summary-list dt {
  color: var(--muted);
  font-size: 12px;
  font-weight: 820;
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.summary-list dd {
  margin: 0;
  color: var(--ink);
  font-weight: 800;
  text-align: right;
}

.review-actions {
  display: grid;
  gap: 10px;
}

.review-actions .primary-button,
.review-actions .ghost-button {
  width: 100%;
}

.app-shell.sidebar-collapsed {
  --sidebar-width: 76px;
}

.sidebar-collapsed .case-sidebar {
  align-items: center;
}

.sidebar-collapsed .brand-text,
.sidebar-collapsed .label-text,
.sidebar-collapsed .case-copy,
.sidebar-collapsed .case-search,
.sidebar-collapsed .sidebar-foot {
  display: none;
}

.sidebar-collapsed .sidebar-top {
  justify-content: center;
}

.sidebar-collapsed .icon-button {
  position: absolute;
  top: 14px;
  right: 10px;
  width: 28px;
  height: 28px;
}

.sidebar-collapsed .new-case-button {
  width: 44px;
  padding: 0;
}

.sidebar-collapsed .case-item {
  width: 44px;
  min-height: 44px;
  grid-template-columns: 1fr;
  place-items: center;
  padding: 0;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@keyframes scan {
  0%,
  100% {
    transform: translateY(0);
    opacity: 0.35;
  }
  50% {
    transform: translateY(104px);
    opacity: 1;
  }
}

@keyframes modelIn {
  to {
    opacity: 1;
    transform: scale(1);
  }
}

@media (max-width: 920px) {
  .app-shell,
  .app-shell.sidebar-collapsed {
    grid-template-columns: 1fr;
  }

  .case-sidebar {
    position: relative;
    height: auto;
    min-height: 0;
  }

  .case-list {
    max-height: 230px;
    overflow: auto;
    padding-bottom: 4px;
  }

  #collapse-sidebar {
    display: none;
  }

  .workspace-header,
  .case-panel {
    grid-template-columns: 1fr;
  }

  .workspace-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .case-panel {
    display: grid;
  }

  .model-frame img {
    min-height: 380px;
    object-position: 68% center;
  }
}

@media (max-width: 640px) {
  .case-sidebar {
    padding: 12px;
  }

  .workspace-header {
    padding: 16px;
  }

  .header-actions {
    width: 100%;
  }

  .header-actions button {
    flex: 1;
  }

  .empty-panel,
  .processing-panel,
  .case-panel {
    padding: 16px;
  }

  .upload-target,
  .processing-card {
    padding: 28px 18px;
  }

  .processing-steps {
    grid-template-columns: 1fr;
  }

  .summary-list div {
    align-items: flex-start;
    flex-direction: column;
    gap: 4px;
  }

  .summary-list dd {
    text-align: left;
  }

  .model-frame img {
    min-height: 330px;
    object-position: 70% center;
  }
}
