:root {
  --ink: #eef4ec;
  --muted: #9ead9f;
  --paper: #07090d;
  --panel: rgba(16, 20, 25, 0.88);
  --panel-strong: #151b22;
  --line: rgba(211, 229, 210, 0.15);
  --accent: #d8833c;
  --accent-strong: #ffb36b;
  --accent-soft: rgba(216, 131, 60, 0.16);
  --green: #72d39a;
  --green-soft: rgba(114, 211, 154, 0.14);
  --danger: #ff817d;
  --danger-soft: rgba(255, 129, 125, 0.14);
  --shadow: 0 26px 90px rgba(0, 0, 0, 0.48);
  --radius: 20px;
  color-scheme: dark;
  font-family: "Inter", "Trebuchet MS", "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background:
    linear-gradient(115deg, rgba(216, 131, 60, 0.13), transparent 36%),
    linear-gradient(245deg, rgba(114, 211, 154, 0.1), transparent 38%),
    linear-gradient(180deg, #0b1016 0%, #07090d 48%, #050609 100%);
}

body::before {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  content: "";
  background-image:
    linear-gradient(rgba(238, 244, 236, 0.045) 1px, transparent 1px),
    linear-gradient(90deg, rgba(238, 244, 236, 0.035) 1px, transparent 1px);
  background-size: 34px 34px;
  mask-image: linear-gradient(to bottom, black, transparent 82%);
}

a {
  color: inherit;
}

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

button,
input,
select,
textarea,
.link-button {
  color-scheme: dark;
}

button,
.link-button {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.72rem 1rem;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.045);
  cursor: pointer;
  text-decoration: none;
  transition: transform 140ms ease, border-color 140ms ease, background 140ms ease, box-shadow 140ms ease;
}

button:hover,
.link-button:hover {
  transform: translateY(-1px);
  border-color: rgba(255, 179, 107, 0.42);
  background: rgba(255, 179, 107, 0.1);
}

.primary {
  border-color: transparent;
  color: #140d08;
  background: linear-gradient(135deg, var(--accent), var(--accent-strong));
  box-shadow: 0 12px 34px rgba(216, 131, 60, 0.22);
}

.auth-page {
  display: grid;
  place-items: center;
  padding: 2rem;
}

.auth-card {
  width: min(460px, 100%);
  padding: 2rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.auth-card h1,
.hero h1 {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(2.1rem, 5vw, 4.8rem);
  line-height: 0.94;
  letter-spacing: 0;
}

.auth-card h1 {
  font-size: clamp(2.1rem, 8vw, 3.8rem);
}

.stack {
  display: grid;
  gap: 1rem;
}

label {
  display: grid;
  gap: 0.4rem;
  color: var(--muted);
  font-size: 0.92rem;
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.checkbox-row input[type="checkbox"] {
  width: auto;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.86rem 1rem;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.055);
  outline: none;
}

option {
  color: var(--ink);
  background: #12171d;
}

input:focus,
select:focus,
textarea:focus {
  border-color: rgba(255, 179, 107, 0.5);
  box-shadow: 0 0 0 4px rgba(216, 131, 60, 0.14);
}

.alert {
  margin: 1rem 0;
  padding: 0.8rem 1rem;
  border: 1px solid rgba(255, 129, 125, 0.32);
  border-radius: 12px;
  color: var(--danger);
  background: var(--danger-soft);
}

.muted {
  color: var(--muted);
}

.hidden {
  display: none !important;
}

.eyebrow {
  margin: 0 0 0.45rem;
  color: var(--accent-strong);
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem clamp(1rem, 4vw, 3rem);
  border-bottom: 1px solid var(--line);
  background: rgba(7, 9, 13, 0.78);
  backdrop-filter: blur(20px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.75rem;
  text-decoration: none;
}

.brand small {
  display: block;
  color: var(--muted);
}

.brand-mark {
  display: grid;
  width: 44px;
  height: 44px;
  place-items: center;
  border-radius: 15px;
  color: #fffaf0;
  font-weight: 900;
  background: linear-gradient(135deg, var(--accent), #4c1f16);
  box-shadow: 0 0 28px rgba(216, 131, 60, 0.24);
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.top-actions form {
  margin: 0;
}

.top-actions a,
.top-actions .fullscreen-toggle {
  display: inline-flex;
  align-items: center;
  min-height: 38px;
  border: 1px solid rgba(255, 179, 107, 0.32);
  border-radius: 999px;
  padding: 0 0.85rem;
  color: var(--accent-strong);
  background: var(--accent-soft);
  font-weight: 800;
  text-decoration: none;
}

.user-menu {
  position: relative;
}

.user-menu-button {
  position: relative;
  min-height: 38px;
  padding-right: 2.1rem;
}

.user-menu-button::after {
  margin-left: 0.65rem;
  content: "v";
  color: var(--accent-strong);
  font-size: 0.75rem;
}

.user-menu-panel {
  position: absolute;
  top: calc(100% + 0.6rem);
  right: 0;
  z-index: 60;
  display: grid;
  width: min(260px, calc(100vw - 2rem));
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(16, 20, 25, 0.96);
  box-shadow: var(--shadow);
}

.menu-action {
  width: 100%;
  border: 0;
  border-radius: 0;
  padding: 0.9rem 1rem;
  text-align: left;
  background: transparent;
}

.menu-action:hover {
  transform: none;
  background: var(--accent-soft);
}

.mode {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.55rem 0.8rem;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.045);
}

.page {
  width: min(1180px, calc(100% - 2rem));
  margin: 0 auto;
  padding: 3rem 0 5rem;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: center;
  padding: 1rem;
  background: rgba(3, 5, 8, 0.74);
  backdrop-filter: blur(10px);
}

.account-modal {
  width: min(460px, 100%);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.35rem;
  background: var(--panel-strong);
  box-shadow: var(--shadow);
}

.modal-head,
.presence-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
}

.modal-head h2,
.presence-head h2 {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.55rem;
}

.presence-toggle {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  z-index: 45;
  border-color: rgba(114, 211, 154, 0.34);
  color: var(--green);
  background: var(--green-soft);
}

.presence-drawer {
  position: fixed;
  top: 92px;
  right: 1rem;
  bottom: 1rem;
  z-index: 40;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  width: min(330px, calc(100vw - 2rem));
  gap: 1rem;
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 1rem;
  background: rgba(16, 20, 25, 0.94);
  box-shadow: var(--shadow);
  transform: translateX(calc(100% + 1.5rem));
  transition: transform 180ms ease;
  backdrop-filter: blur(18px);
}

.presence-drawer.open {
  transform: translateX(0);
}

.hero {
  max-width: 920px;
  margin-bottom: 2rem;
}

.hero.compact h1 {
  font-size: clamp(2rem, 5vw, 3.7rem);
}

.hero p:not(.eyebrow) {
  max-width: 680px;
  color: var(--muted);
  font-size: 1.16rem;
}

.tool-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1rem;
}

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

.tool-card {
  display: grid;
  min-height: 280px;
  align-content: space-between;
  gap: 2rem;
  padding: 1.4rem;
}

.tool-card h2,
.section-title h2 {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 2rem;
  letter-spacing: 0;
}

.tool-card p {
  color: var(--muted);
}

.card-footer,
.inline-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.password-form {
  flex-wrap: wrap;
  justify-content: flex-start;
}

.password-form label {
  min-width: min(260px, 100%);
  flex: 1;
}

.panel {
  margin-top: 1rem;
  padding: 1.4rem;
}

.update-log {
  min-height: 180px;
  max-height: 420px;
  margin: 0;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.9rem;
  color: #d7f8e4;
  background: rgba(5, 8, 11, 0.75);
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
  user-select: text;
}

.presence-grid {
  display: grid;
  min-height: 0;
  grid-template-columns: 1fr;
  align-content: start;
  gap: 0.75rem;
  overflow: auto;
  padding-right: 0.15rem;
}

.presence-card {
  min-height: 120px;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 1rem;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.045);
}

