/* LATE UI — uses canonical Lawvo tokens (lawvo-theme-tokens.css) */

@import url('https://fonts.googleapis.com/css2?family=Roboto:wght@400;500;600;700&family=Roboto+Mono:wght@400;500&display=swap');
@import url('./lawvo-theme-tokens.css');

:root {
  --late-shadow: #00000026 0px 4px 10px;
  --late-radius: 2px;
  --late-font: 'Roboto', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --late-mono: 'Roboto Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --late-focus-ring: color-mix(in srgb, var(--lawvo-violetBlue) 22%, transparent);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  min-height: 100vh;
  background: var(--lawvo-aliceBlue);
  color: var(--lawvo-bodyText);
  font-family: var(--late-font);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

h1,
h2,
h3,
p {
  margin: 0;
}

a {
  color: var(--lawvo-violetBlue);
}

a:hover {
  color: var(--lawvo-violetBlueHover);
}

[hidden] {
  display: none !important;
}

:focus-visible {
  outline: 2px solid var(--lawvo-violetBlue);
  outline-offset: 2px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.label {
  font-size: 13px;
  font-weight: 500;
  color: var(--lawvo-bodyText);
}

.hint {
  font-size: 12px;
  color: var(--lawvo-secondary);
}

.field-error {
  font-size: 12px;
  color: var(--lawvo-destructive);
}

.input,
.select,
.textarea {
  width: 100%;
  border: 1px solid var(--lawvo-inputBorderColor);
  border-radius: var(--late-radius);
  background: var(--lawvo-pageBackground);
  color: var(--lawvo-bodyText);
  font: inherit;
  transition: border-color 120ms, box-shadow 120ms;
}

.input,
.select {
  height: 40px;
  padding: 0 12px;
}

.select {
  appearance: none;
  padding-right: 36px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='none' stroke='%237e8299' stroke-width='2' stroke-linecap='round' stroke-linejoin='round' viewBox='0 0 24 24'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
}

.textarea {
  display: block;
  min-height: 320px;
  padding: 10px 12px;
  resize: vertical;
  background: var(--lawvo-aliceBlue);
  font-family: var(--late-mono);
  font-size: 12px;
  line-height: 20px;
  tab-size: 2;
}

.input:focus,
.select:focus,
.textarea:focus {
  outline: none;
  border-color: var(--lawvo-violetBlue);
  box-shadow: 0 0 0 3px var(--late-focus-ring);
}

.input[aria-invalid='true'],
.textarea[aria-invalid='true'] {
  border-color: var(--lawvo-destructive);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 40px;
  padding: 0 18px;
  border: 1px solid transparent;
  border-radius: var(--late-radius);
  font: inherit;
  font-weight: 500;
  cursor: pointer;
  box-shadow: var(--late-shadow);
  transition: opacity 120ms, background-color 120ms, border-color 120ms;
}

.btn-primary {
  background: var(--lawvo-violetBlue);
  border-color: var(--lawvo-violetBlue);
  color: var(--lawvo-onAccent);
  font-weight: 500;
}

.btn-primary:hover {
  background: var(--lawvo-violetBlue);
  border-color: var(--lawvo-violetBlue);
  opacity: 0.9;
}

.btn-primary:active {
  background: var(--lawvo-violetBlue);
  opacity: 1;
}

.btn-primary:disabled {
  background: var(--lawvo-disabled);
  border-color: var(--lawvo-disabled);
  color: var(--lawvo-secondary);
  opacity: 1;
  cursor: not-allowed;
}

.btn-secondary {
  background: var(--lawvo-pageBackground);
  border-color: var(--lawvo-inputBorderColor);
  color: var(--lawvo-bodyText);
  box-shadow: none;
}

.btn-secondary:hover {
  background: var(--lawvo-modalCancelBg);
}

.btn-block {
  width: 100%;
}

.link-btn {
  padding: 4px 2px;
  border: 0;
  background: none;
  box-shadow: none;
  color: var(--lawvo-violetBlue);
  font: inherit;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
}

.link-btn:hover {
  color: var(--lawvo-violetBlueHover);
  text-decoration: underline;
  opacity: 1;
}

.spinner {
  width: 16px;
  height: 16px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: spin 700ms linear infinite;
}

.spinner-lg {
  width: 24px;
  height: 24px;
  color: var(--lawvo-violetBlue);
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.alert {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  padding: 10px 12px;
  border: 1px solid color-mix(in srgb, var(--lawvo-destructive) 35%, transparent);
  border-radius: var(--late-radius);
  background: color-mix(in srgb, var(--lawvo-destructive) 8%, white);
  color: var(--lawvo-destructive);
  font-size: 13px;
}

.alert svg {
  flex-shrink: 0;
  margin-top: 2px;
}

.auth {
  display: flex;
  min-height: 100vh;
  align-items: center;
  justify-content: center;
  padding: 48px 16px;
}

.auth-card {
  width: 100%;
  max-width: 400px;
  padding: 32px;
  border: 1px solid var(--lawvo-borderColor);
  border-radius: var(--late-radius);
  background: var(--lawvo-pageBackground);
  box-shadow: var(--late-shadow);
}

.auth-head {
  text-align: center;
}

.auth-logo {
  display: block;
  height: 36px;
  width: auto;
  margin: 0 auto 20px;
}

.auth-title {
  font-size: 24px;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--lawvo-bodyText);
}

.auth-head::after {
  content: '';
  display: block;
  width: 32px;
  height: 3px;
  margin: 16px auto 0;
  border-radius: var(--late-radius);
  background: linear-gradient(90deg, var(--lawvo-turquoise), var(--lawvo-violetBlue));
}

.auth-subtitle {
  margin-top: 4px;
  color: var(--lawvo-secondary);
  font-size: 13px;
}

.env-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 12px;
  padding: 2px 8px;
  border: 1px solid var(--lawvo-borderColor);
  border-radius: var(--late-radius);
  background: var(--lawvo-menuHoverBg);
  color: var(--lawvo-violetBlue);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.env-badge::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--lawvo-violetBlue);
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-top: 24px;
}

