:root {
  font-family:
    Inter,
    ui-sans-serif,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    "PingFang SC",
    "Microsoft YaHei",
    sans-serif;
  color: #202526;
  background: #f5f6f3;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
  --ink: #202526;
  --muted: #707879;
  --line: #dde0dc;
  --line-strong: #c9ceca;
  --surface: #ffffff;
  --surface-soft: #f1f3f0;
  --accent: #277665;
  --accent-hover: #1e6254;
  --accent-soft: #e1eee9;
  --blue: #426e98;
  --blue-soft: #e5edf4;
  --amber: #8b6423;
  --amber-soft: #f4ead5;
  --red: #a34c46;
  --red-soft: #f6e7e4;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body {
  min-width: 320px;
  min-height: 100%;
  margin: 0;
}
body {
  background: #f5f6f3;
}
button,
input,
select,
textarea {
  font: inherit;
}
button {
  color: inherit;
}
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 2px solid #347ba0;
  outline-offset: 2px;
}

.app-shell {
  min-height: 100dvh;
  display: grid;
  grid-template-rows: 54px minmax(0, 1fr);
}
.topbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 18px;
  border-bottom: 1px solid var(--line-strong);
  background: rgba(255, 255, 255, 0.96);
  position: sticky;
  top: 0;
  z-index: 10;
}
.brand-mark {
  width: 31px;
  height: 31px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 2px;
  border-radius: 6px;
  color: #fff;
  background: #262d2e;
}
.brand-mark span {
  width: 2px;
  border-radius: 2px;
  background: currentColor;
}
.brand-mark span:nth-child(1),
.brand-mark span:nth-child(5) {
  height: 8px;
  opacity: 0.62;
}
.brand-mark span:nth-child(2),
.brand-mark span:nth-child(4) {
  height: 15px;
  opacity: 0.82;
}
.brand-mark span:nth-child(3) {
  height: 21px;
}
.brand-copy {
  display: flex;
  align-items: baseline;
  gap: 9px;
  min-width: 0;
}
.brand-copy strong {
  font-size: 13px;
}
.brand-copy span {
  color: #899091;
  font-size: 10px;
}
.topbar-spacer {
  flex: 1;
}
.connection-state {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 11px;
  white-space: nowrap;
}
.connection-state i {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #aeb4b2;
  box-shadow: 0 0 0 2px #e7e9e6;
}
.connection-state.is-connected i {
  background: #2c8968;
  box-shadow: 0 0 0 2px #d9ebe4;
}
.connection-state.is-loading i {
  animation: pulse 1s ease infinite;
}
@keyframes pulse {
  50% {
    opacity: 0.3;
  }
}

.workspace {
  width: min(1240px, 100%);
  margin: 0 auto;
  padding: 32px 30px 64px;
}
.page-heading {
  min-height: 66px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  border-bottom: 1px solid var(--line-strong);
}
.page-heading h1 {
  margin: 0;
  font-size: 23px;
  line-height: 1.25;
  letter-spacing: 0;
}
.page-heading p {
  margin: 7px 0 0;
  color: var(--muted);
  font-size: 11px;
}
.primary-button,
.secondary-button,
.text-button,
.icon-button {
  border-radius: 5px;
  cursor: pointer;
}
.primary-button {
  min-height: 34px;
  padding: 0 13px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 1px solid #216555;
  color: #fff;
  background: var(--accent);
  font-size: 12px;
  font-weight: 650;
}
.primary-button:hover:not(:disabled) {
  background: var(--accent-hover);
}
.primary-button:disabled {
  opacity: 0.5;
  cursor: wait;
}
.secondary-button {
  min-height: 34px;
  padding: 0 13px;
  border: 1px solid var(--line-strong);
  background: #fff;
  font-size: 12px;
}
.secondary-button:hover {
  background: var(--surface-soft);
}
.text-button {
  height: 29px;
  padding: 0 8px;
  border: 0;
  background: transparent;
  color: #606869;
  font-size: 11px;
}
.text-button:hover {
  background: var(--surface-soft);
}
.icon-button {
  width: 30px;
  height: 30px;
  display: inline-grid;
  place-items: center;
  padding: 0;
  border: 1px solid transparent;
  background: transparent;
  font-size: 19px;
  line-height: 1;
}
.icon-button:hover {
  border-color: var(--line);
  background: var(--surface-soft);
}
.full-width {
  width: 100%;
}

