:root {
  --bg: #eef2ef;
  --chrome: #f8faf8;
  --panel: #ffffff;
  --panel-2: #f2f5f3;
  --ink: #1d2523;
  --muted: #5e6964;
  --faint: #87918c;
  --rule: #d7ded9;
  --rule-strong: #c4cec7;
  --accent: #275d67;
  --accent-2: #9a4f2f;
  --ok: #2f7048;
  --warn: #906327;
  --error: #a33a32;
  --code: #16211f;
  --code-bg: #f0f3f0;
  --shadow: 0 18px 42px -32px rgba(19, 34, 31, 0.45);
  --shadow-soft: 0 1px 2px rgba(19, 34, 31, 0.06), 0 12px 28px -24px rgba(19, 34, 31, 0.45);
  --sans: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  --mono: "SF Mono", Menlo, Consolas, monospace;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  min-height: 100%;
  overflow: hidden;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.45;
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
  text-underline-offset: 3px;
}

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

button,
.file-button {
  border: 1px solid var(--rule);
  background: var(--panel);
  color: var(--ink);
  border-radius: 7px;
  min-height: 32px;
  padding: 0 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-size: 0.9rem;
  font-weight: 650;
  cursor: pointer;
  white-space: nowrap;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.72) inset;
  transition: background-color 120ms ease, border-color 120ms ease, color 120ms ease, box-shadow 120ms ease;
}

button:hover,
.file-button:hover {
  border-color: var(--rule-strong);
  background: #fbfcfb;
  box-shadow: 0 2px 8px rgba(19, 34, 31, 0.07);
}

button:disabled {
  cursor: not-allowed;
  color: var(--faint);
  background: #f4f6f4;
  border-color: var(--rule);
  box-shadow: none;
  opacity: 0.72;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
.file-button:focus-within {
  outline: 2px solid rgba(39, 93, 103, 0.28);
  outline-offset: 2px;
}

.app-shell {
  width: 100%;
  height: 100vh;
  min-height: 0;
  display: grid;
  grid-template-rows: auto 1fr;
  overflow: hidden;
}

.topbar {
  border-bottom: 1px solid var(--rule);
  background: rgba(248, 250, 248, 0.94);
  backdrop-filter: blur(12px);
  position: sticky;
  top: 0;
  z-index: 10;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.7) inset;
}

.topbar-inner {
  min-height: 54px;
  padding: 0 18px;
  display: flex;
  align-items: center;
  gap: 20px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  color: var(--ink);
  font-weight: 780;
}

.brand-mark {
  width: 22px;
  height: 22px;
  border-radius: 6px;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.22), rgba(255, 255, 255, 0)),
    linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: 0 5px 14px -9px var(--accent);
}

.topline {
  color: var(--muted);
  font-size: 0.83rem;
  font-weight: 680;
  white-space: nowrap;
}

.topnav {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 16px;
  color: var(--muted);
  font-size: 0.92rem;
}

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

.topnav a:hover {
  color: var(--ink);
  text-decoration: none;
}

.workbench {
  display: grid;
  grid-template-rows: auto 1fr;
  height: 100%;
  min-height: 0;
  overflow: hidden;
}

.toolbar {
  display: grid;
  gap: 6px;
  padding: 7px 14px;
  border-bottom: 1px solid var(--rule);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.72), rgba(255, 255, 255, 0)),
    var(--panel-2);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.78) inset;
}

