.luau {
  position: absolute;
  inset: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: 44px minmax(0, 1fr) 26px;
  grid-template-areas: "head" "edit" "line";
  padding: 0 4px 4px;
  --luau-line: 20px;
  --luau-top: 6px;
  --luau-left: 8px;
  --luau-end: 48px;
  --luau-gutter: 36px;
}

.luau .script-head { padding-left: 4px; }
.luau-bytes { display: flex; align-items: baseline; gap: 8px; padding: 0 10px 0 4px; white-space: nowrap; }
.luau-bytes .value { color: var(--value); }
.luau .script-head .btn.on { background: var(--accent); }

.luau-edit { grid-area: edit; position: relative; min-height: 0; background: var(--tile); overflow: hidden; }
.luau-scroll { position: absolute; inset: 0; overflow: auto; overscroll-behavior: contain; scroll-padding-left: var(--luau-gutter); }
.luau-scroll::-webkit-scrollbar, .luau-list::-webkit-scrollbar { width: 10px; height: 10px; }
.luau-scroll::-webkit-scrollbar-track, .luau-list::-webkit-scrollbar-track { background: var(--tile); }
.luau-scroll::-webkit-scrollbar-thumb, .luau-list::-webkit-scrollbar-thumb { background: var(--button); }
.luau-scroll::-webkit-scrollbar-corner { background: var(--tile); }

.luau-sizer {
  position: relative;
  display: flex;
  min-width: 100%;
  min-height: 100%;
  font: var(--luau-size, 13px)/var(--luau-line) ui-monospace, Menlo, Consolas, monospace;
  font-kerning: none;
  font-variant-ligatures: none;
  letter-spacing: 0;
  tab-size: 4;
  -moz-tab-size: 4;
}

.luau-gutter { position: sticky; left: 0; z-index: 3; flex: none; width: var(--luau-gutter); background: var(--panel); color: var(--disabled-text); }
.luau-gutter > i { position: absolute; left: 0; right: 0; height: var(--luau-line); padding-right: 8px; text-align: right; font-style: normal; }
.luau-edit:focus-within .luau-gutter { color: var(--subtle-text); }
.luau-edit:focus-within .luau-gutter > i.at { color: var(--text); }
.luau-gutter > i.p-warning { background: var(--notice); color: var(--ground); }
.luau-gutter > i.p-error, .luau-edit:focus-within .luau-gutter > i.p-error.at { background: var(--problem); color: var(--ground); }
.luau-edit:focus-within .luau-gutter > i.p-warning.at { color: var(--ground); }

.luau-page { position: relative; flex: 1 1 auto; min-width: 0; }

.luau-field {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  margin: 0;
  border: 0;
  outline: 0;
  resize: none;
  overflow: hidden;
  padding: var(--luau-top) var(--luau-end) 0 var(--luau-left);
  background: transparent;
  color: transparent;
  -webkit-text-fill-color: transparent;
  caret-color: var(--text);
  font: inherit;
  font-kerning: none;
  font-variant-ligatures: none;
  letter-spacing: 0;
  tab-size: 4;
  -moz-tab-size: 4;
  white-space: pre;
  overflow-wrap: normal;
  word-break: normal;
  cursor: text;
  user-select: text;
  -webkit-user-select: text;
}
.luau-field:focus-visible { outline: 0; }
.luau-field::selection { background: var(--accent); color: transparent; -webkit-text-fill-color: transparent; }

.luau-paint { position: absolute; inset: 0; pointer-events: none; }
.luau-paint > div { position: absolute; left: var(--luau-left); height: var(--luau-line); white-space: pre; color: var(--text); }
.luau-paint i { font-style: normal; }
.luau-paint i::before { content: attr(data-t); }
.luau-ruler { position: absolute; left: var(--luau-left); top: 0; visibility: hidden; white-space: pre; pointer-events: none; }

.luau-paint .t-comment { color: var(--disabled-text); }
.luau-paint .t-string { color: var(--axis-y); }
.luau-paint .t-number { color: var(--value); }
.luau-paint .t-keyword, .luau-paint .t-interp { color: var(--axis-z); }
.luau-paint .t-removed { color: var(--problem); text-decoration: line-through; }
.luau-paint .t-operator, .luau-paint .t-bracket { color: var(--subtle-text); }
.luau-paint .t-error { color: var(--axis-x); }

.luau-paint .p-error::before, .luau-paint .p-warning::before { text-decoration-line: underline; text-decoration-style: solid; text-decoration-thickness: 2px; text-underline-offset: 3px; }
.luau-paint .p-error::before { text-decoration-color: var(--problem); }
.luau-paint .p-warning::before { text-decoration-color: var(--notice); }

.luau-list {
  position: absolute;
  z-index: 6;
  min-width: 168px;
  max-width: min(340px, calc(100% - 12px));
  max-height: 226px;
  overflow: auto;
  overscroll-behavior: contain;
  display: grid;
  gap: 2px;
  padding: 2px;
  background: var(--panel);
  outline: 4px solid var(--ground);
  font: 13px/26px ui-monospace, Menlo, Consolas, monospace;
}
.luau-list > div { height: 26px; padding: 0 10px; background: var(--tile); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; cursor: pointer; }
.luau-list > div:hover { background: var(--button); }
.luau-list > div.on { background: var(--accent); }

@media (max-width: 760px) {
  .luau { grid-template-rows: 40px minmax(0, 1fr) 26px; }
  .luau-bytes .label { display: none; }
  .luau-bytes { padding: 0 6px 0 2px; }
  .luau .script-head .btn { padding: 0 9px; }
  .luau .script-head .btn.has-icon { padding-left: 4px; gap: 4px; }
  .luau .script-head .spring + .btn { min-width: 0; }
  .luau .script-head .luau-reference .label { display: none; }
  .luau .script-head .luau-reference { padding: 0 4px; }
}
@media (max-width: 520px) {
  .luau .script-head .btn[class*="cut-"]:not(.has-icon):not(.luau-reference) { flex: 0 1 auto; min-width: 48px; overflow: hidden; justify-content: flex-start; }
  .luau .script-head .btn[class*="cut-"]:not(.has-icon):not(.luau-reference) .label { overflow: hidden; text-overflow: ellipsis; }
}
#app.coarse .luau-list { font-size: 15px; line-height: 36px; max-height: 240px; }
#app.coarse .luau-list > div { height: 36px; }