.presence-card h3 {
  margin: 0 0 0.4rem;
}

.presence-user {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.45rem 0;
  border-top: 1px solid var(--line);
  color: var(--muted);
}

.presence-user small {
  overflow: hidden;
  max-width: 46%;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.admin-layout {
  display: grid;
  grid-template-columns: 380px 1fr;
  gap: 1rem;
  align-items: start;
}

.check-row {
  display: flex;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 0.6rem;
}

.check-row input,
.permission-row input {
  width: auto;
}

.permission-matrix {
  display: grid;
  gap: 0.6rem;
}

.permission-row {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 0.7rem;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.75rem;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.045);
}

.users-list {
  display: grid;
  gap: 0.75rem;
}

.user-row {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 0.75rem;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.9rem;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.045);
}

.user-row h3 {
  margin: 0;
}

.user-row p {
  margin: 0.25rem 0 0;
  color: var(--muted);
}

.admin-build-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 1rem;
  align-items: start;
}

.build-log-panel {
  grid-column: 1 / -1;
}

.log-title,
.log-toolbar {
  display: flex;
  align-items: center;
  gap: 0.65rem;
}

.log-title {
  justify-content: space-between;
  flex-wrap: wrap;
}

.log-toolbar {
  justify-content: flex-end;
  flex-wrap: wrap;
}

.log-toolbar .muted {
  margin: 0;
}

.section-title.with-status {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.action-row {
  flex-wrap: wrap;
  justify-content: flex-start;
}

.server-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
}

.semaphore {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.55rem 0.8rem;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.045);
  font-weight: 800;
}

.semaphore::before {
  width: 0.68rem;
  height: 0.68rem;
  border-radius: 999px;
  content: "";
  background: var(--muted);
  box-shadow: 0 0 16px currentColor;
}

.semaphore.is-ok {
  color: var(--green);
  background: var(--green-soft);
}

.semaphore.is-pending {
  color: var(--accent-strong);
  background: var(--accent-soft);
}

.semaphore.is-error {
  color: var(--danger);
  background: var(--danger-soft);
}

.quest-page {
  width: min(1500px, calc(100% - 2rem));
}

.quest-layout {
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr) 340px;
  gap: 1rem;
  align-items: start;
}

.quest-list-panel,
.quest-storage-panel {
  position: sticky;
  top: 88px;
  max-height: calc(100vh - 110px);
  overflow: auto;
}

