html,
body {
  margin: 0;
  min-height: 100%;
}

* {
  box-sizing: border-box;
}

body {
  font-family: ui-monospace, 'SF Mono', Menlo, Monaco, Consolas, monospace;
  font-size: 13px;
  line-height: 1.45;
  color: #d4d4d4;
  background: #0a0a0a;
  background-image: linear-gradient(
      rgba(163, 163, 163, 0.04) 1px,
      transparent 1px
    ),
    linear-gradient(90deg, rgba(163, 163, 163, 0.04) 1px, transparent 1px);
  background-size: 24px 24px;
}

.shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.shell-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid #262626;
}

.shell-title {
  letter-spacing: 0.12em;
  text-transform: lowercase;
  color: #a3a3a3;
  font-size: 11px;
}

.shell-header-actions {
  display: flex;
  align-items: center;
}

.btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.35rem;
  border: 1px solid #404040;
  background: #141414;
  color: #a3a3a3;
  cursor: pointer;
  border-radius: 4px;
  transition:
    color 0.15s ease,
    border-color 0.15s ease,
    background 0.15s ease;
}

.btn-icon:hover {
  color: #e5e5e5;
  border-color: #525252;
  background: #1a1a1a;
}

.btn-icon[aria-expanded='true'] {
  color: #fafafa;
  border-color: #737373;
  background: #262626;
}

.btn-icon-svg {
  display: block;
}

.settings-panel {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.32s ease;
  border-bottom: 1px solid transparent;
}

.settings-panel-open {
  max-height: 14rem;
  border-bottom-color: #262626;
}

.settings-panel:not(.settings-panel-open) {
  pointer-events: none;
}

.settings-panel-inner {
  opacity: 0;
  transform: translateY(-6px);
  transition:
    opacity 0.22s ease 0.04s,
    transform 0.28s ease;
}

.settings-panel-open .settings-panel-inner {
  opacity: 1;
  transform: translateY(0);
}

.shell-main {
  flex: 1;
  display: grid;
  grid-template-columns: minmax(280px, 1fr) minmax(280px, 1fr);
  gap: 0;
  align-items: stretch;
}

@media (max-width: 800px) {
  .shell-main {
    grid-template-columns: 1fr;
  }
}

.col-left,
.col-right {
  padding: 1rem;
  border-right: 1px solid #262626;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  animation: col-fade-in 0.45s ease-out;
}

@keyframes col-fade-in {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.col-right {
  border-right: none;
}

.shell-footer {
  border-top: 1px solid #262626;
  background: rgba(10, 10, 10, 0.85);
}

.shell-footer-links {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5rem 1rem 0.35rem;
  font-size: 11px;
}

.shell-footer-spacer {
  min-width: 0;
}

.footer-link {
  color: #737373;
  text-decoration: none;
  text-transform: lowercase;
  transition: color 0.15s ease;
}

.footer-link:hover {
  color: #d4d4d4;
}

.footer-link-bmc {
  justify-self: center;
  grid-column: 2;
}

.footer-link-x {
  justify-self: end;
  grid-column: 3;
}

.shell-status {
  padding: 0 1rem 0.5rem;
  font-size: 11px;
  color: #737373;
  text-align: center;
}

.settings-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem 1rem;
  padding: 0.6rem 1rem;
  background: rgba(23, 23, 23, 0.95);
}

.settings-field {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 11px;
  color: #a3a3a3;
  text-transform: lowercase;
}

.settings-field.checkbox {
  gap: 0.4rem;
}

.panel {
  border: 1px solid #262626;
  background: rgba(20, 20, 20, 0.55);
  padding: 0.75rem;
  animation: panel-in 0.4s ease-out;
}

