:root {
  color-scheme: light;
  --ink: #14213d;
  --muted: #5f6778;
  --line: #d9dfeb;
  --paper: #f7f4ef;
  --panel: #ffffff;
  --accent: #fca311;
  --accent-2: #2a9d8f;
  --danger: #c44536;
  --shadow: 0 18px 50px rgba(20, 33, 61, 0.12);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: Arial, Helvetica, sans-serif;
  letter-spacing: 0;
}

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

a {
  color: inherit;
  text-decoration: none;
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 10;
  display: grid;
  grid-template-columns: 1fr auto auto;
  align-items: center;
  gap: 24px;
  padding: 14px clamp(16px, 4vw, 48px);
  background: rgba(247, 244, 239, 0.92);
  border-bottom: 1px solid rgba(20, 33, 61, 0.1);
  backdrop-filter: blur(14px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 800;
}

.brand img {
  width: 34px;
  height: 34px;
}

.top-nav {
  display: flex;
  align-items: center;
  gap: 18px;
  color: var(--muted);
  font-size: 14px;
}

.ghost-button,
.secondary-button,
.primary-button,
.icon-button {
  border: 0;
  cursor: pointer;
}

.ghost-button {
  min-height: 38px;
  padding: 0 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--ink);
}

main {
  padding: 28px clamp(16px, 4vw, 48px) 48px;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(320px, 0.65fr);
  gap: 18px;
  min-height: calc(100vh - 120px);
  align-items: start;
}

.tool-console,
.result-panel,
.pricing-grid article,
.api-band {
  background: var(--panel);
  border: 1px solid rgba(20, 33, 61, 0.1);
  box-shadow: var(--shadow);
}

.tool-console {
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  padding: clamp(18px, 3vw, 34px);
  border-radius: 8px;
}

.console-head {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: flex-start;
  margin-bottom: 22px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--accent-2);
  font-size: 13px;
  font-weight: 800;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  max-width: 560px;
  font-size: clamp(28px, 3.5vw, 44px);
  line-height: 1.08;
}

h2 {
  font-size: clamp(26px, 3vw, 42px);
  line-height: 1.05;
}

.usage-pill {
  min-width: 132px;
  padding: 12px;
  border-radius: 8px;
  background: #eef6f4;
  color: var(--ink);
}

.usage-pill span,
.usage-pill strong {
  display: block;
}

.usage-pill span {
  color: var(--muted);
  font-size: 13px;
}

.processor {
  display: grid;
  gap: 16px;
}

.dropzone {
  display: grid;
  place-items: center;
  min-height: 170px;
  padding: 20px;
  border: 2px dashed #b8c0cf;
  border-radius: 8px;
  background: #fbfcff;
  color: var(--muted);
  text-align: center;
  cursor: pointer;
}

.dropzone input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.drop-icon {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  margin-bottom: 8px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--ink);
  font-size: 28px;
  font-weight: 700;
}

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

label {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
}

select,
input,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
}

select {
  min-height: 46px;
  padding: 0 12px;
}

input {
  min-height: 46px;
  padding: 0 12px;
}

textarea {
  resize: vertical;
  padding: 12px;
}

.form-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.primary-button,
.secondary-button {
  min-height: 46px;
  padding: 0 18px;
  border-radius: 8px;
  font-weight: 800;
}

.primary-button {
  background: var(--ink);
  color: #fff;
}

.secondary-button {
  background: #eef2f7;
  color: var(--ink);
}

.result-panel {
  display: grid;
  grid-template-rows: auto 1fr;
  max-height: calc(100vh - 112px);
  border-radius: 8px;
  overflow: hidden;
  position: sticky;
  top: 84px;
}

.result-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  font-weight: 800;
}

.result-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.compact-button {
  min-height: 36px;
  padding: 0 12px;
  font-size: 13px;
  white-space: nowrap;
}

.icon-button {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  background: #eef2f7;
  color: var(--ink);
}

pre {
  margin: 0;
  padding: 18px;
  overflow: auto;
  white-space: pre-wrap;
  color: #28344e;
  font-family: Consolas, "Courier New", monospace;
  line-height: 1.55;
}

.result-dialog {
  width: min(980px, 100%);
  max-height: min(820px, calc(100vh - 36px));
  display: grid;
  grid-template-rows: auto minmax(260px, 1fr);
  border-radius: 8px;
  border: 1px solid rgba(20, 33, 61, 0.12);
  background: var(--panel);
  box-shadow: var(--shadow);
  overflow: hidden;
}

#resultModalBox {
  max-height: none;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin: 18px 0 70px;
}

.metrics div {
  padding: 18px;
  border-radius: 8px;
  background: #e9edf5;
}

.metrics strong,
.metrics span {
  display: block;
}

.metrics strong {
  font-size: 24px;
}

.metrics span {
  color: var(--muted);
}

.section {
  margin-top: 72px;
}

.section-head {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  align-items: end;
  margin-bottom: 18px;
}

.category-tabs {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 10px;
}