.quest-list,
.quest-storage-list {
  display: grid;
  gap: 0.65rem;
  margin-top: 1rem;
}

.quest-list-item {
  display: grid;
  width: 100%;
  gap: 0.22rem;
  border-radius: 12px;
  padding: 0.9rem;
  text-align: left;
}

.quest-list-item.active {
  border-color: rgba(255, 179, 107, 0.5);
  background: var(--accent-soft);
}

.quest-list-item strong,
.quest-list-item span,
.quest-list-item small {
  min-width: 0;
  overflow-wrap: anywhere;
}

.quest-list-item span,
.quest-list-item small,
.quest-storage-row small {
  color: var(--muted);
}

.storage-picker-input.is-storage-target {
  border-color: rgba(114, 211, 154, 0.64);
  box-shadow: 0 0 0 4px rgba(114, 211, 154, 0.12);
}

.quest-form-grid {
  display: grid;
  grid-template-columns: minmax(180px, 1.2fr) minmax(180px, 1.4fr) minmax(120px, 0.7fr) minmax(120px, 0.7fr);
  gap: 0.8rem;
}

.quest-form-grid.names {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.quest-form textarea {
  min-height: 92px;
  font-family: "JetBrains Mono", "Fira Code", Consolas, monospace;
  font-size: 0.86rem;
  line-height: 1.5;
  resize: vertical;
}

#questMissionsInput {
  min-height: 220px;
}

.mission-board {
  display: grid;
  gap: 0.85rem;
}

.quest-mission-cards {
  display: grid;
  gap: 0.85rem;
}

.quest-mission-card {
  display: grid;
  gap: 0.9rem;
  min-width: 0;
  border: 1px solid rgba(255, 179, 107, 0.22);
  border-radius: 14px;
  padding: 1rem;
  background: rgba(255, 255, 255, 0.045);
}

.quest-submission-list > .quest-mission-card {
  border-color: rgba(114, 211, 154, 0.28);
  border-left-width: 3px;
  background: rgba(114, 211, 154, 0.045);
}

.quest-submission-list .quest-mission-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.quest-submission-list .quest-mission-grid.names {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.quest-mission-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
}

.quest-mission-head h3 {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.45rem;
  letter-spacing: 0;
  overflow-wrap: anywhere;
}

.quest-mission-grid {
  display: grid;
  grid-template-columns: minmax(160px, 1fr) minmax(180px, 1.2fr) repeat(2, minmax(120px, 0.65fr));
  gap: 0.75rem;
}

.quest-mission-grid.names {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin-top: 0.75rem;
}

.quest-mission-card details {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.75rem;
  background: rgba(5, 8, 11, 0.28);
}

.quest-mission-card summary,
.quest-json-details summary {
  color: var(--accent-strong);
  cursor: pointer;
  font-weight: 800;
}

.quest-progress-section[open] {
  border-color: rgba(98, 164, 255, 0.3);
  background: rgba(98, 164, 255, 0.045);
}

.quest-field-help {
  margin: 0.65rem 0 0;
  color: var(--muted);
  font-size: 0.84rem;
}

.quest-submission-section {
  display: grid;
  gap: 0.75rem;
  border: 1px solid rgba(114, 211, 154, 0.22);
  border-radius: 12px;
  padding: 0.85rem;
  background: rgba(5, 8, 11, 0.24);
}

.quest-submission-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.quest-submission-heading h4 {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0.15rem 0 0;
  font-size: 1rem;
}

.quest-submission-heading h4 span {
  border: 1px solid rgba(114, 211, 154, 0.3);
  border-radius: 999px;
  min-width: 1.75rem;
  padding: 0.12rem 0.4rem;
  color: var(--green);
  background: var(--green-soft);
  font-size: 0.75rem;
  text-align: center;
}

.quest-submission-list {
  display: grid;
  gap: 0.75rem;
  min-width: 0;
  margin-left: 0.65rem;
  padding-left: 0.85rem;
  border-left: 2px solid rgba(114, 211, 154, 0.2);
}

.quest-submission-empty {
  margin: 0;
  border: 1px dashed rgba(114, 211, 154, 0.22);
  border-radius: 10px;
  padding: 0.75rem;
  color: var(--muted);
  font-size: 0.84rem;
}

.quest-json-details {
  border: 1px dashed rgba(255, 179, 107, 0.3);
  border-radius: 12px;
  padding: 0.9rem;
  background: rgba(5, 8, 11, 0.28);
}

.quest-json-details textarea {
  margin-top: 0.8rem;
}

.quest-json-details button {
  margin-top: 0.75rem;
}

.quest-storage-target {
  border: 1px solid rgba(114, 211, 154, 0.24);
  border-radius: 12px;
  margin: 0.8rem 0;
  padding: 0.65rem 0.75rem;
  color: var(--green);
  background: var(--green-soft);
  font-size: 0.86rem;
  font-weight: 800;
}

.quest-storage-folder {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(5, 8, 11, 0.22);
  overflow: hidden;
}

.quest-storage-folder summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.75rem 0.85rem;
  color: #f5fff1;
  cursor: pointer;
  font-weight: 900;
}

