:root {
  --auth-viewport-height: 100dvh;
  --bg-1: #120f24;
  --bg-2: #211f3e;
  --bg-3: #0a1120;
  --line: rgba(130, 236, 221, 0.18);
  --line-strong: rgba(130, 236, 221, 0.42);
  --card: rgba(17, 18, 39, 0.76);
  --card-strong: rgba(24, 25, 52, 0.9);
  --text: #f5f8ff;
  --muted: #adb6d5;
  --teal: #68efd8;
  --teal-strong: #25c2aa;
  --amber: #ffc34e;
  --danger: #ff7f8d;
  --shadow: 0 24px 60px rgba(0, 0, 0, 0.42);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  font-family: 'Space Grotesk', sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(255, 195, 78, 0.18), transparent 28%),
    radial-gradient(circle at top right, rgba(104, 239, 216, 0.18), transparent 24%),
    linear-gradient(150deg, var(--bg-1), var(--bg-2) 48%, var(--bg-3));
}

body {
  position: relative;
}

html.bee-auth-mode,
html.bee-auth-mode body {
  height: var(--auth-viewport-height);
  max-height: var(--auth-viewport-height);
  overflow: hidden;
}

html.bee-auth-mode body .app-shell {
  height: var(--auth-viewport-height);
  max-height: var(--auth-viewport-height);
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding-bottom: max(24px, env(safe-area-inset-bottom));
}

.page-bg {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.03) 1px, transparent 1px);
  background-size: 38px 38px;
  mask-image: radial-gradient(circle at center, black 30%, transparent 100%);
  opacity: 0.35;
}

.app-shell {
  position: relative;
  z-index: 1;
  max-width: 1480px;
  margin: 0 auto;
  padding: 24px;
}

.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 24px;
}

.brand {
  min-width: 0;
}

.brand-copy {
  display: grid;
  gap: 12px;
}

html.bee-auth-mode body .topbar {
  justify-content: center;
  margin-bottom: 30px;
}

html.bee-auth-mode body .brand {
  width: min(100%, 640px);
}

html.bee-auth-mode body .brand-copy {
  justify-items: center;
  text-align: center;
}

html.bee-auth-mode body .session-panel {
  display: none;
}

.brand-kicker,
.card-kicker {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  width: fit-content;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid rgba(255, 195, 78, 0.24);
  background: rgba(255, 195, 78, 0.12);
  color: #ffe7a8;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.brand-lockup {
  width: min(100%, 380px);
  height: auto;
  filter: drop-shadow(0 16px 34px rgba(0, 0, 0, 0.35));
}

.combined-brand-lockup {
  width: min(100%, 520px);
  justify-self: center;
  border-radius: 28px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow:
    0 18px 36px rgba(0, 0, 0, 0.32),
    0 0 0 1px rgba(104, 239, 216, 0.08);
}

.session-panel {
  display: flex;
  align-items: center;
  gap: 12px;
}

.session-chip {
  min-width: 180px;
  padding: 11px 16px;
  border-radius: 18px;
  border: 1px solid rgba(104, 239, 216, 0.24);
  background: rgba(6, 12, 27, 0.4);
  text-align: center;
  color: #ddfff8;
  font-weight: 700;
}

.hidden {
  display: none !important;
}

.login-section {
  display: grid;
  place-items: center;
  min-height: 52vh;
}

html.bee-auth-mode body .login-section {
  min-height: 0;
}

.login-card,
.panel {
  border: 1px solid var(--line);
  background: var(--card);
  backdrop-filter: blur(18px);
  box-shadow: var(--shadow);
}

.login-card {
  width: min(100%, 640px);
  padding: 28px;
  border-radius: 28px;
  scroll-margin-block: 16px;
}

.login-card h2,
.panel h2 {
  margin: 8px 0 6px;
  font-size: 1.38rem;
}

.login-card p,
.history-empty {
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
}

