:root {
  --bg: #08111f;
  --bg-soft: #101c31;
  --surface: rgba(12, 22, 40, 0.82);
  --surface-strong: rgba(15, 28, 48, 0.96);
  --surface-alt: rgba(255, 255, 255, 0.05);
  --border: rgba(166, 194, 255, 0.14);
  --border-strong: rgba(128, 169, 255, 0.24);
  --text: #edf3ff;
  --muted: #9ab0d3;
  --accent: #72e4ff;
  --accent-strong: #3bc8ff;
  --accent-warm: #ff9f70;
  --shadow: 0 20px 60px rgba(0, 0, 0, 0.4);
  --radius-xl: 28px;
  --radius-lg: 20px;
  --radius-md: 14px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Noto Sans SC", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(59, 200, 255, 0.18), transparent 28%),
    radial-gradient(circle at bottom right, rgba(255, 159, 112, 0.16), transparent 24%),
    linear-gradient(160deg, #040814 0%, #08111f 40%, #0b1730 100%);
  min-height: 100vh;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.03) 1px, transparent 1px);
  background-size: 48px 48px;
  mask-image: radial-gradient(circle at center, black 36%, transparent 100%);
  opacity: 0.25;
}

button,
input,
textarea {
  font: inherit;
}

.app-shell {
  position: relative;
  z-index: 1;
  padding: 24px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 22px;
  border: 1px solid var(--border);
  background: rgba(8, 17, 31, 0.84);
  backdrop-filter: blur(22px);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow);
}

.brand-block {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand-mark {
  width: 52px;
  height: 52px;
  border-radius: 18px;
  display: grid;
  place-items: center;
  font-family: "Space Grotesk", sans-serif;
  font-size: 20px;
  font-weight: 700;
  background: linear-gradient(135deg, rgba(114, 228, 255, 0.28), rgba(255, 159, 112, 0.26));
  border: 1px solid rgba(114, 228, 255, 0.28);
}

.brand-title,
.panel-title,
.card-title,
.section-title {
  font-family: "Space Grotesk", sans-serif;
}

.brand-title {
  font-size: 24px;
  font-weight: 700;
}

.brand-subtitle,
.panel-note,
.card-note,
.section-title,
.meter-label,
.status-pill,
.empty-state,
.field-label,
.tag,
.work-caption,
.sidebar-meta {
  color: var(--muted);
}

.status-strip {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.status-pill {
  padding: 10px 14px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface-alt);
  font-size: 13px;
}

.status-pill.accent {
  color: var(--text);
  border-color: rgba(114, 228, 255, 0.32);
}

.workspace {
  display: grid;
  grid-template-columns: 280px minmax(0, 1.08fr) minmax(320px, 0.62fr);
  gap: 18px;
  margin-top: 18px;
}

.sidebar,
.panel {
  border: 1px solid var(--border);
  background: var(--surface);
  backdrop-filter: blur(20px);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow);
}

.sidebar {
  display: flex;
  flex-direction: column;
  padding: 18px;
  gap: 16px;
}

.section-title {
  font-size: 14px;
  margin-bottom: 10px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.sidebar-list {
  display: grid;
  gap: 10px;
  max-height: 260px;
  overflow: auto;
}

.works-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.sidebar-card,
.work-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.04);
}

.sidebar-card {
  padding: 12px;
  cursor: pointer;
}

.sidebar-card:hover,
.template-chip:hover,
.result-card-item:hover,
.work-card:hover,
.primary-btn:hover,
.secondary-btn:hover,
.ghost-btn:hover,
.copy-btn:hover,
.task-tab:hover,
.icon-chip:hover {
  transform: translateY(-1px);
  border-color: var(--border-strong);
}

.sidebar-card.active {
  border-color: rgba(114, 228, 255, 0.34);
  background: rgba(114, 228, 255, 0.08);
}

.sidebar-title {
  font-size: 14px;
  color: var(--text);
  margin-bottom: 4px;
}

.sidebar-footer {
  margin-top: auto;
  padding-top: 10px;
}

.meter-label {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  margin-bottom: 8px;
}

.meter-track {
  height: 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  overflow: hidden;
}

.meter-fill {
  height: 100%;
  width: 0;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent-strong), var(--accent-warm));
}

.panel {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 20px 22px 16px;
  border-bottom: 1px solid var(--border);
}

.panel-title {
  font-size: 22px;
  font-weight: 700;
}

.panel-body {
  padding: 20px;
}

.panel-grid,
.side-stack,
.output-stack,
.conversation-list {
  display: grid;
  gap: 16px;
}

.card {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface-strong);
  padding: 18px;
}

.card-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.card-title {
  font-size: 18px;
  font-weight: 600;
}