.quest-storage-folder summary:hover {
  background: rgba(255, 179, 107, 0.08);
}

.quest-storage-folder-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.quest-storage-folder-count {
  border: 1px solid var(--line);
  border-radius: 999px;
  min-width: 2rem;
  padding: 0.18rem 0.45rem;
  color: var(--accent-strong);
  background: var(--accent-soft);
  font-size: 0.78rem;
  text-align: center;
}

.quest-storage-folder-items {
  display: grid;
  gap: 0.55rem;
  border-top: 1px solid var(--line);
  padding: 0.65rem;
}

.quest-storage-row {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.7rem;
  border: 1px solid rgba(255, 179, 107, 0.18);
  border-radius: 12px;
  padding: 0.8rem;
  background: rgba(255, 255, 255, 0.04);
}

.quest-storage-main {
  display: grid;
  width: 100%;
  min-width: 0;
  border: 0;
  border-radius: 8px;
  gap: 0.45rem;
  padding: 0;
  background: transparent;
  text-align: left;
}

.quest-storage-main:hover {
  transform: none;
  background: transparent;
}

.quest-storage-main strong {
  display: block;
  min-width: 0;
  color: #f5fff1;
  font-family: "JetBrains Mono", "Fira Code", Consolas, monospace;
  font-size: 0.82rem;
  line-height: 1.28;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.quest-storage-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.quest-storage-meta small {
  max-width: 100%;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.24rem 0.5rem;
  color: var(--muted);
  background: rgba(5, 8, 11, 0.32);
  overflow-wrap: anywhere;
}

.quest-storage-actions {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(72px, 1fr));
  gap: 0.45rem;
}

.quest-storage-actions button {
  min-height: 36px;
  border-radius: 10px;
  padding: 0.45rem 0.55rem;
  font-size: 0.84rem;
}

@media (min-width: 1100px) {
  .presence-toggle,
  #presenceClose {
    display: none;
  }

  .presence-drawer {
    transform: translateX(0);
  }

  .page.has-presence {
    width: min(980px, calc(100% - 370px));
    margin-left: max(1rem, calc((100% - 1360px) / 2));
    margin-right: 350px;
  }

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

@media (max-width: 900px) {
  .tool-grid,
  .presence-grid,
  .admin-layout,
  .admin-build-grid,
  .quest-layout,
  .quest-form-grid,
  .quest-form-grid.names,
  .quest-mission-grid,
  .quest-mission-grid.names {
    grid-template-columns: 1fr;
  }

  .quest-mission-head {
    flex-direction: column;
  }

  .quest-submission-heading {
    align-items: flex-start;
    flex-direction: column;
  }

  .quest-submission-list {
    margin-left: 0;
    padding-left: 0.5rem;
  }

  .quest-submission-list .quest-mission-grid,
  .quest-submission-list .quest-mission-grid.names {
    grid-template-columns: 1fr;
  }

  .quest-list-panel,
  .quest-storage-panel {
    position: static;
    max-height: none;
  }

  .topbar,
  .top-actions {
    align-items: flex-start;
    flex-direction: column;
  }

  .top-actions,
  .top-actions a,
  .user-menu,
  .user-menu-button {
    width: 100%;
  }

  .user-menu-panel {
    left: 0;
    right: auto;
  }

  .presence-drawer {
    top: 1rem;
    bottom: 1rem;
    border-radius: 14px;
  }
}

body.lua-tool-page {
  color: var(--ink);
  background:
    linear-gradient(115deg, rgba(216, 131, 60, 0.1), transparent 34%),
    linear-gradient(245deg, rgba(114, 211, 154, 0.08), transparent 38%),
    #07090d;
}

body.lua-tool-page::before {
  display: block;
}

.lua-topbar {
  background: rgba(7, 9, 13, 0.86);
}

.lua-workspace {
  display: grid;
  grid-template-columns: 430px minmax(0, 1fr) 410px;
  gap: 0.8rem;
  width: min(1980px, calc(100% - 0.8rem));
  height: calc(100vh - 82px);
  margin: 0 auto;
  padding: 0.8rem 0;
}

.lua-sidebar,
.lua-rightbar {
  display: grid;
  min-height: 0;
  min-width: 0;
  gap: 0.8rem;
}

.lua-rightbar {
  grid-template-rows: minmax(0, 1fr) 330px;
}

.lua-panel,
.lua-editor-zone {
  min-height: 0;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(16, 20, 25, 0.9);
  box-shadow: 0 16px 44px rgba(0, 0, 0, 0.36);
}

.lua-panel {
  display: grid;
  gap: 0.8rem;
  padding: 1rem;
  overflow: hidden;
}

.lua-panel-title,
.lua-editor-toolbar,
.lua-editor-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.lua-panel-title h2,
.lua-editor-toolbar h1 {
  margin: 0;
  font-size: 1.22rem;
  letter-spacing: 0;
}

.lua-panel-title input[type="search"] {
  max-width: 140px;
  padding: 0.55rem 0.7rem;
  border-radius: 8px;
}

.lua-tree,
.lua-function-list,
.lua-logs {
  min-height: 0;
  overflow: auto;
  scrollbar-color: rgba(255, 179, 107, 0.45) rgba(255, 255, 255, 0.05);
}