.category-tabs button {
  flex: 0 0 auto;
  min-height: 38px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--muted);
  cursor: pointer;
}

.category-tabs button.active {
  background: var(--ink);
  color: #fff;
  border-color: var(--ink);
}

.tool-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.tool-card {
  min-height: 76px;
  padding: 14px;
  border: 1px solid rgba(20, 33, 61, 0.1);
  border-radius: 8px;
  background: #fff;
  color: #24324d;
  font-weight: 700;
}

.history-section[hidden] {
  display: none;
}

.history-list {
  display: grid;
  gap: 10px;
  max-height: 430px;
  overflow: auto;
  padding-right: 4px;
}

.history-actions {
  display: flex;
  gap: 10px;
  align-items: center;
}

.history-actions input {
  width: min(260px, 42vw);
}

.history-note {
  margin: -6px 0 14px;
  color: var(--muted);
  font-size: 14px;
}

.full-history-toolbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  padding: 16px;
  border-bottom: 1px solid var(--line);
}

.full-history-list {
  max-height: none;
  padding: 16px;
  overflow: auto;
}

.history-pager {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  padding: 14px 16px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 14px;
}

.history-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 16px;
  align-items: start;
  padding: 14px;
  border: 1px solid rgba(20, 33, 61, 0.1);
  border-radius: 8px;
  background: #fff;
}

.history-item strong,
.history-item span {
  display: block;
}

.history-item strong {
  margin-bottom: 6px;
}

.history-item span {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.45;
}

.history-time {
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
}

.history-row-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  justify-content: flex-end;
  color: var(--muted);
  font-size: 13px;
}

.empty-history {
  padding: 18px;
  border: 1px solid rgba(20, 33, 61, 0.1);
  border-radius: 8px;
  background: #fff;
  color: var(--muted);
}

.split {
  display: grid;
  grid-template-columns: 0.75fr 1.25fr;
  gap: 22px;
  align-items: start;
}

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

.pricing-grid article {
  padding: 18px;
  border-radius: 8px;
}

.pricing-grid article span,
.pricing-grid article strong {
  display: block;
}

.pricing-grid article span {
  color: var(--muted);
  font-weight: 800;
}

.pricing-grid article strong {
  margin: 12px 0;
  font-size: 30px;
}

.pricing-grid article p {
  margin: 0;
  color: var(--muted);
  line-height: 1.45;
}

.pricing-grid .featured {
  background: var(--ink);
  color: #fff;
}

.pricing-grid .featured p,
.pricing-grid .featured span {
  color: #dbe3f2;
}

.api-band {
  display: flex;
  justify-content: space-between;
  gap: 22px;
  align-items: center;
  padding: 24px;
  border-radius: 8px;
}

.api-band code {
  padding: 14px 16px;
  border-radius: 8px;
  background: #10182c;
  color: #fff;
  white-space: nowrap;
}

.auth-modal {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(20, 33, 61, 0.42);
}

.auth-modal[hidden] {
  display: none;
}

.auth-dialog {
  width: min(440px, 100%);
  border-radius: 8px;
  border: 1px solid rgba(20, 33, 61, 0.12);
  background: var(--panel);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.history-dialog {
  width: min(860px, 100%);
  max-height: min(760px, calc(100vh - 36px));
  display: grid;
  grid-template-rows: auto auto minmax(220px, 1fr) auto;
  border-radius: 8px;
  border: 1px solid rgba(20, 33, 61, 0.12);
  background: var(--panel);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.auth-tabs {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  padding: 16px 16px 0;
}

.auth-tabs button {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--muted);
  cursor: pointer;
}

.auth-tabs button.active {
  background: var(--ink);
  color: #fff;
  border-color: var(--ink);
}

.auth-form {
  display: grid;
  gap: 14px;
  padding: 16px;
}

.auth-message {
  min-height: 20px;
  margin: 0;
  color: var(--danger);
  font-size: 14px;
  line-height: 1.4;
}

@media (max-width: 980px) {
  .workspace,
  .split {
    grid-template-columns: 1fr;
  }

  .workspace {
    min-height: auto;
  }

  .result-panel {
    max-height: 520px;
    position: static;
  }

  .tool-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 680px) {
  .app-header {
    grid-template-columns: 1fr auto;
  }

  .top-nav {
    display: none;
  }

  main {
    padding-top: 16px;
  }

  .console-head,
  .section-head,
  .api-band {
    display: grid;
  }

  h1 {
    font-size: 32px;
  }

  .field-grid,
  .metrics,
  .pricing-grid,
  .tool-grid {
    grid-template-columns: 1fr;
  }

  .history-actions {
    display: grid;
  }

  .history-actions input {
    width: 100%;
  }

  .full-history-toolbar,
  .history-pager {
    display: grid;
    grid-template-columns: 1fr;
  }

  .form-actions button {
    width: 100%;
  }

  .history-item {
    grid-template-columns: 1fr;
  }

  .history-time {
    white-space: normal;
  }

  .history-row-actions {
    justify-content: flex-start;
    flex-wrap: wrap;
  }
}
