/* Night theme surface polish. The canvas background remains untouched. */
:root {
  --night-line: rgba(155, 179, 219, .18);
  --night-line-strong: rgba(175, 199, 240, .32);
  --night-blue: #91bfff;
  --night-lilac: #c6b8ff;
  --night-green: #d6f58b;
  --night-surface: rgba(20, 28, 43, .92);
  --night-surface-deep: rgba(10, 16, 29, .78);
  --night-shadow: 0 22px 58px rgba(0, 0, 0, .34);
}

/* Shared glass edge used by the registration theme. */
.topbar,
.panel,
.canvas-toolbar,
.selection-tools,
.library,
.prompt-library,
.canvas-manager,
#accountDialog,
.job,
.references,
.tiers button,
.panel textarea,
.panel select {
  isolation: isolate;
}

.topbar::after,
.panel::after,
.canvas-toolbar::after,
.selection-tools::after,
.library::after,
.prompt-library::after,
.canvas-manager::after,
#accountDialog::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  padding: 1px;
  pointer-events: none;
  opacity: .72;
  background: linear-gradient(112deg, transparent 8%, rgba(168, 200, 255, .04) 28%, rgba(214, 245, 139, .42) 50%, rgba(187, 163, 255, .12) 70%, transparent 92%);
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
}

.topbar {
  background:
    radial-gradient(420px 90px at 74% 0%, rgba(116, 157, 235, .12), transparent 72%),
    linear-gradient(180deg, rgba(27, 37, 58, .97), rgba(17, 24, 38, .93));
  border-bottom-color: rgba(159, 186, 234, .26);
  box-shadow: 0 12px 35px rgba(0, 0, 0, .22), inset 0 -1px rgba(192, 217, 255, .08);
}

.topbar .wordmark {
  filter: drop-shadow(0 0 14px rgba(143, 191, 255, .2));
}

.topbar .divider {
  border-color: rgba(166, 194, 236, .25);
}

.top-actions > .quiet {
  border: 1px solid transparent;
  box-shadow: inset 0 1px rgba(255, 255, 255, .045);
}

.top-actions > .quiet:hover {
  border-color: rgba(160, 192, 243, .36);
  background: linear-gradient(135deg, rgba(128, 167, 237, .14), rgba(207, 190, 255, .08));
  box-shadow: 0 0 20px rgba(116, 158, 236, .12), inset 0 1px rgba(255, 255, 255, .12);
}

.topbar .user-badge {
  box-shadow: 0 0 0 1px rgba(214, 245, 139, .05), 0 0 18px rgba(214, 245, 139, .08);
}

.sync {
  text-shadow: 0 0 12px rgba(176, 227, 149, .26);
}

.panel {
  background:
    radial-gradient(360px 240px at 70% 0%, rgba(111, 148, 226, .15), transparent 72%),
    linear-gradient(180deg, rgba(29, 40, 61, .985), rgba(17, 24, 38, .985) 58%, rgba(13, 19, 31, .99));
  border-left-color: rgba(157, 186, 231, .28);
  box-shadow: -20px 0 52px rgba(0, 0, 0, .24), inset 1px 0 rgba(212, 229, 255, .06);
  scrollbar-color: rgba(151, 185, 235, .4) transparent;
}

.panel::before {
  content: "";
  position: absolute;
  top: 0;
  left: 18px;
  right: 18px;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(214, 245, 139, .62), rgba(150, 189, 255, .55), transparent);
  box-shadow: 0 0 18px rgba(168, 197, 255, .3);
  pointer-events: none;
}

.panel-heading {
  padding: 4px 0 18px;
  margin-bottom: 22px;
  border-bottom: 1px solid rgba(166, 194, 236, .17);
}

.panel-heading h2 {
  letter-spacing: -.035em;
  text-shadow: 0 0 20px rgba(176, 198, 255, .14);
}

.panel-heading h2 span {
  color: #e0f6a7;
  text-shadow: 0 0 10px rgba(214, 245, 139, .7), 0 0 26px rgba(214, 245, 139, .32);
}

.panel .eyebrow {
  color: #a9b9d5;
  text-shadow: 0 0 14px rgba(156, 194, 255, .24);
}

.panel .field-title {
  color: #d5dff0;
  letter-spacing: .015em;
}

.panel .field-title small {
  color: #8395b0;
}

.panel textarea,
.panel select {
  background:
    linear-gradient(145deg, rgba(15, 24, 42, .94), rgba(8, 15, 28, .9));
  border-color: rgba(151, 181, 228, .25);
  box-shadow: inset 0 1px rgba(255, 255, 255, .045), 0 8px 22px rgba(0, 0, 0, .12);
}

.panel textarea {
  min-height: 136px;
  line-height: 1.8;
  border-radius: 14px;
}