.login-grid,
.field-grid {
  display: grid;
  gap: 14px;
}

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

.login-grid {
  margin-top: 22px;
}

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

.login-card > .card-kicker {
  justify-self: start;
}

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

label > span,
.field > label,
.field > span {
  color: #eff4ff;
  font-weight: 600;
}

.label-line {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}

.label-line label {
  margin: 0;
  display: inline-flex;
  align-items: center;
  line-height: 1.1;
}

.field-help {
  position: relative;
  display: inline-flex;
  align-items: center;
}

.info-dot {
  width: 19px;
  height: 19px;
  border-radius: 999px;
  border: 1px solid rgba(125, 211, 252, 0.65);
  background: rgba(8, 27, 43, 0.95);
  color: #9fdbff;
  font-size: 0.74rem;
  font-weight: 700;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  line-height: 1;
}

.info-dot:focus-visible {
  outline: 2px solid #7dd3fc;
  outline-offset: 2px;
}

.tip {
  position: absolute;
  z-index: 12;
  top: calc(100% + 6px);
  left: 50%;
  transform: translate(-50%, -4px);
  min-width: 240px;
  max-width: min(340px, 70vw);
  padding: 10px 11px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  background: rgba(4, 14, 24, 0.97);
  color: #d8ebf7;
  font-size: 0.82rem;
  line-height: 1.35;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.38);
  opacity: 0;
  pointer-events: none;
}

.field-help:hover .tip,
.field-help:focus-within .tip,
.field-help.open .tip {
  opacity: 1;
  pointer-events: auto;
  transform: translate(-50%, 0);
}

input,
select,
button,
textarea {
  font: inherit;
}

input,
select,
textarea {
  width: 100%;
  padding: 13px 14px;
  border-radius: 16px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(34, 38, 63, 0.96);
  color: var(--text);
  outline: none;
}

select {
  background-image: linear-gradient(180deg, rgba(52, 57, 88, 0.98), rgba(33, 37, 61, 0.98));
}

select option,
select optgroup {
  background: #232844;
  color: var(--text);
}

input::placeholder {
  color: rgba(232, 236, 255, 0.44);
}

input:focus,
select:focus,
textarea:focus {
  border-color: rgba(104, 239, 216, 0.62);
  box-shadow: 0 0 0 4px rgba(104, 239, 216, 0.12);
}

input[type='file'] {
  padding: 12px;
}

input[type='range'] {
  padding: 0;
  background: transparent;
  box-shadow: none;
}

button {
  border: 0;
  cursor: pointer;
  transition: transform 0.16s ease, box-shadow 0.16s ease, opacity 0.16s ease;
}

button:hover {
  transform: translateY(-1px);
}