.lua-tree {
  display: grid;
  align-content: start;
  gap: 0.55rem;
}

.lua-tree-dir {
  display: grid;
  gap: 0.42rem;
}

.lua-tree-dir summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.7rem;
  cursor: pointer;
  min-height: 46px;
  padding: 0.72rem 0.8rem;
  border: 1px solid transparent;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.03);
  color: #d7e6dc;
  font-weight: 800;
  font-size: 1rem;
  list-style: none;
}

.lua-tree-dir summary::-webkit-details-marker {
  display: none;
}

.lua-tree-dir summary::before {
  content: '▸';
  color: var(--accent-strong);
  font-size: 0.9rem;
  margin-right: 0.35rem;
}

.lua-tree-dir[open] > summary::before {
  content: '▾';
}

.lua-tree-dir summary:hover {
  border-color: rgba(255, 179, 107, 0.18);
  background: rgba(255, 179, 107, 0.06);
}

.lua-tree-dir summary small {
  margin-left: auto;
  padding: 0.18rem 0.48rem;
  border-radius: 999px;
  color: var(--accent-strong);
  background: rgba(255, 179, 107, 0.08);
  font-size: 0.72rem;
  font-weight: 900;
  letter-spacing: 0.04em;
}

.lua-tree-children {
  display: grid;
  gap: 0.45rem;
  padding-left: 1rem;
  border-left: 1px solid var(--line);
}

.lua-tree-row {
  display: block;
}

.lua-tree-file {
  display: flex;
  width: 100%;
  min-height: 46px;
  align-items: center;
  justify-content: space-between;
  gap: 0.7rem;
  border-radius: 14px;
  padding: 0.72rem 0.82rem;
  border: 1px solid rgba(255, 255, 255, 0.05);
  color: var(--ink);
  background: rgba(255, 255, 255, 0.05);
  text-align: left;
  font-size: 0.98rem;
}

.lua-tree-file:hover {
  background: rgba(255, 179, 107, 0.1);
}

.lua-tree-file.dragging {
  opacity: 0.45;
  transform: scale(0.99);
}

.lua-tree-dir.lua-tree-drop-target > summary {
  border-color: rgba(114, 211, 154, 0.45);
  background: rgba(114, 211, 154, 0.09);
  box-shadow: inset 0 0 0 1px rgba(114, 211, 154, 0.12);
}

.lua-tree-file span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.lua-tree-file small {
  padding: 0.16rem 0.45rem;
  border-radius: 999px;
  color: var(--accent-strong);
  background: rgba(255, 179, 107, 0.08);
  font-weight: 900;
}

.lua-context-menu {
  position: fixed;
  z-index: 50;
  display: grid;
  gap: 0.2rem;
  min-width: 220px;
  padding: 0.4rem;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 12px;
  background: rgba(10, 14, 18, 0.98);
  box-shadow: 0 22px 60px rgba(0, 0, 0, 0.45);
}

.lua-context-menu.hidden {
  display: none;
}

.lua-context-menu-item {
  min-height: 38px;
  padding: 0.55rem 0.75rem;
  border-radius: 9px;
  border: 1px solid transparent;
  background: rgba(255, 255, 255, 0.04);
  color: var(--ink);
  text-align: left;
  font-size: 0.92rem;
}

.lua-context-menu-item:hover {
  background: rgba(255, 179, 107, 0.1);
  border-color: rgba(255, 179, 107, 0.18);
}

.lua-context-menu-item.danger:hover {
  background: rgba(255, 107, 107, 0.12);
  border-color: rgba(255, 107, 107, 0.2);
  color: #ffd6d6;
}

.lua-tree-file.active {
  border-color: rgba(114, 211, 154, 0.45);
  background: var(--green-soft);
}

.lua-tree-file.git-dirty {
  border-color: rgba(216, 131, 60, 0.42);
}

.lua-tree-file.recent-change {
  box-shadow: inset 3px 0 0 var(--green);
}

.lua-new-file {
  align-self: start;
}

.lua-new-file input,
.lua-new-file select,
.lua-panel select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.65rem 0.75rem;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.055);
}

.lua-editor-zone {
  display: grid;
  grid-template-rows: auto auto auto minmax(0, 1fr) auto;
  overflow: hidden;
}

.lua-open-tabs {
  grid-row: 1;
  display: flex;
  min-width: 0;
  gap: 0.35rem;
  overflow-x: auto;
  border-bottom: 1px solid var(--line);
  padding: 0.45rem 0.55rem;
  background: rgba(255, 255, 255, 0.035);
}

.lua-open-tabs.empty {
  color: var(--muted);
  font-size: 0.84rem;
}

.lua-file-tab {
  display: inline-flex;
  min-width: 120px;
  max-width: 240px;
  height: 34px;
  align-items: center;
  justify-content: space-between;
  gap: 0.45rem;
  border-radius: 8px;
  padding: 0.38rem 0.45rem 0.38rem 0.65rem;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.045);
  white-space: nowrap;
}

.lua-file-tab:hover {
  background: rgba(255, 179, 107, 0.1);
}

.lua-file-tab span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.lua-file-tab small {
  color: var(--accent-strong);
  font-weight: 900;
}