@keyframes panel-in {
  from {
    opacity: 0;
    transform: translateY(4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.panel-label {
  font-size: 10px;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: #737373;
  margin-bottom: 0.65rem;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin-bottom: 0.65rem;
}

.field-label {
  font-size: 11px;
  color: #737373;
  text-transform: lowercase;
}

.input {
  width: 100%;
  padding: 0.45rem 0.5rem;
  border: 1px solid #404040;
  background: #0f0f0f;
  color: #e5e5e5;
  font: inherit;
}

.input:focus {
  outline: 1px solid #737373;
  outline-offset: 0;
}

.input-inline {
  width: auto;
  min-width: 8rem;
}

.input-narrow {
  width: 4.5rem;
}

.textarea {
  min-height: 5rem;
  resize: vertical;
}

.btn {
  font: inherit;
  padding: 0.35rem 0.65rem;
  border: 1px solid #404040;
  background: #141414;
  color: #d4d4d4;
  cursor: pointer;
  transition:
    border-color 0.15s ease,
    color 0.15s ease,
    background 0.15s ease;
}

.btn:hover:not(:disabled) {
  border-color: #737373;
  color: #fafafa;
}

.btn:disabled {
  opacity: 0.35;
  cursor: default;
}

.btn-accent {
  border-color: #525252;
  color: #e5e5e5;
}

.btn-sm {
  padding: 0.2rem 0.45rem;
  font-size: 11px;
}

.btn.danger:hover:not(:disabled) {
  border-color: #f87171;
  color: #fca5a5;
}

.quick-add-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-bottom: 0.5rem;
}

.meta {
  font-size: 11px;
  color: #737373;
}

.meta.empty-hint {
  margin: 0.5rem 0;
}

.dim {
  opacity: 0.75;
}

.field-error {
  color: #f87171;
  font-size: 11px;
  margin: 0 0 0.5rem;
}

.dup-banner {
  margin-top: 0.5rem;
  padding: 0.5rem;
  border: 1px solid #854d0e;
  background: rgba(120, 53, 15, 0.2);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  font-size: 12px;
}

.lex-toolbar {
  margin-bottom: 0.5rem;
}

.table-wrap {
  overflow-x: auto;
  max-height: min(50vh, 28rem);
  overflow-y: auto;
}

.lex-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

.lex-table th {
  text-align: left;
  font-weight: normal;
  color: #737373;
  text-transform: lowercase;
  font-size: 10px;
  padding: 0.35rem 0.25rem;
  border-bottom: 1px solid #262626;
}

.lex-table td {
  padding: 0.4rem 0.25rem;
  border-bottom: 1px solid #1f1f1f;
  vertical-align: middle;
}

.lex-row {
  animation: lex-row-in 0.38s ease-out;
}

@keyframes lex-row-in {
  from {
    opacity: 0;
    transform: translateX(-10px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

.lex-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  justify-content: flex-end;
}

.linkish {
  background: none;
  border: none;
  color: #e5e5e5;
  font: inherit;
  cursor: pointer;
  text-align: left;
  padding: 0;
  transition: color 0.15s ease;
}

.linkish:hover {
  color: #fafafa;
}

.mono {
  font-family: inherit;
}

.lexicon-panel {
  flex: 1;
  min-height: 0;
}

.composer-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.unknown-banner {
  margin: 0.5rem 0;
  padding: 0.45rem 0.5rem;
  border: 1px solid #7c2d12;
  background: rgba(124, 45, 18, 0.15);
  font-size: 11px;
}

.token-unknown {
  display: inline-block;
  margin-right: 0.35rem;
  padding: 0.1rem 0.25rem;
  background: rgba(127, 29, 29, 0.35);
  color: #fca5a5;
}

.token-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin: 0.65rem 0;
  min-height: 1.5rem;
  align-items: center;
}

.token-chip {
  padding: 0.15rem 0.4rem;
  border: 1px solid #404040;
  font-size: 11px;
  transition:
    border-color 0.15s ease,
    box-shadow 0.15s ease;
}

.token-known {
  border-color: #525252;
  color: #d4d4d4;
}

.token-miss {
  border-color: #7f1d1d;
  color: #fca5a5;
}

.token-active {
  box-shadow: 0 0 0 1px #a3a3a3;
  background: rgba(163, 163, 163, 0.1);
}

.composer-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: auto;
  padding-top: 0.5rem;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

select.input {
  cursor: pointer;
}

@media (prefers-reduced-motion: reduce) {
  .col-left,
  .col-right,
  .panel,
  .lex-row,
  .settings-panel,
  .settings-panel-inner {
    animation: none !important;
    transition: none !important;
  }

  .settings-panel-open {
    transition: none;
  }
}