.toolbar {
  min-height: 66px;
  display: grid;
  grid-template-columns: minmax(240px, 1fr) auto 180px;
  align-items: center;
  gap: 18px;
  border-bottom: 1px solid var(--line);
}
.search-field,
.select-field {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 9px;
}
.search-field span,
.select-field span {
  color: #7a8282;
  font-size: 10px;
  text-transform: uppercase;
}
input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: 4px;
  color: var(--ink);
  background: #fff;
}
input,
select {
  height: 34px;
  padding: 0 10px;
}
textarea {
  padding: 9px 10px;
  resize: vertical;
  line-height: 1.5;
}
input::placeholder,
textarea::placeholder {
  color: #a1a7a5;
}
.search-field input {
  border: 0;
  background: transparent;
  padding-left: 0;
}
.segmented-control {
  display: inline-flex;
  padding: 2px;
  border-radius: 5px;
  background: #e9ece8;
}
.segmented-control button {
  min-width: 52px;
  height: 28px;
  padding: 0 9px;
  border: 0;
  border-radius: 3px;
  color: #687071;
  background: transparent;
  font-size: 11px;
  cursor: pointer;
}
.segmented-control button.is-active {
  color: #263031;
  background: #fff;
  box-shadow: 0 1px 2px rgba(24, 33, 31, 0.1);
  font-weight: 650;
}

.profile-table {
  background: rgba(255, 255, 255, 0.55);
}
.profile-table-head,
.profile-row {
  display: grid;
  grid-template-columns:
    minmax(250px, 1.2fr) 105px minmax(190px, 1fr)
    110px 90px 32px;
  gap: 16px;
  align-items: center;
}
.profile-table-head {
  min-height: 39px;
  padding: 0 13px;
  border-bottom: 1px solid var(--line);
  color: #858c8d;
  font-size: 9px;
  text-transform: uppercase;
}
.profile-row {
  min-height: 76px;
  padding: 10px 13px;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
}
.profile-row:hover {
  background: #fff;
}
.profile-identity {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 11px;
}
.voice-avatar {
  width: 34px;
  height: 34px;
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 2px;
  border-radius: 6px;
  color: #356c64;
  background: var(--accent-soft);
}
.voice-avatar i {
  width: 2px;
  border-radius: 2px;
  background: currentColor;
}
.voice-avatar i:nth-child(1),
.voice-avatar i:nth-child(5) {
  height: 7px;
}
.voice-avatar i:nth-child(2),
.voice-avatar i:nth-child(4) {
  height: 13px;
}
.voice-avatar i:nth-child(3) {
  height: 19px;
}
.profile-identity strong,
.profile-identity small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.profile-identity strong {
  font-size: 12px;
}
.profile-identity small {
  margin-top: 5px;
  color: #868d8e;
  font-size: 9px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}
.language-code {
  color: #596263;
  font-size: 11px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}
.tag-list {
  min-width: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}
.tag {
  max-width: 110px;
  padding: 3px 6px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  border-radius: 3px;
  color: #5f6869;
  background: #eceeeb;
  font-size: 9px;
}
.status-badge,
.reference-badge,
.default-badge {
  display: inline-flex;
  align-items: center;
  min-height: 21px;
  width: max-content;
  padding: 0 7px;
  border-radius: 3px;
  font-size: 9px;
  white-space: nowrap;
}
.status-badge.active {
  color: #23654f;
  background: #dfeee7;
}
.status-badge.disabled {
  color: var(--red);
  background: var(--red-soft);
}
.reference-badge.ready {
  color: var(--blue);
  background: var(--blue-soft);
}
.reference-badge.empty {
  color: #7d8384;
  background: #eceeeb;
}
.default-badge {
  margin-left: 6px;
  color: var(--amber);
  background: var(--amber-soft);
}
.row-open {
  color: #6e7677;
  font-size: 18px;
  text-align: center;
}
.empty-state {
  min-height: 220px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 7px;
  color: #838a8b;
  font-size: 11px;
}
.empty-state strong {
  color: #596162;
  font-size: 13px;
}

.login-backdrop,
.drawer-backdrop {
  position: fixed;
  inset: 0;
  z-index: 30;
  background: rgba(28, 34, 34, 0.38);
  backdrop-filter: blur(2px);
}
.login-backdrop {
  display: grid;
  place-items: center;
  padding: 18px;
}
.login-dialog {
  width: min(380px, 100%);
  padding: 28px;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  background: #fff;
  box-shadow: 0 18px 60px rgba(22, 30, 29, 0.18);
}
.login-brand {
  display: flex;
  justify-content: center;
}
.login-dialog h2 {
  margin: 16px 0 24px;
  text-align: center;
  font-size: 18px;
}
.login-dialog label {
  display: block;
  margin-bottom: 7px;
  color: #626a6b;
  font-size: 11px;
}
.login-dialog input {
  margin-bottom: 5px;
}
.form-error {
  min-height: 20px;
  margin: 5px 0 10px;
  color: var(--red);
  font-size: 10px;
  line-height: 1.45;
}