.lua-file-tab b {
  display: inline-grid;
  flex: 0 0 auto;
  width: 20px;
  height: 20px;
  place-items: center;
  border-radius: 50%;
  color: var(--muted);
  font-size: 0.8rem;
  font-style: normal;
  line-height: 1;
}

.lua-file-tab b:hover {
  color: var(--danger);
  background: var(--danger-soft);
}

.lua-file-tab.active {
  border-color: rgba(114, 211, 154, 0.45);
  background: var(--green-soft);
}

.lua-file-tab.dirty {
  border-color: rgba(216, 131, 60, 0.42);
}

.lua-file-tab.deleted {
  border-color: rgba(255, 129, 125, 0.38);
  color: var(--danger);
}

.lua-editor-toolbar,
.lua-editor-footer {
  padding: 0.75rem 0.9rem;
  border-bottom: 1px solid var(--line);
}

.lua-editor-toolbar {
  grid-row: 2;
}

.lua-editor-footer {
  grid-row: 5;
  min-height: 48px;
  border-top: 1px solid var(--line);
  border-bottom: 0;
}

.lua-notification {
  grid-row: 3;
}

.lua-code-shell {
  grid-row: 4;
  height: 100%;
  min-height: 0;
  min-width: 0;
  overflow: hidden;
  background: #202722;
}

#codeEditor {
  width: 100%;
  height: 100%;
  min-height: 0;
  border: 0;
  border-radius: 0;
  padding: 1rem;
  color: #e7efe6;
  background: #202722;
  font-family: "JetBrains Mono", "Fira Code", Consolas, monospace;
  font-size: 0.92rem;
  line-height: 1.55;
  resize: none;
}

.lua-code-shell > .CodeMirror {
  height: 100% !important;
  min-height: 0;
  width: 100%;
  min-width: 0;
  font-family: "JetBrains Mono", "Fira Code", Consolas, monospace;
  font-size: 0.92rem;
  line-height: 1.55;
}

.lua-code-shell .CodeMirror-scroll {
  height: 100% !important;
  min-height: 0;
}

.lua-notification {
  margin: 0.75rem 0.9rem 0;
  border: 1px solid rgba(114, 211, 154, 0.26);
  border-radius: 8px;
  padding: 0.65rem 0.75rem;
  color: #ccebd7;
  background: var(--green-soft);
}

.lua-notification.warn {
  border-color: rgba(216, 131, 60, 0.32);
  color: var(--accent-strong);
  background: var(--accent-soft);
}

.lua-notification.error {
  border-color: rgba(255, 129, 125, 0.32);
  color: var(--danger);
  background: var(--danger-soft);
}

.lua-notification.hidden {
  display: none;
}

.mode.dirty,
.presence-pill.dirty {
  border-color: rgba(216, 131, 60, 0.42);
  color: var(--accent-strong);
  background: var(--accent-soft);
}

.mode.danger {
  border-color: rgba(255, 129, 125, 0.38);
  color: var(--danger);
  background: var(--danger-soft);
}

.lua-file-presence {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 0.35rem;
}

.presence-pill {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.28rem 0.55rem;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.045);
  font-size: 0.8rem;
}

.lua-tabs {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(92px, 1fr));
  gap: 0.35rem;
}

.lua-tabs button {
  min-width: 0;
  border-radius: 8px;
  padding: 0.5rem 0.35rem;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.045);
  font-size: 0.82rem;
}

.lua-tabs button.active {
  border-color: rgba(114, 211, 154, 0.45);
  background: var(--green-soft);
}

.lua-function-list {
  display: grid;
  align-content: start;
  gap: 0.45rem;
}

.lua-function-item {
  display: grid;
  width: 100%;
  gap: 0.25rem;
  border-radius: 8px;
  padding: 0.65rem;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.045);
  text-align: left;
}

.lua-function-item:hover {
  background: rgba(255, 179, 107, 0.1);
}

.lua-function-item strong,
.lua-function-item small,
.lua-function-item span {
  min-width: 0;
  overflow-wrap: anywhere;
}

.lua-function-item strong {
  color: #f5fff1;
}

.lua-function-item small,
.lua-function-item span {
  color: var(--muted);
}

.lua-storage-item strong {
  color: #dff8ff;
}

.CodeMirror-hints {
  z-index: 50;
  min-width: 280px;
  max-width: min(560px, calc(100vw - 32px));
  border: 1px solid rgba(114, 211, 154, 0.32);
  border-radius: 8px;
  padding: 0.25rem;
  background: #111820;
  box-shadow: 0 18px 42px rgba(0, 0, 0, 0.42);
  color: #e7efe6;
  font-family: inherit;
}

.CodeMirror-hint {
  display: block;
  border-radius: 6px;
  padding: 0.45rem 0.55rem;
  color: #e7efe6;
  white-space: normal;
}

li.CodeMirror-hint-active {
  color: #f5fff1;
  background: rgba(114, 211, 154, 0.22);
}

.lua-hint-title {
  font-weight: 800;
}

.CodeMirror-hint small {
  display: block;
  margin-top: 0.15rem;
  color: #9fb3ad;
  font-size: 0.76rem;
  line-height: 1.3;
}