.panel textarea:hover,
.panel select:hover {
  border-color: rgba(161, 195, 245, .48);
}

.panel textarea:focus,
.panel select:focus {
  border-color: rgba(214, 245, 139, .7);
  box-shadow: 0 0 0 3px rgba(214, 245, 139, .1), 0 0 26px rgba(129, 170, 242, .13), inset 0 1px rgba(255, 255, 255, .08);
}

.prompt-open,
.panel .quiet {
  transition: .2s ease;
}

.prompt-open:hover,
.panel .quiet:hover {
  box-shadow: 0 0 16px rgba(196, 227, 145, .14);
}

.references {
  min-height: 68px;
  border-color: rgba(133, 167, 222, .32);
  background:
    linear-gradient(135deg, rgba(111, 146, 214, .08), rgba(16, 25, 42, .35)),
    repeating-linear-gradient(135deg, transparent 0 10px, rgba(188, 213, 255, .025) 10px 11px);
  box-shadow: inset 0 1px rgba(255, 255, 255, .035), 0 0 18px rgba(100, 147, 230, .06);
}

.references p {
  color: #8fa1bc;
}

.references img {
  box-shadow: 0 0 0 1px rgba(214, 245, 139, .18), 0 4px 14px rgba(0, 0, 0, .3);
}

.tiers {
  gap: 8px;
}

.tiers button {
  background: linear-gradient(145deg, rgba(43, 57, 80, .58), rgba(17, 25, 41, .7));
  border-color: rgba(143, 174, 222, .24);
  box-shadow: inset 0 1px rgba(255, 255, 255, .035);
}

.tiers button:hover {
  border-color: rgba(175, 207, 255, .52);
  box-shadow: 0 0 20px rgba(122, 165, 239, .12), inset 0 1px rgba(255, 255, 255, .08);
  transform: translateY(-1px);
}

.tiers button.active {
  background: linear-gradient(145deg, rgba(90, 118, 68, .52), rgba(43, 61, 43, .72));
  border-color: rgba(214, 245, 139, .72);
  box-shadow: 0 0 0 1px rgba(214, 245, 139, .12), 0 0 26px rgba(173, 215, 91, .15), inset 0 1px rgba(240, 255, 201, .16);
}

.field-row {
  gap: 10px;
  margin-bottom: 10px;
}

.field-row label {
  color: #9eacc2;
}

#generate {
  border-radius: 13px;
  min-height: 52px;
  letter-spacing: .015em;
  background: linear-gradient(115deg, #e4f8ba 0%, #cde99b 42%, #e9f9bc 68%, #bfdf86 100%);
  box-shadow: 0 8px 24px rgba(174, 219, 99, .2), 0 0 0 1px rgba(244, 255, 205, .28), inset 0 1px rgba(255, 255, 255, .55);
}

#generate:hover {
  box-shadow: 0 11px 32px rgba(174, 219, 99, .3), 0 0 24px rgba(214, 245, 139, .17), inset 0 1px rgba(255, 255, 255, .72);
}

#generate::before {
  content: "";
  position: absolute;
  inset: 1px;
  border-radius: inherit;
  border: 1px solid rgba(255, 255, 255, .28);
  pointer-events: none;
}

.history-heading {
  margin-top: 4px;
  border-top-color: rgba(166, 194, 236, .2);
}

.history-heading h3 {
  letter-spacing: .05em;
  text-transform: uppercase;
  color: #c7d6ed;
}

.history-heading span {
  min-width: 23px;
  padding: 3px 7px;
  border: 1px solid rgba(155, 184, 230, .24);
  border-radius: 999px;
  background: rgba(119, 156, 224, .1);
  color: #b7cff3;
  text-align: center;
}

.job {
  border-color: rgba(137, 168, 218, .23);
  background: linear-gradient(135deg, rgba(29, 44, 67, .68), rgba(13, 21, 35, .74));
  box-shadow: inset 0 1px rgba(255, 255, 255, .035), 0 8px 24px rgba(0, 0, 0, .16);
}

.job::before {
  content: "";
  position: absolute;
  inset: 9px auto 9px 0;
  width: 2px;
  border-radius: 2px;
  background: linear-gradient(180deg, transparent, rgba(159, 198, 255, .8), transparent);
  box-shadow: 0 0 12px rgba(132, 180, 255, .4);
}

.job:hover {
  border-color: rgba(173, 204, 252, .46);
  box-shadow: 0 0 24px rgba(99, 145, 222, .12), inset 0 1px rgba(255, 255, 255, .08);
}

.job p {
  color: #cfdaec;
}

