:root {
  --bg: #111111;
  --surface: #181818;
  --surface-soft: #202020;
  --surface-lift: #242424;
  --ink: #f4f4f4;
  --muted: #9b9b9b;
  --line: #303030;
  --line-strong: #5d5d5d;
  --accent: #ff6a00;
  --accent-dark: #d95500;
  --red: #ff6b5f;
  --shadow: 0 18px 42px rgba(0, 0, 0, 0.34);
  --radius: 8px;
  --focus: 0 0 0 3px rgba(255, 106, 0, 0.28);
  color-scheme: dark;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-width: 320px;
  background:
    radial-gradient(circle at 24% 28%, rgba(255, 106, 0, 0.09), transparent 32%),
    var(--bg);
  color: var(--ink);
  font-family:
    Inter,
    ui-sans-serif,
    system-ui,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    sans-serif;
}

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

button,
select,
input[type="file"],
.file-button {
  cursor: pointer;
}

button:disabled,
input:disabled,
select:disabled,
textarea:disabled,
.is-locked .file-button {
  cursor: not-allowed;
  opacity: 0.56;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
.file-button:focus-visible,
a:focus-visible {
  outline: none;
  box-shadow: var(--focus);
}

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

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 22px clamp(18px, 4vw, 50px);
  border-bottom: 1px solid rgba(255, 106, 0, 0.16);
  background: rgba(17, 17, 17, 0.92);
  backdrop-filter: blur(16px);
}

.brand {
  min-width: 0;
  display: inline-flex;
  align-items: center;
  gap: 14px;
  color: inherit;
  text-decoration: none;
}

.brand-mark {
  min-width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  border-radius: var(--radius);
  background: var(--accent);
  color: #111111;
  font-size: 0.86rem;
  font-weight: 900;
  letter-spacing: 0;
}

.brand-name,
.brand-subtitle {
  display: block;
}

.brand-name {
  color: var(--accent);
  font-size: clamp(1.25rem, 2vw, 1.65rem);
  font-weight: 900;
  line-height: 1.05;
}

.brand-subtitle {
  margin-top: 3px;
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.2;
}

.topbar-link {
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 14px;
  border: 1px solid var(--accent);
  border-radius: 7px;
  background: var(--accent);
  color: #111111;
  font-weight: 850;
  text-decoration: none;
}

main {
  width: min(1480px, 100%);
  margin: 0 auto;
  padding: 28px clamp(14px, 3vw, 42px);
  flex: 1;
}

h1,
h2,
h3,
p {
  overflow-wrap: anywhere;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(310px, 0.34fr) minmax(0, 1fr);
  gap: 20px;
  align-items: start;
}

.library-panel,
.detail-panel,
.editor-sidebar,
.editor-form {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(24, 24, 24, 0.96);
  box-shadow: var(--shadow);
}