.menu-row {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.menu-tabs,
.ribbon-panel {
  display: flex;
  align-items: center;
  max-width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: thin;
  scrollbar-color: rgba(94, 105, 100, 0.35) transparent;
}

.menu-tabs {
  flex: 1 1 auto;
  min-width: 0;
  gap: 2px;
}

.menu-tabs button {
  min-height: 28px;
  padding: 0 11px;
  border-color: transparent;
  background: transparent;
  color: var(--muted);
  border-radius: 6px;
  box-shadow: none;
  font-size: 0.88rem;
  font-weight: 690;
}

.menu-tabs button:hover {
  color: var(--ink);
  background: rgba(255, 255, 255, 0.58);
  border-color: transparent;
  box-shadow: none;
}

.menu-tabs button[aria-selected="true"] {
  color: var(--ink);
  background: var(--panel);
  border-color: var(--rule);
  box-shadow: inset 0 -2px 0 var(--accent);
}

.menu-tabs::-webkit-scrollbar,
.ribbon-panel::-webkit-scrollbar {
  height: 6px;
}

.menu-tabs::-webkit-scrollbar-thumb,
.ribbon-panel::-webkit-scrollbar-thumb {
  background: rgba(94, 105, 100, 0.28);
  border-radius: 999px;
}

.field {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 650;
}

select {
  min-height: 30px;
  border: 1px solid var(--rule);
  border-radius: 7px;
  padding: 0 30px 0 9px;
  background: var(--panel);
  color: var(--ink);
  font-size: 0.86rem;
}

input[type="search"] {
  min-height: 30px;
  min-width: 180px;
  border: 1px solid var(--rule);
  border-radius: 7px;
  padding: 0 10px;
  background: var(--panel);
  color: var(--ink);
  font-size: 0.86rem;
}

.file-button input {
  position: absolute;
  inline-size: 1px;
  block-size: 1px;
  opacity: 0;
  pointer-events: none;
}

.ribbon-panel {
  align-items: stretch;
  gap: 7px;
  min-height: 36px;
}

.ribbon-panel[hidden] {
  display: none;
}

.tool-group {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-height: 34px;
  border: 1px solid var(--rule);
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.82);
  padding: 3px;
  box-shadow: var(--shadow-soft);
  flex: 0 0 auto;
}

.tool-label {
  color: var(--faint);
  font-size: 0.66rem;
  font-weight: 760;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  padding: 0 4px;
}

.tool-group button,
.tool-group .file-button {
  min-height: 27px;
  border-radius: 6px;
  padding: 0 8px;
  font-size: 0.82rem;
  background: transparent;
  border-color: transparent;
  box-shadow: none;
}

.tool-group button:hover,
.tool-group .file-button:hover {
  background: var(--panel);
}

.search-group {
  flex: 0 0 min(420px, 78vw);
}

.search-group input {
  flex: 1 1 160px;
}

.find-status {
  color: var(--faint);
  min-width: 38px;
  font-family: var(--mono);
  font-size: 0.75rem;
}

.status-pill {
  border-radius: 999px;
  border: 1px solid var(--rule);
  background: var(--panel);
  min-height: 28px;
  display: inline-flex;
  align-items: center;
  padding: 0 10px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 690;
  white-space: nowrap;
  flex: 0 0 auto;
  margin-left: auto;
}

.status-pill[data-state="ok"] {
  color: var(--ok);
  border-color: rgba(47, 112, 72, 0.28);
  background: #eff7f1;
}

.status-pill[data-state="warning"] {
  color: var(--warn);
  border-color: rgba(144, 99, 39, 0.28);
  background: #fbf5e7;
}

.status-pill[data-state="error"] {
  color: var(--error);
  border-color: rgba(163, 58, 50, 0.28);
  background: #fbebe9;
}

.layout {
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(320px, 0.9fr) minmax(420px, 1.12fr) minmax(300px, 0.62fr);
  gap: 10px;
  padding: 10px 12px 12px;
  overflow: hidden;
}

.pane {
  min-width: 0;
  min-height: 0;
  border: 1px solid var(--rule);
  border-radius: 10px;
  display: grid;
  grid-template-rows: auto 1fr;
  background: var(--panel);
  overflow: hidden;
  box-shadow: var(--shadow);
}

.pane-head {
  min-height: 46px;
  padding: 0 12px 0 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid var(--rule);
  background:
    linear-gradient(180deg, #ffffff, #f8faf8);
  min-width: 0;
}

.pane-title {
  margin: 0;
  font-size: 0.9rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}

.target-tabs {
  display: inline-flex;
  border: 1px solid var(--rule);
  border-radius: 9px;
  overflow-x: auto;
  overflow-y: hidden;
  background: var(--panel);
  max-width: 100%;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.75) inset;
  scrollbar-width: none;
}

.target-tabs::-webkit-scrollbar {
  display: none;
}

.target-tabs button {
  min-height: 31px;
  border: 0;
  border-radius: 0;
  border-right: 1px solid var(--rule);
  background: transparent;
  color: var(--muted);
  flex: 0 0 auto;
  padding: 0 10px;
  box-shadow: none;
}

.target-tabs button:last-child {
  border-right: 0;
}

.target-tabs button[aria-pressed="true"] {
  background: var(--accent);
  color: #ffffff;
}