.canvas-toolbar,
.selection-tools {
  background:
    radial-gradient(180px 80px at 20% 0%, rgba(136, 180, 255, .16), transparent 72%),
    linear-gradient(180deg, rgba(41, 55, 78, .94), rgba(21, 30, 47, .92));
  border-color: rgba(151, 181, 228, .38);
  box-shadow: 0 20px 48px rgba(0, 0, 0, .32), 0 0 26px rgba(94, 146, 228, .08), inset 0 1px rgba(255, 255, 255, .1);
}

.canvas-toolbar button:hover {
  background: linear-gradient(145deg, rgba(132, 178, 250, .24), rgba(192, 171, 255, .14));
  box-shadow: 0 0 16px rgba(130, 174, 245, .17);
}

.canvas-toolbar output {
  color: #d3e3fa;
}

.selection-tools {
  border-radius: 13px;
}

.selection-tools button {
  border: 1px solid rgba(154, 183, 229, .2);
  background: rgba(119, 153, 210, .14);
}

.selection-tools button:hover {
  border-color: rgba(181, 210, 255, .5);
  background: rgba(132, 174, 244, .22);
  box-shadow: 0 0 16px rgba(127, 173, 249, .14);
}

.node {
  border-color: rgba(134, 168, 221, .48);
  box-shadow: 0 16px 38px rgba(0, 0, 0, .28), 0 0 0 1px rgba(165, 193, 235, .06);
}

.node:hover {
  border-color: rgba(187, 214, 255, .76);
  box-shadow: 0 18px 44px rgba(0, 0, 0, .33), 0 0 22px rgba(122, 170, 244, .15);
}

.node.selected {
  border-color: rgba(214, 245, 139, .9);
  box-shadow: 0 0 0 3px rgba(214, 245, 139, .18), 0 0 30px rgba(174, 218, 103, .18), 0 18px 44px rgba(0, 0, 0, .32);
}

.node-footer {
  background: linear-gradient(180deg, rgba(29, 43, 64, .92), rgba(15, 24, 39, .98));
}

.canvas-hint {
  color: #8fa3c1;
  text-shadow: 0 1px 10px rgba(0, 0, 0, .5);
}

/* Keep the light theme calm while retaining the same spacing hierarchy. */
:root[data-theme="light"] .topbar {
  background: linear-gradient(180deg, rgba(255, 255, 255, .96), rgba(247, 250, 253, .94));
  border-bottom-color: rgba(89, 119, 151, .2);
}

:root[data-theme="light"] .panel {
  background: linear-gradient(180deg, rgba(255, 255, 255, .98), rgba(246, 249, 252, .98));
  border-left-color: rgba(92, 121, 150, .2);
}

:root[data-theme="light"] .panel textarea,
:root[data-theme="light"] .panel select {
  background: #fff;
  border-color: #c9d5e1;
  box-shadow: inset 0 1px #fff, 0 6px 16px rgba(62, 86, 112, .07);
}

:root[data-theme="light"] .references {
  background: #f7fafc;
  border-color: #b9c9d8;
}

:root[data-theme="light"] .tiers button {
  background: #f4f7fa;
  border-color: #cbd7e2;
}

:root[data-theme="light"] .tiers button.active {
  background: #eaf3dc;
  border-color: #91ad70;
  box-shadow: 0 0 0 1px rgba(117, 151, 79, .12);
}

:root[data-theme="light"] .job {
  background: #f9fbfd;
  border-color: #d1dce7;
  box-shadow: 0 7px 20px rgba(62, 86, 112, .08);
}

:root[data-theme="light"] .job p {
  color: #42556b;
}

@keyframes studio-edge-sheen {
  0%, 55% { opacity: .26; transform: translateX(-42%); }
  100% { opacity: .72; transform: translateX(42%); }
}

@keyframes studio-control-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(164, 203, 255, 0); }
  50% { box-shadow: 0 0 0 5px rgba(164, 203, 255, .06), 0 0 22px rgba(129, 177, 248, .11); }
}

:root[data-motion="on"] .topbar::after,
:root[data-motion="on"] .panel::after,
:root[data-motion="on"] .canvas-toolbar::after,
:root[data-motion="on"] .selection-tools::after,
:root[data-motion="on"] .library::after,
:root[data-motion="on"] .prompt-library::after,
:root[data-motion="on"] .canvas-manager::after,
:root[data-motion="on"] #accountDialog::after {
  animation: studio-edge-sheen 4.6s ease-in-out infinite alternate;
}

:root[data-motion="on"] .panel-heading h2 span,
:root[data-motion="on"] .canvas-toolbar #uploadBtn,
:root[data-motion="on"] .canvas-toolbar #themeToggle {
  animation: studio-control-pulse 3.8s ease-in-out infinite;
}

@media (max-width: 640px) {
  .panel-heading { padding-bottom: 10px; margin-bottom: 12px; }
  .panel textarea { min-height: 86px; }
  .panel::before { left: 12px; right: 12px; }
}