.library-panel {
  position: sticky;
  top: 112px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.toolbar {
  padding: 18px;
  background: linear-gradient(180deg, rgba(255, 106, 0, 0.08), rgba(24, 24, 24, 0));
}

label span,
.select-block span {
  display: block;
  margin-bottom: 7px;
  color: var(--muted);
  font-size: 0.77rem;
  font-weight: 850;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

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

input,
select {
  min-height: 44px;
  padding: 0 12px;
}

textarea {
  min-height: 118px;
  padding: 11px 12px;
  resize: vertical;
  line-height: 1.45;
}

input::placeholder,
textarea::placeholder {
  color: #777777;
}

.select-block {
  margin-bottom: 16px;
}

.select-block:last-child {
  margin-bottom: 0;
}

.detail-panel {
  min-height: 640px;
  overflow: hidden;
}

.detail-hero {
  display: grid;
  gap: 16px;
  padding: clamp(20px, 3vw, 34px);
  border-bottom: 1px solid var(--line);
  background:
    radial-gradient(circle at top right, rgba(255, 106, 0, 0.16), transparent 34%),
    var(--surface);
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 850;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.detail-title {
  margin: 0 0 9px;
  color: var(--accent);
  font-size: clamp(2rem, 4vw, 4rem);
  line-height: 0.98;
  letter-spacing: 0;
}

.brand-list,
.detail-subtitle {
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.35;
}

.tag-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.tag {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 5px 9px;
  border: 1px solid rgba(255, 106, 0, 0.38);
  border-radius: 999px;
  background: rgba(255, 106, 0, 0.11);
  color: var(--accent);
  font-size: 0.77rem;
  font-weight: 850;
  line-height: 1;
  white-space: nowrap;
}

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

.info-section {
  min-height: 180px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-soft);
  scroll-margin-top: 96px;
}

.info-section.wide {
  grid-column: 1 / -1;
}

.info-section h2,
.info-section h3 {
  margin: 0 0 10px;
  color: var(--ink);
  font-size: 1.04rem;
}

.info-section p,
.info-section li {
  color: #c2c2c2;
  font-size: 0.96rem;
  line-height: 1.58;
}

.section-subheading {
  margin: 16px 0 8px;
  color: var(--accent);
  font-size: 0.98rem;
  line-height: 1.25;
}

.info-section p {
  margin: 0;
}

.info-section p + p {
  margin-top: 10px;
}

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

.dose-grid div {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #151515;
}

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

.dose-grid strong {
  margin-bottom: 5px;
  color: var(--accent);
  font-size: 0.78rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.dose-grid span {
  color: #c2c2c2;
  line-height: 1.35;
}

.section-list {
  margin: 0 0 10px;
  padding-left: 18px;
}

.section-list li + li {
  margin-top: 7px;
}

.section-list .indent-1 {
  margin-left: 18px;
}

.section-list .indent-2,
.section-list .indent-3 {
  margin-left: 36px;
}

.empty-state {
  padding: 34px;
  color: var(--muted);
  text-align: center;
}

.editor-layout {
  display: grid;
  grid-template-columns: minmax(270px, 0.32fr) minmax(0, 1fr);
  gap: 20px;
  align-items: start;
}

.editor-sidebar {
  position: sticky;
  top: 112px;
  padding: 18px;
}

.auth-panel {
  display: grid;
  gap: 10px;
  margin-bottom: 14px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
}

.is-locked .file-button {
  pointer-events: none;
}

.editor-actions,
.data-actions,
.form-header-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.editor-actions {
  margin-bottom: 14px;
}

.data-actions {
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

button,
.file-button {
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 14px;
  border-radius: 7px;
  font-weight: 850;
  line-height: 1.1;
  text-decoration: none;
}

.primary-button {
  border: 1px solid var(--accent);
  background: var(--accent);
  color: #111111;
}

.primary-button:hover,
.topbar-link:hover {
  background: #ff7d20;
  border-color: #ff7d20;
}

.secondary-button,
.file-button {
  border: 1px solid var(--line-strong);
  background: transparent;
  color: var(--ink);
}

.danger-button {
  border: 1px solid rgba(255, 107, 95, 0.5);
  background: rgba(255, 107, 95, 0.1);
  color: var(--red);
}

#importJsonInput {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.editor-status {
  min-height: 44px;
  margin: 14px 0 0;
  padding: 11px 12px;
  border-radius: var(--radius);
  background: rgba(255, 106, 0, 0.12);
  color: var(--accent);
  font-size: 0.9rem;
  font-weight: 760;
  line-height: 1.35;
}

.editor-status.is-danger {
  background: rgba(255, 107, 95, 0.12);
  color: var(--red);
}

.editor-form {
  padding: clamp(16px, 3vw, 24px);
}

.form-header {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: start;
  padding-bottom: 18px;
  margin-bottom: 18px;
  border-bottom: 1px solid var(--line);
}

.form-header h1 {
  margin: 0;
  color: var(--accent);
  font-size: clamp(1.6rem, 2.6vw, 2.55rem);
  line-height: 1.05;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 16px;
}

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

.site-footer {
  width: min(1480px, 100%);
  margin: 0 auto;
  padding: 0 clamp(14px, 3vw, 42px) 26px;
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.5;
}

.is-hidden {
  display: none !important;
}

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

  .library-panel,
  .editor-sidebar {
    position: static;
  }
}

@media (max-width: 760px) {
  .topbar {
    position: static;
    align-items: stretch;
    flex-direction: column;
  }

  .topbar-link {
    width: 100%;
  }

  .detail-grid,
  .form-grid,
  .form-grid.two-column,
  .dose-grid {
    grid-template-columns: 1fr;
  }

  .form-header {
    flex-direction: column;
  }

  .form-header-actions,
  .editor-actions,
  .data-actions {
    width: 100%;
  }

  .form-header-actions button,
  .editor-actions button,
  .data-actions button,
  .file-button {
    flex: 1 1 150px;
  }
}