.source-editor {
  width: 100%;
  height: 100%;
  min-height: 0;
  resize: none;
  border: 0;
  padding: 16px 18px;
  color: #f3fbf7;
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.03) 1px, transparent 1px) 0 0 / 44px 44px,
    var(--code);
  font-family: var(--mono);
  font-size: 13px;
  line-height: 1.54;
  tab-size: 2;
  outline: none;
}

.preview-frame {
  width: 100%;
  height: 100%;
  min-height: 0;
  border: 0;
  background: #ffffff;
}

.preview-frame[data-editing="true"] {
  box-shadow: inset 0 0 0 2px rgba(39, 93, 103, 0.34), inset 0 0 0 9999px rgba(232, 246, 239, 0.02);
}

.output-pre {
  margin: 0;
  min-height: 0;
  overflow: auto;
  padding: 18px;
  color: #f3fbf7;
  background: var(--code);
  font-family: var(--mono);
  font-size: 12.5px;
  line-height: 1.52;
  white-space: pre-wrap;
}

.side-panel {
  min-height: 0;
  min-width: 0;
  overflow: auto;
  background: var(--panel);
  border: 1px solid var(--rule);
  border-radius: 10px;
  box-shadow: var(--shadow);
}

.side-section {
  min-width: 0;
  border-bottom: 1px solid var(--rule);
  padding: 13px;
  background: linear-gradient(180deg, #ffffff, #fbfcfb);
}

.side-section h3 {
  margin: 0 0 10px;
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
}

.proof-ops-input {
  width: 100%;
  min-height: 138px;
  max-height: 210px;
  resize: vertical;
  border: 1px solid var(--rule);
  border-radius: 8px;
  padding: 10px;
  background: var(--code);
  color: #f3fbf7;
  font-family: var(--mono);
  font-size: 11.5px;
  line-height: 1.45;
  outline: none;
}

.collab-status,
.proof-status,
.data-status {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 0.8rem;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.collab-status {
  margin-top: 0;
  border: 1px solid var(--rule);
  border-radius: 8px;
  padding: 8px 9px;
  background: #f7f9f7;
  font-family: var(--mono);
  font-size: 0.72rem;
}

.cloud-status {
  margin-top: 8px;
}

.cloud-field {
  display: grid;
  gap: 5px;
  margin: 8px 0;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 700;
}

.cloud-field input,
.cloud-field select {
  width: 100%;
}

.collab-status[data-state="ok"] {
  color: var(--ok);
  border-color: rgba(47, 112, 72, 0.22);
  background: #eff7f1;
}

.collab-status[data-state="warning"] {
  color: var(--warn);
  border-color: rgba(144, 99, 39, 0.22);
  background: #fbf5e7;
}

.collab-status[data-state="error"] {
  color: var(--error);
  border-color: rgba(163, 58, 50, 0.22);
  background: #fbebe9;
}

.collab-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
  margin-top: 8px;
}

.collab-actions button {
  min-height: 28px;
  padding: 0 8px;
  font-size: 0.8rem;
}

.proof-status[data-state="ok"] {
  color: var(--ok);
}

.proof-status[data-state="warning"] {
  color: var(--warn);
}

.proof-status[data-state="error"] {
  color: var(--error);
}

.data-select-label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 700;
}

.data-select-label select {
  width: 100%;
}

.data-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.data-actions button {
  min-height: 28px;
  padding: 0 8px;
  font-size: 0.8rem;
}

.data-editor {
  margin-top: 9px;
  max-height: 260px;
  overflow: auto;
  border: 1px solid var(--rule);
  border-radius: 8px;
  background: #fbfcfb;
}

.data-grid {
  width: 100%;
  min-width: 320px;
  border-collapse: collapse;
  font-size: 0.78rem;
}

.data-grid th,
.data-grid td {
  border-bottom: 1px solid var(--rule);
  border-right: 1px solid var(--rule);
  padding: 0;
  background: var(--panel);
}

.data-grid th:last-child,
.data-grid td:last-child {
  border-right: 0;
}

.data-grid tr:last-child td {
  border-bottom: 0;
}

.data-grid th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--panel-2);
}

.data-grid input {
  width: 100%;
  min-width: 96px;
  border: 0;
  border-radius: 0;
  padding: 7px 8px;
  background: transparent;
  color: var(--ink);
  font-family: var(--mono);
  font-size: 0.76rem;
  outline: none;
}