.lua-hint-local .lua-hint-title {
  color: #bdebd1;
}

.lua-hint-storage .lua-hint-title {
  color: #bdeeff;
}

.lua-hint-keyword .lua-hint-title {
  color: #ffd59b;
}

.lua-server-panel {
  grid-template-rows: auto auto minmax(0, 1fr);
}

.lua-logs {
  margin: 0;
  border-radius: 8px;
  padding: 0.75rem;
  color: #dbe7d8;
  background: #202722;
  font-family: "JetBrains Mono", "Fira Code", Consolas, monospace;
  font-size: 0.78rem;
  line-height: 1.45;
  white-space: pre-wrap;
}

@media (max-width: 1180px) {
  .lua-workspace {
    grid-template-columns: 280px minmax(0, 1fr);
    height: auto;
  }

  .lua-rightbar {
    grid-column: 1 / -1;
    grid-template-columns: 1fr 1fr;
    grid-template-rows: 420px;
  }
}

@media (max-width: 820px) {
  .lua-workspace,
  .lua-rightbar {
    grid-template-columns: 1fr;
  }

  .lua-editor-toolbar,
  .lua-editor-footer,
  .lua-panel-title {
    align-items: flex-start;
    flex-direction: column;
  }

  .lua-file-presence {
    justify-content: flex-start;
  }
}

/* Lua workspace: compact IDE layout. These rules intentionally live after the
   shared Toolshub theme so the other tools keep their existing presentation. */
.lua-workspace {
  --lua-explorer-width: 280px;
  grid-template-columns: var(--lua-explorer-width) 5px minmax(420px, 1fr) 350px;
  gap: 0;
  width: 100%;
  height: calc(100vh - 64px);
  padding: 0;
}

.lua-workspace.explorer-hidden {
  grid-template-columns: 0 0 minmax(420px, 1fr) 350px;
}

.lua-workspace.explorer-hidden .lua-sidebar {
  visibility: hidden;
  pointer-events: none;
}

.lua-resizer,
.lua-split-resizer {
  position: relative;
  z-index: 5;
  cursor: col-resize;
  background: transparent;
}

.lua-resizer:hover,
.lua-resizer:focus,
.lua-split-resizer:hover,
.lua-split-resizer:focus {
  outline: 0;
  background: #3f8cff;
}

.lua-panel,
.lua-editor-zone {
  border-radius: 0;
  box-shadow: none;
  background: #181818;
}

.lua-sidebar .lua-panel {
  gap: 0;
  padding: 0;
}

.lua-sidebar .lua-panel-title {
  min-height: 36px;
  padding: 0 8px 0 14px;
  border-bottom: 1px solid #292929;
}

.lua-sidebar .lua-panel-title h2 {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
}

.lua-explorer-actions {
  display: flex;
  gap: 2px;
}

.lua-explorer-actions button,
.lua-tab-tool {
  display: inline-grid;
  width: 28px;
  min-width: 28px;
  height: 28px;
  padding: 0;
  place-items: center;
  border: 0;
  border-radius: 4px;
  color: #bdbdbd;
  background: transparent;
}

.lua-explorer-actions button:hover,
.lua-tab-tool:hover {
  color: #fff;
  background: #2a2d2e;
}