.auth-footer {
  margin-top: 24px;
  padding-top: 16px;
  border-top: 1px solid var(--lawvo-borderColor);
  text-align: center;
  color: var(--lawvo-secondary);
  font-size: 12px;
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 10;
  border-bottom: 1px solid var(--lawvo-borderColor);
  background: var(--lawvo-pageBackground);
}

.app-header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  max-width: 1440px;
  height: 56px;
  margin: 0 auto;
  padding: 0 24px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.brand-logo {
  height: 24px;
  width: auto;
}

.brand-divider {
  width: 1px;
  height: 24px;
  background: var(--lawvo-borderColor);
}

.brand-name {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: var(--lawvo-bodyText);
}

.brand-desc {
  color: var(--lawvo-secondary);
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user {
  display: flex;
  align-items: center;
  gap: 16px;
  font-size: 13px;
}

.user-email {
  color: var(--lawvo-secondary);
}

.main {
  max-width: 1440px;
  margin: 0 auto;
  padding: 24px;
}

.page-head {
  margin-bottom: 20px;
}

.page-title {
  font-size: 20px;
  font-weight: 600;
  color: var(--lawvo-bodyText);
}

.page-desc {
  margin-top: 2px;
  color: var(--lawvo-secondary);
  font-size: 13px;
}

.panel {
  border: 1px solid var(--lawvo-borderColor);
  border-radius: var(--late-radius);
  background: var(--lawvo-pageBackground);
  box-shadow: var(--late-shadow);
}

.panel + .panel {
  margin-top: 24px;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--lawvo-borderColor);
}

.panel-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--lawvo-bodyText);
}

.panel-meta {
  color: var(--lawvo-secondary);
  font-size: 12px;
  font-family: var(--late-mono);
}

.panel-body {
  padding: 20px;
}

.panel-foot {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  padding: 12px 20px;
  border-top: 1px solid var(--lawvo-borderColor);
  background: var(--lawvo-aliceBlue);
}

.template-row {
  max-width: 560px;
}

.editor-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-top: 20px;
}

.editor-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 8px;
}

.status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 2px 8px;
  border: 1px solid var(--lawvo-borderColor);
  border-radius: var(--late-radius);
  background: var(--lawvo-aliceBlue);
  color: var(--lawvo-secondary);
  font-size: 12px;
  font-weight: 500;
}

.status::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

.status[data-state='running'] {
  color: var(--lawvo-violetBlue);
  border-color: color-mix(in srgb, var(--lawvo-violetBlue) 35%, transparent);
  background: var(--lawvo-menuHoverBg);
}

.status[data-state='success'] {
  color: var(--lawvo-successGreen);
  border-color: color-mix(in srgb, var(--lawvo-successGreen) 35%, transparent);
  background: color-mix(in srgb, var(--lawvo-successGreen) 8%, white);
}

.status[data-state='error'] {
  color: var(--lawvo-destructive);
  border-color: color-mix(in srgb, var(--lawvo-destructive) 35%, transparent);
  background: color-mix(in srgb, var(--lawvo-destructive) 8%, white);
}

.output-empty,
.output-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 240px;
  text-align: center;
  color: var(--lawvo-secondary);
}

.output-empty strong {
  color: var(--lawvo-bodyText);
  font-size: 14px;
}

.json-output {
  margin: 0;
  max-height: 560px;
  overflow: auto;
  padding: 12px 14px;
  border: 1px solid var(--lawvo-borderColor);
  border-radius: var(--late-radius);
  background: var(--lawvo-aliceBlue);
  font-family: var(--late-mono);
  font-size: 12px;
  line-height: 20px;
  white-space: pre-wrap;
  word-break: break-word;
}

@media (max-width: 900px) {
  .editor-grid {
    grid-template-columns: 1fr;
  }
  .brand-desc {
    display: none;
  }
}

@media (max-width: 600px) {
  .app-header-inner,
  .main {
    padding-left: 16px;
    padding-right: 16px;
  }
  .user-email {
    display: none;
  }
  .auth-card {
    padding: 24px;
  }
  .panel-foot {
    flex-direction: column-reverse;
    align-items: stretch;
  }
  .panel-foot .btn {
    width: 100%;
  }
}