.data-grid th input {
  font-weight: 760;
  color: var(--accent);
}

.data-grid input[readonly] {
  color: var(--muted);
  background: rgba(242, 245, 243, 0.72);
}

.diagnostic-summary {
  border: 1px solid var(--rule);
  border-radius: 999px;
  width: max-content;
  max-width: 100%;
  padding: 4px 8px;
  margin-bottom: 9px;
  color: var(--muted);
  background: #f7f9f7;
  font-size: 0.76rem;
  font-weight: 760;
  overflow-wrap: anywhere;
}

.diagnostic-summary[data-state="ok"] {
  color: var(--ok);
  border-color: rgba(47, 112, 72, 0.24);
  background: #eff7f1;
}

.diagnostic-summary[data-state="warning"] {
  color: var(--warn);
  border-color: rgba(144, 99, 39, 0.24);
  background: #fbf5e7;
}

.diagnostic-summary[data-state="error"] {
  color: var(--error);
  border-color: rgba(163, 58, 50, 0.24);
  background: #fbebe9;
}

.diagnostics,
.outline {
  display: grid;
  gap: 8px;
  min-width: 0;
}

.diagnostic,
.outline-item {
  width: 100%;
  min-width: 0;
  max-width: 100%;
  text-align: left;
  border: 1px solid var(--rule);
  border-radius: 8px;
  background: var(--panel);
  color: var(--ink);
  padding: 9px 10px;
  min-height: 0;
  display: grid;
  gap: 4px;
  cursor: default;
  box-shadow: 0 8px 18px -18px rgba(19, 34, 31, 0.5);
  overflow: hidden;
}

button.diagnostic,
.outline-item {
  cursor: pointer;
}

.diagnostic-error {
  border-color: rgba(163, 58, 50, 0.28);
}

.diagnostic-warning {
  border-color: rgba(144, 99, 39, 0.28);
}

.diagnostic-meta,
.outline-meta {
  min-width: 0;
  color: var(--faint);
  font-size: 0.78rem;
  font-family: var(--mono);
  overflow-wrap: anywhere;
  white-space: normal;
}

.diagnostic-body,
.outline-label {
  display: block;
  min-width: 0;
  overflow-wrap: anywhere;
}

.outline-item {
  padding-left: calc(10px + var(--depth, 0) * 12px);
}

.empty {
  margin: 0;
  color: var(--faint);
}

[hidden] {
  display: none !important;
}

@media (max-width: 1040px) {
  .layout {
    grid-template-columns: minmax(280px, 0.88fr) minmax(360px, 1.12fr);
    grid-template-rows: minmax(0, 1fr) minmax(190px, 0.65fr);
  }

  .side-panel {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: 1fr 1fr;
    max-height: none;
  }

  .side-section {
    border-bottom: 0;
    border-right: 1px solid var(--rule);
  }

  .side-section:nth-child(2n) {
    border-right: 0;
  }

  .side-section:last-child {
    border-right: 0;
  }
}

@media (max-width: 760px) {
  .topbar-inner {
    min-height: 50px;
    padding: 0 12px;
    gap: 12px;
    overflow-x: auto;
    scrollbar-width: none;
  }

  .topbar-inner::-webkit-scrollbar {
    display: none;
  }

  .topnav {
    margin-left: 0;
    gap: 12px;
    flex: 0 0 auto;
  }

  .topline {
    display: none;
  }

  .toolbar {
    padding: 7px 8px;
    gap: 6px;
  }

  .menu-row {
    gap: 8px;
  }

  .menu-tabs,
  .ribbon-panel {
    gap: 5px;
  }

  .menu-tabs button,
  .file-button,
  .status-pill,
  .field,
  .tool-group {
    flex: 0 0 auto;
  }

  .field select {
    max-width: 172px;
  }

  .layout {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(170px, 0.8fr) minmax(220px, 1.1fr) minmax(150px, 0.75fr);
    gap: 8px;
    padding: 8px;
  }

  .pane {
    border-radius: 9px;
  }

  .pane-head {
    min-height: 42px;
    padding: 0 8px 0 10px;
  }

  .side-panel {
    display: block;
    max-height: none;
    border-radius: 9px;
  }

  .side-section {
    border-right: 0;
    border-bottom: 1px solid var(--rule);
  }

  .target-tabs {
    max-width: min(100%, 254px);
  }

  .target-tabs button {
    padding: 0 9px;
  }
}