button:disabled {
  opacity: 0.46;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.primary-btn,
.secondary-btn,
.ghost-btn {
  padding: 12px 16px;
  border-radius: 16px;
  font-weight: 700;
}

.compact-btn {
  padding: 9px 12px;
  border-radius: 14px;
  font-size: 0.92rem;
}

.primary-btn {
  background: linear-gradient(135deg, var(--teal), #6de0ff);
  color: #07131f;
  box-shadow: 0 14px 30px rgba(41, 198, 186, 0.28);
}

.secondary-btn {
  background: rgba(255, 195, 78, 0.14);
  color: #ffe7a8;
  border: 1px solid rgba(255, 195, 78, 0.24);
}

.ghost-btn {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  border: 1px solid rgba(255, 255, 255, 0.12);
}

.session-panel a.ghost-btn {
  display: inline-flex;
  align-items: center;
  text-decoration: none;
}

.ghost-btn.danger {
  color: #ffd7dc;
  border-color: rgba(255, 127, 141, 0.24);
  background: rgba(255, 127, 141, 0.12);
}

.workspace-grid {
  display: grid;
  grid-template-columns: minmax(320px, 0.82fr) minmax(520px, 1.18fr);
  gap: 18px;
  align-items: start;
}

.controls-column,
.preview-column {
  display: grid;
  gap: 18px;
}

.preview-column {
  align-self: stretch;
  align-content: start;
}

.preview-stack {
  display: grid;
  gap: 14px;
  align-self: start;
}

.preview-panel {
  position: static;
}

.panel {
  border-radius: 22px;
  padding: 18px;
}

.panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.inline-actions,
.action-row,
.login-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.compact-actions {
  gap: 8px;
}

.login-actions {
  margin-top: 20px;
}

.style-panel {
  position: relative;
  overflow: hidden;
}

.style-panel::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  padding: 1px;
  background: linear-gradient(135deg, rgba(104, 239, 216, 0.5), rgba(255, 195, 78, 0.18), transparent 55%);
  -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  pointer-events: none;
}

.mini-tag {
  display: inline-flex;
  align-items: center;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  color: #d9e2ff;
  font-size: 0.82rem;
}

.meta-box {
  padding: 12px 14px;
  border-radius: 18px;
  border: 1px solid rgba(104, 239, 216, 0.12);
  background: rgba(5, 8, 18, 0.28);
  color: var(--muted);
  line-height: 1.55;
}

.editor-hint {
  margin-top: 14px;
  padding: 12px 14px;
  border-radius: 18px;
  border: 1px dashed rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.03);
  color: var(--muted);
  line-height: 1.5;
}

.field-grid.two.instructor-select-row {
  grid-template-columns: 1fr;
}

.instructor-editor {
  display: grid;
  gap: 14px;
  margin-top: 14px;
}

.instructor-editor .field-grid.two {
  grid-template-columns: 1fr;
}

.instructor-editor-actions {
  margin-top: 12px;
}

.fine-panel {
  display: grid;
  gap: 12px;
  padding: 16px;
  border-radius: 22px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(0, 0, 0, 0.15);
}

.fine-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  color: var(--muted);
}

.nudge-pad {
  display: grid;
  gap: 10px;
}

.nudge-pad {
  grid-template-columns: repeat(3, 54px);
  justify-content: center;
}

.nudge-pad button:nth-child(1) {
  grid-column: 2;
}

.nudge-pad button:nth-child(2) {
  grid-column: 1;
  grid-row: 2;
}

.nudge-pad button:nth-child(3) {
  grid-column: 3;
  grid-row: 2;
}

.nudge-pad button:nth-child(4) {
  grid-column: 2;
  grid-row: 3;
}

.nudge-pad button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  border-radius: 16px;
  background: radial-gradient(circle at top, rgba(255, 255, 255, 0.16), rgba(20, 24, 54, 0.92));
  color: #edf6ff;
  border: 1px solid rgba(163, 174, 255, 0.18);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.16);
}

.status {
  margin-top: 10px;
  padding: 11px 14px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.08);
  color: #dfeaff;
}

.status.ok {
  background: rgba(104, 239, 216, 0.12);
  color: #d9fff7;
}

.status.warn {
  background: rgba(255, 195, 78, 0.14);
  color: #ffe9b7;
}

.status.bad {
  background: rgba(255, 127, 141, 0.16);
  color: #ffdce1;
}

.progress-bar {
  width: 100%;
  height: 12px;
  margin-top: 14px;
  appearance: none;
}

.progress-bar::-webkit-progress-bar {
  background: rgba(255, 255, 255, 0.08);
  border-radius: 999px;
}

.progress-bar::-webkit-progress-value {
  border-radius: 999px;
  background: linear-gradient(90deg, var(--amber), var(--teal));
}

.preview-stage-wrap {
  position: relative;
  height: clamp(360px, 56vh, 620px);
  padding: 10px;
  border-radius: 20px;
  border: 1px dashed rgba(104, 239, 216, 0.2);
  background:
    radial-gradient(circle at top left, rgba(255, 195, 78, 0.08), transparent 28%),
    rgba(4, 8, 19, 0.42);
  overflow: hidden;
  display: grid;
  place-items: center;
}

