:root {
  color-scheme: light;
  font-family: Inter, "Segoe UI", "Microsoft YaHei", sans-serif;
  color: #1f2937;
  background: #f4f7fb;
  --primary: #155eef;
  --primary-dark: #0f47b8;
  --border: #d8e0ec;
  --muted: #64748b;
  --danger: #b42318;
  --surface: #ffffff;
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; }
button, input, textarea, select { font: inherit; }
button, .button {
  border: 0;
  border-radius: 8px;
  padding: 10px 16px;
  background: var(--primary);
  color: white;
  cursor: pointer;
  text-decoration: none;
  font-weight: 600;
}
button:hover, .button:hover { background: var(--primary-dark); }
button.secondary, .button.secondary {
  color: #24324a;
  background: #edf2f8;
  border: 1px solid var(--border);
}
button.secondary:hover, .button.secondary:hover { background: #dfe8f3; }
button.danger { background: #fee4e2; color: var(--danger); }
button.small { padding: 7px 10px; font-size: 13px; }
button:disabled { opacity: .5; cursor: not-allowed; }
button:focus-visible, .field-card:focus-visible { outline: 2px solid var(--primary); outline-offset: 3px; }
.hidden, [hidden] { display: none !important; }

.app-shell { min-width: 0; }
.navigation-bar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 14px;
  min-height: 54px;
  padding: 10px 24px;
  background: #f4f7fb;
  border-bottom: 1px solid var(--border);
}
#current-panel-name { color: var(--muted); font-size: 13px; }
.quick-sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 40;
  width: 232px;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border-right: 1px solid var(--border);
}
.sidebar-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 18px 16px; border-bottom: 1px solid var(--border); }
.sidebar-header h2 { margin: 0; font-size: 17px; }
.sidebar-scroll { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 14px 12px; }
.sidebar-menu, .sidebar-positions { display: grid; gap: 4px; }
.sidebar-menu a, .sidebar-positions a {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 8px;
  color: #344054;
  text-decoration: none;
  overflow-wrap: anywhere;
}
.sidebar-menu a:hover, .sidebar-positions a:hover { background: #f0f5fd; }
.sidebar-menu a[aria-current="page"], .sidebar-positions a[aria-current="location"] { color: var(--primary); background: #ecf4ff; font-weight: 600; }
.sidebar-menu a:focus-visible, .sidebar-positions a:focus-visible { outline: 2px solid var(--primary); outline-offset: -2px; }
.sidebar-section { margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--border); }
.sidebar-section h3 { margin: 0 12px 8px; font-size: 12px; color: var(--muted); }
.sidebar-section-header { display: flex; justify-content: space-between; align-items: center; gap: 6px; margin: 0 4px 8px 12px; }
.sidebar-section-header h3 { margin: 0; }
.sidebar-section-header button { padding: 5px 7px; font-size: 12px; }
.sidebar-order-hint { margin: 0 12px 10px; font-size: 12px; line-height: 1.6; color: var(--muted); }
.sidebar-positions a { font-size: 13px; padding: 8px 12px; }
.sidebar-positions .badge { flex: 0 0 auto; }
.category-position { min-width: 0; border-radius: 8px; }
.category-position a { min-width: 0; }
.category-position.sortable { display: grid; grid-template-columns: 20px minmax(0, 1fr) auto; align-items: center; gap: 2px; }
.category-position.sortable a { padding: 8px 4px; gap: 4px; }
.category-position button { background: transparent; color: var(--muted); padding: 4px; border-radius: 5px; font-size: 15px; line-height: 1.2; }
.category-position button:hover { color: var(--primary); background: #ecf4ff; }
.category-position button:disabled { opacity: .3; }
.category-move-buttons { display: flex; }
.category-move-buttons button { width: 22px; min-height: 28px; }
.category-drag-handle { cursor: grab; touch-action: pan-y; }
.category-drag-handle:active { cursor: grabbing; }
.category-position.dragging { opacity: .45; }
.category-position.drop-before { box-shadow: 0 -2px 0 var(--primary); }
.category-position.drop-after { box-shadow: 0 2px 0 var(--primary); }
.sidebar-empty { margin: 12px; color: var(--muted); font-size: 13px; line-height: 1.6; }
.sidebar-footer { padding: 12px; border-top: 1px solid var(--border); font-size: 13px; }
.sidebar-backdrop { position: fixed; inset: 0; z-index: 30; background: rgba(15, 23, 42, .4); border-radius: 0; padding: 0; }
.sidebar-backdrop:hover { background: rgba(15, 23, 42, .4); }
[tabindex="-1"] { scroll-margin-top: 76px; }

@media (min-width: 1001px) {
  body.sidebar-open .app-shell { margin-left: 232px; }
}

@media (max-width: 1000px) {
  body.sidebar-open { overflow: hidden; }
  .quick-sidebar { width: min(280px, calc(100vw - 40px)); box-shadow: 8px 0 30px rgba(15, 23, 42, .16); }
  .navigation-bar { padding: 10px 16px; }
}

.app-header {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  padding: 28px max(32px, calc((100vw - 1320px) / 2));
  color: white;
  background: linear-gradient(120deg, #0f3f8f, #1769e0);
}
.app-header h1 { margin: 2px 0 6px; font-size: 30px; }
.app-header p { margin: 0; opacity: .9; }
.eyebrow { text-transform: uppercase; letter-spacing: .12em; font-size: 12px; }
.header-actions { display: flex; align-items: center; gap: 10px; }
.app-header > div { min-width: 0; }

main { max-width: 1320px; margin: 0 auto; padding: 24px 32px 50px; }
.connection-card {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 20px;
  padding: 18px 20px;
  background: #ecf4ff;
  border: 1px solid #b8d4ff;
  border-radius: 12px;
}
.connection-card span { margin-left: 18px; color: var(--muted); }
.token-row { display: flex; gap: 8px; }
.token-row input { width: 320px; }
.connection-card.server-mode { flex-wrap: wrap; }
#server-controls { flex: 1 0 100%; min-width: 0; }
#server-controls label { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-bottom: 12px; }
#device-name { width: min(300px, 100%); }
#device-list p { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
#device-list span { margin: 0; overflow-wrap: anywhere; }

.tabs { display: flex; gap: 6px; margin-top: 24px; border-bottom: 1px solid var(--border); }
.tab { background: transparent; color: var(--muted); border-radius: 8px 8px 0 0; }
.tab:hover { background: #e8eef7; }
.tab.active { color: var(--primary); background: white; border: 1px solid var(--border); border-bottom-color: white; margin-bottom: -1px; }
.panel { display: none; background: var(--surface); border: 1px solid var(--border); border-top: 0; padding: 22px; min-height: 400px; }
.panel.active { display: block; }

.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 14px; margin-bottom: 20px; }
.toolbar input[type="search"] { min-width: 320px; }
.toolbar span { margin-left: auto; color: var(--muted); }
#fields-panel .toolbar { flex-wrap: wrap; }
#fields-panel .toolbar input[type="search"] { flex: 1 1 280px; min-width: 240px; }
#fields-panel .toolbar select { flex: 0 1 240px; width: auto; min-width: 180px; }
#fields-panel .toolbar label { flex: 0 0 auto; white-space: nowrap; }
#fields-panel .toolbar span { flex: 0 0 auto; white-space: nowrap; }
input, textarea, select {
  width: 100%;
  padding: 9px 11px;
  border: 1px solid #c8d2e1;
  border-radius: 7px;
  background: white;
  color: #182230;
}
input:focus, textarea:focus, select:focus { outline: 2px solid #9cc1ff; border-color: var(--primary); }

.field-group { margin-bottom: 22px; }
.field-group h2 { font-size: 18px; margin: 0 0 10px; }
.field-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.field-card {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px 12px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  cursor: pointer;
}
.field-card:hover { border-color: #8eb7f5; box-shadow: 0 2px 10px rgba(31, 65, 120, .08); }
.field-label { font-weight: 650; }
.field-key { color: var(--muted); font: 12px Consolas, monospace; overflow-wrap: anywhere; }
.field-card > div { min-width: 0; }
.load-status { display: flex; align-items: center; gap: 12px; padding: 12px; margin-bottom: 16px; background: #ecf4ff; border-radius: 8px; }
.load-error { background: #fff1f0; color: var(--danger); }
.empty-state { padding: 32px 16px; text-align: center; color: var(--muted); }
.field-value { grid-column: 1 / -1; white-space: pre-wrap; overflow-wrap: anywhere; color: #344054; }
.field-content { grid-column: 1 / -1; display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 10px; align-items: start; }
.field-content .field-value { grid-column: auto; min-width: 0; }
.copy-field { white-space: nowrap; min-width: 56px; }
.copy-field:disabled { opacity: .45; cursor: not-allowed; }
.field-value.empty { color: #98a2b3; font-style: italic; }
.badges { display: flex; gap: 5px; align-items: start; }
.badge { padding: 3px 7px; border-radius: 999px; background: #eef2f7; color: #475467; font-size: 11px; }
.badge.sensitive { color: #9a3412; background: #ffedd5; }
.badge.confirm { color: #7c2d12; background: #fef3c7; }

.table-wrap { overflow: auto; }
.source-html { max-height: 420px; overflow: auto; white-space: pre-wrap; overflow-wrap: anywhere; background: #f8fafc; padding: 12px; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 11px 10px; border-bottom: 1px solid var(--border); text-align: left; }
th { color: var(--muted); font-size: 13px; }
.prose { line-height: 1.75; }
.prose code { padding: 2px 5px; background: #edf2f7; border-radius: 4px; }

dialog {
  width: min(760px, calc(100vw - 40px));
  max-height: calc(100vh - 40px);
  border: 0;
  border-radius: 14px;
  padding: 0;
  box-shadow: 0 24px 80px rgba(15, 23, 42, .28);
}
dialog::backdrop { background: rgba(15, 23, 42, .45); }
#field-form, #attachment-form { padding: 24px; overflow: auto; max-height: calc(100vh - 40px); }
.dialog-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 18px; }
.dialog-header h2 { margin: 0; }
.icon-button { padding: 4px 10px; background: transparent; color: #475467; font-size: 25px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-grid label { display: grid; gap: 6px; font-weight: 600; font-size: 13px; }
.form-grid .full { grid-column: 1 / -1; }
.checks { display: flex; gap: 24px; margin: 16px 0; }
.checks label, .toolbar label { display: flex; align-items: center; gap: 7px; }
.checks input, .toolbar input[type="checkbox"] { width: auto; }
.dialog-actions { display: flex; gap: 10px; align-items: center; }
.spacer { flex: 1; }
.error { min-height: 24px; color: var(--danger); }

#toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  transform: translateY(20px);
  opacity: 0;
  padding: 12px 18px;
  color: white;
  background: #182230;
  border-radius: 9px;
  pointer-events: none;
  transition: .2s ease;
}
#toast.show { transform: translateY(0); opacity: 1; }

.variants-header { display: flex; justify-content: space-between; align-items: center; font-weight: 600; font-size: 13px; }
.hint { margin: 6px 0 8px; color: var(--muted); font-size: 12px; }
.variant-row {
  display: grid;
  grid-template-columns: 180px 1fr auto;
  gap: 8px;
  align-items: start;
  margin-bottom: 8px;
}
.row-actions { white-space: nowrap; }
.row-actions button { margin-right: 4px; }
.checks-inline { display: flex; align-items: center; gap: 7px; font-weight: 600; font-size: 13px; }
.checks-inline input { width: auto; }

@media (max-width: 1050px) {
  .field-list { grid-template-columns: 1fr; }
  .connection-card { flex-wrap: wrap; }
  .header-actions { flex-wrap: wrap; }
}

@media (min-width: 1001px) and (max-width: 1280px) {
  .sidebar-open .app-header { flex-wrap: wrap; }
  .sidebar-open .field-list { grid-template-columns: 1fr; }
}

@media (max-width: 700px) {
  .app-header { flex-direction: column; padding: 22px 16px; gap: 18px; }
  .app-header h1 { font-size: 25px; }
  main { padding: 16px 12px 32px; }
  .connection-card { padding: 14px; }
  .connection-card span { display: block; margin: 8px 0 0; overflow-wrap: anywhere; }
  .token-row { flex-wrap: wrap; width: 100%; }
  .token-row input { width: 100%; min-width: 0; }
  .tabs { flex-wrap: wrap; gap: 4px; }
  .tab { padding: 10px; font-size: 13px; }
  .panel { padding: 16px 12px; min-width: 0; }
  .toolbar input[type="search"], #fields-panel .toolbar input[type="search"] { min-width: 0; width: 100%; flex-basis: 100%; }
  #fields-panel .toolbar select { min-width: 0; flex: 1 1 140px; }
  .toolbar span { margin-left: 0; }
  .form-grid, .variant-row { grid-template-columns: minmax(0, 1fr); }
  .form-grid .full { grid-column: auto; }
  #field-form, #attachment-form { padding: 18px; }
  .dialog-actions { flex-wrap: wrap; }
  .load-status { flex-wrap: wrap; }
  .load-status span, .prose, .field-label { overflow-wrap: anywhere; }
  #toast { left: 16px; right: 16px; bottom: 16px; }
}
:root { --resume-accent: #155eef; }
.resume-current { display:flex; flex-wrap:wrap; gap:12px; align-items:center; justify-content:space-between; padding:14px 18px; margin:12px 0 20px; border:1px solid #cdddf8; border-radius:12px; background:#f0f5ff; color:#183d74; }
.editing-scheme-label { display:flex; flex-wrap:wrap; align-items:center; gap:8px; min-width:0; max-width:100%; margin:0; }
#editing-scheme { width:min(280px,100%); min-width:0; max-width:100%; }
#scheme-base-fields label { display:block; margin-bottom:12px; }
.schemes-list { display:grid; gap:18px; }
.scheme-card { padding:22px; border:1px solid #d6dfec; border-radius:14px; background:#fff; min-width:0; }
.scheme-card-heading { display:flex; gap:12px; flex-wrap:wrap; align-items:center; }
.scheme-card-heading h2 { margin:0; font-size:21px; overflow-wrap:anywhere; }
.scheme-card p,.scheme-history p { overflow-wrap:anywhere; }
.scheme-actions { display:flex; flex-wrap:wrap; gap:8px; margin:12px 0; }
.scheme-file-detail { padding:12px; border:1px solid #dde4ef; border-radius:8px; margin:10px 0; }
.scheme-history { margin-top:20px; padding-top:10px; border-top:1px solid #dde4ef; }
.scheme-editor-dialog { width:min(1000px,calc(100vw - 32px)); max-width:1000px; }
#scheme-editor-dialog,#scheme-create-dialog,#scheme-file-dialog { overflow:hidden; }
#scheme-editor-form,#scheme-create-form,#scheme-file-form { padding:24px; min-width:0; max-height:calc(100dvh - 40px); overflow:auto; }
.scheme-project .form-grid { grid-template-columns:minmax(0,1fr) minmax(0,1fr); }
.scheme-project .form-grid label { min-width:0; }
.scheme-project input,.scheme-project textarea,.scheme-project select { min-width:0; max-width:100%; }
html:has(#scheme-editor-dialog[open],#scheme-create-dialog[open],#scheme-file-dialog[open]) { overflow:hidden; }
.scheme-project { margin:18px 0; padding:16px; border:1px solid #d0dbea; border-radius:10px; min-width:0; }
.scheme-project legend { font-size:17px; font-weight:600; color:#234c85; }
.scheme-project textarea { resize:vertical; }
.scheme-project details { margin:8px 0; }
.scheme-project summary { cursor:pointer; color:#285aa2; padding:7px 0; }
.scheme-meta label { display:block; margin:9px 0; }
.scheme-meta textarea { width:100%; font-family:inherit; }
.scheme-diff { max-height:360px; overflow:auto; }
.scheme-diff>div { padding:12px 0; border-bottom:1px solid #dce4f0; }
.scheme-diff p { white-space:pre-wrap; overflow-wrap:anywhere; }
#scheme-import-info pre { max-height:300px; overflow:auto; white-space:pre-wrap; overflow-wrap:anywhere; }
#scheme-create-dialog label,#scheme-file-dialog label { display:block; margin:16px 0; }
#scheme-create-dialog input,#scheme-file-dialog input:not([type=checkbox]),#scheme-edit-name { width:100%; }
.scheme-check { display:flex!important; gap:8px; align-items:center; }
#scheme-editor-dialog .dialog-actions,#scheme-create-dialog .dialog-actions,#scheme-file-dialog .dialog-actions { display:flex; flex-wrap:wrap; justify-content:flex-end; gap:10px; margin-top:20px; padding-top:16px; border-top:1px solid #dde4ef; }
.form-error { color:#b42318; white-space:pre-wrap; overflow-wrap:anywhere; }
@media(max-width:600px) { .scheme-card { padding:14px; } .scheme-project { padding:10px; } .scheme-actions button { flex:1 1 130px; } .scheme-editor-dialog { width:calc(100vw - 16px); max-width:calc(100vw - 16px); } #scheme-editor-form,#scheme-create-form,#scheme-file-form { padding:14px; } .scheme-project .form-grid { grid-template-columns:minmax(0,1fr); } .tabs { overflow-x:auto; } }