.lua-explorer-actions button:active,
.lua-tab-tool:active { background: #3a3d3e; }
.lua-explorer-actions button:focus-visible,
.lua-tab-tool:focus-visible,
.lua-file-tab:focus-visible,
.lua-tree-file:focus-visible { outline: 1px solid #75aaff; outline-offset: -1px; }
.lua-explorer-actions button:disabled,
.lua-tab-tool:disabled { opacity: 0.35; cursor: default; }

.lua-tree-search {
  width: calc(100% - 16px);
  height: 28px;
  margin: 7px 8px;
  padding: 3px 8px;
  border: 1px solid #3d3d3d;
  border-radius: 3px;
  color: #ddd;
  background: #242424;
  font-size: 0.78rem;
}

.lua-tree {
  display: block;
  padding: 2px 0 12px;
}

.lua-tree-dir {
  display: block;
}

.lua-tree-dir summary,
.lua-tree-file {
  min-height: 24px;
  height: 24px;
  padding: 2px 8px;
  border: 0;
  border-radius: 0;
  background: transparent;
  font-size: 0.8rem;
  font-weight: 500;
}

.lua-tree-dir summary::before {
  width: 12px;
  margin-right: 2px;
  color: #a8a8a8;
}

.lua-tree-dir summary small {
  padding: 0;
  color: #777;
  background: transparent;
  font-size: 0.68rem;
}

.lua-tree-children {
  display: block;
  padding-left: 13px;
  border-left: 0;
}

.lua-tree-file:hover,
.lua-tree-dir summary:hover {
  border: 0;
  background: #2a2d2e;
}

.lua-tree-file.active {
  border: 0;
  background: #37373d;
}
.lua-tree-file.selected:not(.active),
.lua-tree-dir.selected > summary { background: #303033; }

.lua-file-icon {
  display: inline-grid;
  flex: 0 0 16px;
  width: 16px;
  height: 16px;
  place-items: center;
  color: #9cdcfe;
  font-size: 0.62rem;
  font-style: normal;
  font-weight: 800;
}

.lua-file-icon.is-lua { color: #51a8dd; }
.lua-file-icon.is-json { color: #dcdcaa; }
.lua-file-icon.is-xml { color: #e37933; }
.lua-file-icon.is-png { color: #c586c0; }
.lua-tree-empty { padding: 12px; color: #858585; font-size: 0.8rem; }

.lua-tabs-row {
  grid-row: 1;
  display: flex;
  min-width: 0;
  height: 36px;
  border-bottom: 1px solid #252525;
  background: #181818;
}

.lua-show-explorer {
  flex: 0 0 34px;
  width: 34px;
  border-right: 1px solid #2b2b2b;
}

.lua-restore-tabs {
  width: auto;
  min-width: 38px;
  padding: 0 7px;
  font-size: 0.72rem;
}

.lua-open-tabs {
  flex: 1 1 auto;
  padding: 0;
  gap: 0;
  border: 0;
  background: #181818;
}

.lua-open-tabs.empty { padding: 9px 12px; }

.lua-file-tab {
  min-width: 110px;
  max-width: 190px;
  height: 35px;
  padding: 0 7px 0 11px;
  border: 0;
  border-right: 1px solid #252525;
  border-radius: 0;
  color: #aaa;
  background: #181818;
  font-size: 0.78rem;
}

.lua-file-tab:hover { background: #1f1f1f; }
.lua-file-tab.active { border-top: 1px solid #3f8cff; background: #1f1f1f; color: #fff; }
.lua-file-tab.dirty small { color: #fff; }
.lua-file-tab.dragging { opacity: 0.45; }
.lua-file-tab.drop-before { box-shadow: inset 2px 0 #3f8cff; }
.lua-open-tabs.lua-tab-drop-target,
.lua-editor-pane.lua-tab-drop-target { box-shadow: inset 0 0 0 2px #3f8cff; }

.lua-editor-toolbar {
  min-height: 54px;
  padding: 5px 10px;
  background: #1f1f1f;
}

.lua-file-heading { min-width: 0; }
.lua-file-heading h1 { display: none; }
.lua-file-heading .eyebrow { margin-bottom: 2px; font-size: 0.65rem; }

.lua-breadcrumbs {
  display: flex;
  min-width: 0;
  align-items: center;
  overflow: hidden;
  color: #bdbdbd;
  font-size: 0.76rem;
  white-space: nowrap;
}

.lua-breadcrumbs > * {
  min-width: 0;
  padding: 0;
  border: 0;
  color: inherit;
  background: transparent;
  overflow: hidden;
  text-overflow: ellipsis;
}

.lua-breadcrumbs > * + *::before { content: '›'; padding: 0 6px; color: #666; }
.lua-breadcrumbs button:hover { color: #fff; }

.lua-editor-panes {
  --lua-split-ratio: 50%;
  grid-row: 4;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 0 0;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
}

.lua-editor-panes.split {
  grid-template-columns: minmax(0, var(--lua-split-ratio)) 5px minmax(0, calc(100% - var(--lua-split-ratio) - 5px));
}

.lua-editor-pane {
  display: grid;
  grid-template-rows: minmax(0, 1fr);
  min-width: 0;
  min-height: 0;
  overflow: hidden;
}
.lua-editor-pane:focus-within { box-shadow: inset 0 1px #3f8cff; }

.lua-side-editor { grid-template-rows: 36px 28px minmax(0, 1fr); border-left: 1px solid #252525; }
.lua-side-editor.hidden { display: none; }
.lua-side-head { display: flex; justify-content: space-between; background: #181818; }
.lua-side-head .lua-file-tab { flex: 1 1 auto; max-width: none; }
.lua-side-breadcrumbs { padding: 0 10px; border-bottom: 1px solid #252525; background: #1f1f1f; }
.lua-code-shell { grid-row: auto; background: #1e1e1e; }
.lua-code-shell > .CodeMirror { background: #1e1e1e; }
.lua-code-shell .CodeMirror-gutters { background: #1e1e1e; border-right: 0; }
.CodeMirror-foldgutter-open::after { content: '⌄'; color: #999; }
.CodeMirror-foldgutter-folded::after { content: '›'; color: #ccc; }

@media (max-width: 1180px) {
  .lua-workspace,
  .lua-workspace.explorer-hidden {
    grid-template-columns: minmax(210px, var(--lua-explorer-width)) 5px minmax(0, 1fr);
  }
  .lua-workspace.explorer-hidden { grid-template-columns: 0 0 minmax(0, 1fr); }
  .lua-rightbar { display: none; }
}

@media (max-width: 820px) {
  .lua-workspace,
  .lua-workspace.explorer-hidden { grid-template-columns: 1fr; height: auto; }
  .lua-sidebar, .lua-resizer { display: none; }
  .lua-editor-zone { min-height: calc(100vh - 64px); }
  .lua-editor-panes.split { grid-template-columns: 1fr; grid-template-rows: minmax(360px, 1fr) minmax(360px, 1fr); }
  .lua-split-resizer { display: none; }
  .lua-side-editor { border-top: 1px solid #444; border-left: 0; }
}
