:root {
  color-scheme: light;
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #eef2f5;
  --border: #cfd7df;
  --border-strong: #9ba8b5;
  --text: #17202a;
  --muted: #5d6874;
  --accent: #0f766e;
  --accent-strong: #0b5f59;
  --danger: #b42318;
  --code: #0f172a;
  --code-bg: #e9edf2;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
textarea {
  font: inherit;
}

button {
  border: 1px solid var(--accent);
  border-radius: 6px;
  background: var(--accent);
  color: #ffffff;
  min-height: 40px;
  padding: 0 14px;
  cursor: pointer;
}

button:hover {
  background: var(--accent-strong);
}

button.secondary,
.tabs button {
  border-color: var(--border);
  background: var(--surface);
  color: var(--text);
}

button.secondary:hover,
.tabs button:hover {
  border-color: var(--border-strong);
  background: var(--surface-2);
}

button.active {
  border-color: var(--accent);
  background: #dcefed;
  color: var(--accent-strong);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.62;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 650;
}

input,
textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #ffffff;
  color: var(--text);
  outline: none;
}

input {
  height: 40px;
  padding: 0 11px;
}

textarea {
  min-height: 340px;
  resize: vertical;
  padding: 12px;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 0.88rem;
  line-height: 1.5;
  tab-size: 2;
}

.libraries-section textarea {
  min-height: 108px;
}

input:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.16);
}

.shell {
  width: min(1240px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 24px 0 36px;
}

.topbar,
.controls,
.workspace,
.panel-heading,
.actions,
.address-row,
.wallet {
  display: flex;
  gap: 16px;
}

.topbar,
.controls,
.panel-heading {
  align-items: center;
  justify-content: space-between;
}

.topbar {
  padding-bottom: 18px;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 1.65rem;
  line-height: 1.15;
}

h2 {
  font-size: 1.25rem;
  line-height: 1.2;
}

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

.wallet {
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.controls {
  margin-bottom: 16px;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
}

.controls label {
  flex: 0 0 180px;
}

.controls .api-key {
  flex: 1 1 360px;
}

.workspace {
  align-items: stretch;
}

.contract-list {
  flex: 0 0 300px;
  display: grid;
  gap: 16px;
  align-content: start;
}

.tabs {
  display: grid;
  gap: 8px;
}

.tabs button {
  min-height: 48px;
  text-align: left;
}

.build-facts,
.contract-panel {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
}

.build-facts {
  display: grid;
  gap: 12px;
  padding: 14px;
}

.build-facts div {
  display: grid;
  gap: 4px;
}

.build-facts span {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
}

.build-facts strong {
  overflow-wrap: anywhere;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 0.8rem;
}

.contract-panel {
  flex: 1 1 auto;
  min-width: 0;
  display: grid;
  gap: 14px;
  padding: 18px;
}

.panel-heading {
  gap: 12px;
}

.panel-heading p {
  margin-top: 4px;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 0.82rem;
  overflow-wrap: anywhere;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 30px;
  max-width: 100%;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted);
  padding: 0 10px;
  font-size: 0.8rem;
  font-weight: 700;
  white-space: nowrap;
}

.json-editor-label {
  margin-top: 2px;
}

.actions {
  flex-wrap: wrap;
}

.address-row {
  align-items: start;
}

.address-row label {
  flex: 1 1 260px;
}

.log {
  min-height: 150px;
  max-height: 300px;
  overflow: auto;
  margin: 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--code-bg);
  color: var(--code);
  padding: 12px;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 0.82rem;
  line-height: 1.5;
  white-space: pre-wrap;
}

.log.error {
  border-color: rgba(180, 35, 24, 0.5);
  color: var(--danger);
}

@media (max-width: 840px) {
  .shell {
    width: min(100vw - 20px, 760px);
    padding-top: 16px;
  }

  .topbar,
  .controls,
  .workspace,
  .panel-heading,
  .address-row {
    flex-direction: column;
    align-items: stretch;
  }

  .wallet {
    justify-content: flex-start;
  }

  .controls label,
  .contract-list {
    flex-basis: auto;
  }

  .contract-list {
    width: 100%;
  }

  textarea {
    min-height: 280px;
  }
}
