:root {
  color-scheme: light;
  --bg: #f6f3ee;
  --panel: #ffffff;
  --ink: #1f2933;
  --muted: #667085;
  --line: #ded8ce;
  --green: #2f7d67;
  --green-dark: #1f5f4d;
  --coral: #c65f46;
  --gold: #b5832f;
  --blue: #356f9f;
  --shadow: 0 14px 32px rgba(39, 45, 51, 0.08);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
}

body {
  min-height: 100%;
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

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

button {
  cursor: pointer;
}

.app-shell {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 22px 18px;
  background: #fbfaf7;
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.brand {
  min-height: 52px;
  display: flex;
  align-items: center;
  gap: 12px;
  color: inherit;
  text-decoration: none;
}

.brand-mark {
  width: 48px;
  height: 48px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--green);
  color: #fff;
  font-weight: 800;
}

.brand strong {
  display: block;
  font-size: 18px;
}

.brand small {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-top: 2px;
}

.search {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
}

.search input {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  background: var(--panel);
  color: var(--ink);
  outline: none;
}

.search input:focus,
.field input:focus,
.field select:focus,
.field textarea:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(47, 125, 103, 0.14);
}

.category-list,
.tabs {
  display: flex;
  gap: 8px;
}

.category-list {
  flex-direction: column;
  overflow: auto;
  padding-right: 2px;
}

.category-button,
.tab-button {
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--ink);
  min-height: 38px;
  padding: 0 12px;
  text-align: left;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.category-button:hover,
.tab-button:hover {
  background: #f0ebe2;
}

.category-button.active,
.tab-button.active {
  background: #e5f1ec;
  color: var(--green-dark);
  border-color: #b9d8cc;
  font-weight: 700;
}

.sidebar-note {
  margin-top: auto;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  color: var(--muted);
  background: var(--panel);
}

.sidebar-note span:first-child {
  color: var(--coral);
  font-weight: 800;
}

.workspace {
  min-width: 0;
  padding: 28px;
}

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

.eyebrow {
  margin: 0 0 6px;
  color: var(--green-dark);
  font-size: 13px;
  font-weight: 800;
}

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

h1 {
  margin-bottom: 0;
  font-size: 36px;
  line-height: 1.12;
}

.system-state {
  min-height: 36px;
  border-radius: 8px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  color: var(--muted);
  background: var(--panel);
  white-space: nowrap;
}

.system-state.ok {
  color: var(--green-dark);
  border-color: #b9d8cc;
  background: #edf7f2;
}

.tool-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(360px, 440px);
  gap: 22px;
  align-items: start;
}

.tool-column {
  min-width: 0;
}

.tabs {
  margin-bottom: 14px;
  overflow: auto;
  padding-bottom: 2px;
}

.tab-button {
  white-space: nowrap;
  background: var(--panel);
  border-color: var(--line);
}

.tool-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 12px;
}

.tool-card {
  min-height: 126px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 1px 0 rgba(39, 45, 51, 0.03);
  padding: 14px;
  text-align: left;
  display: grid;
  align-content: start;
  gap: 10px;
}

.tool-card:hover {
  border-color: #b9d8cc;
  box-shadow: var(--shadow);
}

.tool-card.active {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(47, 125, 103, 0.12);
}

.tool-card.planned {
  opacity: 0.58;
}

.tool-head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
}

.tool-title {
  margin: 0;
  font-size: 16px;
  line-height: 1.35;
}

.tag {
  flex: 0 0 auto;
  min-height: 24px;
  border-radius: 6px;
  padding: 3px 8px;
  display: inline-flex;
  align-items: center;
  font-size: 12px;
  color: #fff;
  background: var(--blue);
}

.tag.server {
  background: var(--green);
}

.tag.client {
  background: var(--gold);
}

.tag.planned {
  background: #8a8f98;
}

.tool-desc {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
  margin-bottom: 0;
}

.runner {
  position: sticky;
  top: 20px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
  min-height: 420px;
  padding: 18px;
}

.runner h2 {
  font-size: 22px;
  margin-bottom: 6px;
}

.runner-meta {
  color: var(--muted);
  margin-bottom: 18px;
  line-height: 1.5;
}

.empty-state {
  min-height: 360px;
  display: grid;
  place-items: center;
  align-content: center;
  text-align: center;
  gap: 8px;
  color: var(--muted);
}

.empty-state h2 {
  color: var(--ink);
  margin-bottom: 0;
}

.empty-icon {
  width: 48px;
  height: 48px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #edf7f2;
  color: var(--green-dark);
  font-weight: 900;
  font-size: 28px;
}

.tool-form {
  display: grid;
  gap: 14px;
}

.dropzone {
  position: relative;
  min-height: 116px;
  border: 1px dashed #b7aa97;
  border-radius: 8px;
  background: #fffdf9;
  display: grid;
  place-items: center;
  text-align: center;
  padding: 18px;
}

.dropzone:hover {
  border-color: var(--green);
}

.dropzone input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.dropzone strong {
  display: block;
}

.file-hint {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
  word-break: break-all;
}

.field-grid {
  display: grid;
  gap: 12px;
}

.field {
  display: grid;
  gap: 7px;
}

.field label {
  font-size: 13px;
  color: var(--muted);
  font-weight: 700;
}

.field input,
.field select,
.field textarea {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  outline: none;
  background: #fff;
  color: var(--ink);
}

.field textarea,
.client-textarea,
.client-output {
  min-height: 160px;
  resize: vertical;
}

.primary-button,
.secondary-button {
  min-height: 42px;
  border-radius: 8px;
  border: 1px solid transparent;
  padding: 0 14px;
  font-weight: 800;
}

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

.primary-button:hover {
  background: var(--green-dark);
}

.secondary-button {
  background: #fff;
  border-color: var(--line);
  color: var(--ink);
}

.secondary-button:hover {
  border-color: #b9d8cc;
}

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

.result-box {
  margin-top: 14px;
  border-radius: 8px;
  border: 1px solid var(--line);
  padding: 12px;
  color: var(--muted);
  background: #fbfaf7;
  word-break: break-word;
}

.result-box.good {
  color: var(--green-dark);
  background: #edf7f2;
  border-color: #b9d8cc;
}

.result-box.bad {
  color: #9b3424;
  background: #fff2ee;
  border-color: #edc7bd;
}

.download-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  margin-top: 8px;
  padding: 0 12px;
  border-radius: 8px;
  background: var(--green);
  color: #fff;
  text-decoration: none;
  font-weight: 800;
}

.client-panel {
  display: grid;
  gap: 12px;
}

.client-output {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: #fbfaf7;
  color: var(--ink);
  white-space: pre-wrap;
  overflow: auto;
}

.client-textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: #fff;
  color: var(--ink);
  outline: none;
}

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

  .sidebar {
    position: relative;
    height: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .category-list {
    flex-direction: row;
  }

  .category-button {
    white-space: nowrap;
  }

  .tool-layout {
    grid-template-columns: 1fr;
  }

  .runner {
    position: relative;
    top: 0;
  }
}

@media (max-width: 640px) {
  .workspace {
    padding: 18px;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  h1 {
    font-size: 30px;
  }

  .tool-grid {
    grid-template-columns: 1fr;
  }

  .sidebar {
    padding: 18px;
  }
}