.drawer-backdrop {
  z-index: 20;
}
.profile-drawer {
  position: fixed;
  inset: 0 0 0 auto;
  z-index: 25;
  width: min(590px, 100%);
  background: #f9faf8;
  border-left: 1px solid var(--line-strong);
  box-shadow: -14px 0 44px rgba(24, 31, 30, 0.13);
  transform: translateX(102%);
  transition: transform 0.2s ease;
}
.profile-drawer.is-open {
  transform: translateX(0);
}
.profile-drawer form {
  height: 100%;
  display: grid;
  grid-template-rows: 66px minmax(0, 1fr) 64px;
}
.drawer-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 20px;
  border-bottom: 1px solid var(--line);
  background: #fff;
}
.drawer-header > div {
  min-width: 0;
  flex: 1;
}
.drawer-header span {
  display: block;
  margin-bottom: 3px;
  color: #8a9091;
  font-size: 9px;
  text-transform: uppercase;
}
.drawer-header h2 {
  margin: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 15px;
}
.drawer-body {
  overflow: auto;
  padding: 0 22px 28px;
}
.form-section {
  padding: 22px 0;
  border-bottom: 1px solid var(--line);
}
.form-section h3 {
  margin: 0 0 15px;
  font-size: 11px;
  text-transform: uppercase;
  color: #5e6768;
}
.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}
.form-grid .span-2 {
  grid-column: span 2;
}
.form-section label {
  display: grid;
  gap: 6px;
  color: #646c6d;
  font-size: 10px;
}
.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.section-heading span {
  color: #7a8283;
  font-size: 9px;
}
.reference-summary {
  margin-bottom: 12px;
  padding: 10px 11px;
  border-left: 3px solid var(--blue);
  color: #5d6769;
  background: var(--blue-soft);
  font-size: 10px;
  line-height: 1.55;
  overflow-wrap: anywhere;
  white-space: pre-line;
}
.file-drop {
  min-height: 76px;
  display: flex !important;
  flex-direction: column;
  gap: 5px;
  align-items: center;
  justify-content: center;
  text-align: center;
  border: 1px dashed #aeb6b3;
  border-radius: 5px;
  background: #fff;
  cursor: pointer;
}
.file-drop:hover {
  border-color: var(--accent);
  background: #f8fbfa;
}
.file-drop input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}
.file-drop strong {
  color: #365f58;
  font-size: 11px;
}
.file-drop span {
  color: #8a9191;
  font-size: 9px;
}
.settings-section {
  display: grid;
  gap: 1px;
}
.switch-row {
  min-height: 58px;
  display: flex !important;
  align-items: center;
  gap: 14px;
  cursor: pointer;
}
.switch-row > span {
  flex: 1;
}
.switch-row strong,
.switch-row small {
  display: block;
}
.switch-row strong {
  color: #343b3c;
  font-size: 11px;
}
.switch-row small {
  margin-top: 4px;
  color: #899091;
  font-size: 9px;
}
.switch-row input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}
.switch-row i {
  width: 34px;
  height: 19px;
  padding: 2px;
  border-radius: 10px;
  background: #bbc1bf;
  transition: background 0.15s ease;
}
.switch-row i::after {
  content: "";
  display: block;
  width: 15px;
  height: 15px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
  transition: transform 0.15s ease;
}
.switch-row input:checked + i {
  background: var(--accent);
}
.switch-row input:checked + i::after {
  transform: translateX(15px);
}
.save-error {
  margin: 15px 0 0;
}
.drawer-footer {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 20px;
  border-top: 1px solid var(--line-strong);
  background: #fff;
}
.drawer-footer > span {
  flex: 1;
  color: #8a9192;
  font-size: 9px;
}
.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  z-index: 50;
  max-width: min(420px, calc(100% - 32px));
  padding: 10px 13px;
  border-radius: 5px;
  color: #fff;
  background: #283132;
  box-shadow: 0 8px 28px rgba(25, 34, 33, 0.2);
  font-size: 11px;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 8px);
  transition:
    opacity 0.16s ease,
    transform 0.16s ease;
}
.toast.is-visible {
  opacity: 1;
  transform: translate(-50%, 0);
}
.toast.is-error {
  background: #873f3a;
}

@media (max-width: 800px) {
  .workspace {
    padding: 24px 16px 48px;
  }
  .toolbar {
    grid-template-columns: 1fr;
    gap: 10px;
    padding: 13px 0;
  }
  .segmented-control {
    width: 100%;
  }
  .segmented-control button {
    flex: 1;
  }
  .profile-table-head {
    display: none;
  }
  .profile-row {
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 10px;
    padding: 14px 10px;
  }
  .profile-row > :not(.profile-identity):not(.row-open) {
    display: none;
  }
  .page-heading {
    min-height: 62px;
  }
  .brand-copy span,
  .connection-state span {
    display: none;
  }
}

@media (max-width: 560px) {
  .topbar {
    padding: 0 10px;
  }
  .workspace {
    padding-inline: 12px;
  }
  .page-heading h1 {
    font-size: 19px;
  }
  .primary-button {
    padding-inline: 10px;
  }
  .profile-drawer form {
    grid-template-rows: 58px minmax(0, 1fr) 60px;
  }
  .drawer-body {
    padding-inline: 16px;
  }
  .drawer-header,
  .drawer-footer {
    padding-inline: 14px;
  }
  .form-grid {
    grid-template-columns: 1fr;
  }
  .form-grid .span-2 {
    grid-column: span 1;
  }
  .drawer-footer > span {
    display: none;
  }
  .drawer-footer .secondary-button,
  .drawer-footer .primary-button {
    flex: 1;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition: none !important;
    animation: none !important;
  }
}