.task-tabs,
.template-row,
.upload-toolbar,
.action-bar,
.result-actions,
.output-actions,
.tag-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.task-tab,
.template-chip,
.primary-btn,
.secondary-btn,
.ghost-btn,
.copy-btn,
.icon-chip {
  border: 1px solid var(--border);
  border-radius: 999px;
  transition: transform 0.18s ease, border-color 0.18s ease, background 0.18s ease;
}

.task-tab,
.template-chip,
.secondary-btn,
.copy-btn,
.ghost-btn,
.icon-chip {
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
}

.task-tab,
.template-chip,
.secondary-btn,
.ghost-btn,
.copy-btn,
.icon-chip {
  padding: 10px 14px;
  cursor: pointer;
}

.task-tab.active,
.template-chip.active,
.primary-btn,
.icon-chip.active {
  background: linear-gradient(135deg, rgba(59, 200, 255, 0.22), rgba(255, 159, 112, 0.2));
  border-color: rgba(114, 228, 255, 0.34);
}

.primary-btn {
  color: #05111f;
  font-weight: 700;
}

.full {
  width: 100%;
}

.dynamic-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.field {
  display: grid;
  gap: 8px;
}

.field.full {
  grid-column: 1 / -1;
}

.field-input,
.notes-input {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  padding: 12px 14px;
  outline: none;
}

.field-input:focus,
.notes-input:focus {
  border-color: rgba(114, 228, 255, 0.36);
  box-shadow: 0 0 0 3px rgba(114, 228, 255, 0.08);
}

.notes-input {
  min-height: 120px;
  resize: vertical;
}

.reference-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(126px, 1fr));
  gap: 12px;
  margin-top: 14px;
}

.reference-card,
.result-card-item {
  position: relative;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.03);
}

.reference-card img,
.result-card-item img,
.work-card img,
.modal-media img {
  width: 100%;
  display: block;
  object-fit: cover;
}

.reference-card img,
.work-card img,
.result-card-item img {
  aspect-ratio: 1 / 1;
}

.reference-meta,
.result-meta,
.work-caption {
  padding: 10px;
}

.tag,
.icon-chip {
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 12px;
}

.result-grid {
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.result-title,
.output-title {
  font-size: 15px;
  color: var(--text);
  margin-bottom: 8px;
}

.assistant-intro {
  display: grid;
  gap: 8px;
  line-height: 1.7;
}

.message,
.output-block {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  line-height: 1.7;
  background: rgba(255, 255, 255, 0.04);
}

.message.user {
  border-color: rgba(255, 159, 112, 0.22);
}

.message.assistant {
  border-color: rgba(114, 228, 255, 0.22);
}

.message-role {
  font-size: 12px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  margin-bottom: 6px;
}

.message.user .message-role {
  color: var(--accent-warm);
}

.message.assistant .message-role {
  color: var(--accent);
}

.output-content {
  white-space: pre-wrap;
}

.empty-state {
  border: 1px dashed var(--border);
  border-radius: var(--radius-md);
  padding: 16px;
  text-align: center;
  line-height: 1.7;
}

.large {
  padding: 42px 20px;
}

.modal.hidden {
  display: none;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 20;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(3, 8, 14, 0.74);
  backdrop-filter: blur(6px);
}

.modal-panel {
  position: relative;
  z-index: 1;
  width: min(980px, calc(100vw - 32px));
  max-height: calc(100vh - 32px);
  overflow: auto;
  margin: 16px auto;
  border-radius: var(--radius-xl);
  border: 1px solid var(--border);
  background: rgba(9, 18, 33, 0.98);
  box-shadow: var(--shadow);
  padding: 16px;
}

.modal-close {
  margin-left: auto;
  display: block;
  padding: 10px 14px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  cursor: pointer;
}

.modal-media img {
  border-radius: var(--radius-lg);
  margin-top: 12px;
}

.modal-meta {
  margin-top: 14px;
  display: grid;
  gap: 12px;
}

.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 25;
  padding: 14px 16px;
  border-radius: var(--radius-md);
  background: rgba(8, 17, 31, 0.92);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}

@media (max-width: 1240px) {
  .workspace {
    grid-template-columns: 260px minmax(0, 1fr);
  }

  .panel-side {
    grid-column: 2;
  }
}

@media (max-width: 940px) {
  .app-shell {
    padding: 14px;
  }

  .topbar,
  .workspace {
    display: block;
  }

  .status-strip {
    margin-top: 12px;
    justify-content: flex-start;
  }

  .sidebar,
  .panel {
    margin-top: 14px;
  }

  .dynamic-form,
  .result-grid {
    grid-template-columns: 1fr;
  }
}