.preview-tools {
  display: grid;
  gap: 12px;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.preview-tools h3 {
  margin: 0;
  font-size: 1.18rem;
}

#previewCanvas {
  display: block;
  width: auto;
  max-width: 100%;
  max-height: 100%;
  height: auto;
}

.preview-empty {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 28px;
  text-align: center;
  color: var(--muted);
}

.history-list {
  display: grid;
  gap: 12px;
}

.history-panel {
  position: relative;
  z-index: 1;
}

.nudge-wrap {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: center;
}

.nudge-grid {
  width: auto;
  display: grid;
  grid-template-columns: repeat(3, 52px);
  grid-template-rows: repeat(2, 46px);
  gap: 8px;
  justify-content: start;
}

.nudge-btn {
  width: 52px;
  min-height: 46px;
  padding: 0;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
  font-size: 1.2rem;
  font-weight: 700;
  box-shadow: none;
}

.nudge-btn:hover {
  background: rgba(125, 211, 252, 0.16);
}

.nudge-btn.empty {
  visibility: hidden;
}

.nudge-reset {
  width: auto;
  min-width: 96px;
  padding-inline: 14px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
  box-shadow: none;
}

.nudge-status {
  margin-top: 6px;
  color: var(--muted);
  font-size: 0.82rem;
}

.watermark-row {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) auto;
  gap: 12px;
  align-items: center;
}

.watermark-select-wrap select {
  width: 100%;
}

.watermark-offset-wrap,
.watermark-offset-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.watermark-offset-btn,
.watermark-offset-reset {
  width: auto;
  min-width: 46px;
  min-height: 42px;
  padding: 0 12px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
  box-shadow: none;
}

.watermark-offset-reset {
  min-width: 86px;
}

.range-control {
  display: grid;
  gap: 8px;
}

.range-grid,
.style-control-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.style-control-grid label {
  min-width: 0;
}

.style-control-grid input[type='color'] {
  min-height: 48px;
  padding: 5px;
}

.range-control-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.range-value {
  color: #c7f4ff;
  font-weight: 700;
}

.batch-card {
  padding: 16px;
  border-radius: 20px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.04);
}

.batch-card h3 {
  margin: 0 0 6px;
  font-size: 1rem;
}

.batch-card p {
  margin: 0;
  color: var(--muted);
  line-height: 1.45;
}

.batch-card .inline-actions {
  margin-top: 12px;
}

@media (max-width: 1180px) {
  .workspace-grid {
    grid-template-columns: 1fr;
  }

  .preview-stage-wrap {
    height: clamp(330px, 56vh, 600px);
  }
}

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

  .topbar {
    flex-direction: column;
  }

  .session-panel {
    width: 100%;
    justify-content: space-between;
  }

  .login-grid,
  .field-grid.two {
    grid-template-columns: 1fr;
  }

  html.bee-auth-mode body .topbar {
    margin-bottom: 18px;
  }

  html.bee-auth-mode body .brand-lockup {
    width: min(100%, 300px);
  }

  html.bee-auth-mode body .subbrand-lockup {
    width: min(100%, 480px);
    max-height: 34vh;
    object-fit: contain;
  }

  .login-card {
    padding: 22px 18px;
    border-radius: 22px;
  }

  .preview-stage-wrap {
    height: clamp(300px, 58vh, 560px);
  }

  .nudge-wrap {
    grid-template-columns: 1fr;
  }

  .nudge-reset {
    width: 100%;
  }

  .watermark-row {
    grid-template-columns: 1fr;
  }

  .watermark-offset-wrap {
    justify-content: stretch;
  }

  .watermark-offset-buttons {
    flex: 1;
  }

  .watermark-offset-btn,
  .watermark-offset-reset {
    flex: 1;
  }

  .range-grid,
  .style-control-grid {
    grid-template-columns: 1fr;
  }
}
