:root {
  color: #1c252c;
  background: #f1f3f5;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  min-width: 320px;
  margin: 0;
}

button,
input {
  font: inherit;
}

.app-shell {
  min-height: 100vh;
  padding: 24px;
}

.topbar {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 24px;
  width: min(1180px, 100%);
  margin: 0 auto 18px;
}

.eyebrow,
.domain {
  margin: 0 0 6px;
  color: #69747d;
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  line-height: 1.1;
}

h1 {
  font-size: 2rem;
}

h2 {
  font-size: 1.55rem;
}

.format-control {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0;
  border: 1px solid #c9d0d7;
  border-radius: 8px;
  background: #ffffff;
  padding: 8px;
}

.format-control label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 32px;
  border-radius: 6px;
  padding: 4px 8px;
  color: #33414d;
  font-size: 0.88rem;
  font-weight: 700;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(240px, 320px) minmax(0, 1fr);
  gap: 18px;
  width: min(1180px, 100%);
  margin: 0 auto;
}

.formula-pane,
.calculator-pane {
  border: 1px solid #d3d9df;
  border-radius: 8px;
  background: #ffffff;
}

.formula-pane {
  padding: 16px;
}

.calculator-pane {
  padding: 20px;
}

.search-label,
.input-row span {
  display: block;
  color: #2d3943;
  font-size: 0.9rem;
  font-weight: 800;
}

#formula-search,
.input-row input {
  width: 100%;
  min-height: 42px;
  margin-top: 8px;
  border: 1px solid #b9c3cc;
  border-radius: 6px;
  padding: 9px 11px;
  color: #1c252c;
  background: #ffffff;
}

.formula-list {
  display: grid;
  gap: 8px;
  max-height: calc(100vh - 190px);
  margin-top: 14px;
  overflow: auto;
}

.formula-item {
  display: grid;
  gap: 4px;
  width: 100%;
  min-height: 58px;
  border: 1px solid #d6dde3;
  border-radius: 6px;
  background: #f9fafb;
  padding: 10px;
  color: #23313c;
  text-align: left;
  cursor: pointer;
}

.formula-item span {
  font-weight: 800;
}

.formula-item code,
#formula-equation {
  color: #6f4a14;
  font-family: "Cascadia Mono", "SFMono-Regular", Consolas, monospace;
  font-size: 0.86rem;
}

.formula-item:hover,
.formula-item.is-selected {
  border-color: #2f6f6d;
  background: #eef8f6;
}

.formula-summary {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 18px;
  border-bottom: 1px solid #e1e5e9;
  padding-bottom: 16px;
}

#formula-equation {
  min-width: fit-content;
  border: 1px solid #e0d0b8;
  border-radius: 6px;
  background: #fff8ed;
  padding: 8px 10px;
}

.details {
  min-height: 44px;
  margin: 16px 0;
  color: #40505d;
  font: inherit;
  white-space: pre-wrap;
}

.input-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.input-row {
  min-width: 0;
}

.input-row small {
  display: block;
  min-height: 34px;
  margin-top: 4px;
  color: #69747d;
  font-size: 0.76rem;
  overflow-wrap: anywhere;
}

.actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 18px;
}

#calculate,
.examples button {
  min-height: 40px;
  border: 1px solid #2f6f6d;
  border-radius: 6px;
  background: #2f6f6d;
  color: #ffffff;
  padding: 9px 14px;
  font-weight: 800;
  cursor: pointer;
}

#calculate:hover {
  background: #275f5d;
}

.examples {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.examples button {
  border-color: #c8d0d8;
  background: #f7f9fb;
  color: #28343f;
}

.examples button:hover {
  background: #e9eef3;
}

.result {
  display: block;
  min-height: 54px;
  margin-top: 18px;
  border: 1px solid #c7d8d6;
  border-radius: 6px;
  background: #eef8f6;
  padding: 14px;
  color: #17423f;
  font-family: "Cascadia Mono", "SFMono-Regular", Consolas, monospace;
  overflow-wrap: anywhere;
}

.result.is-error {
  border-color: #e5b8b8;
  background: #fff1f1;
  color: #8b2525;
}

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

  .topbar,
  .workspace,
  .formula-summary,
  .actions {
    display: grid;
  }

  .workspace,
  .input-grid {
    grid-template-columns: 1fr;
  }

  .formula-list {
    max-height: 260px;
  }

  .examples {
    justify-content: start;
  }
}