* {
	margin: 0;
	padding: 0;
	box-sizing: border-box;
}

:root {
	--bg:           #111111;
	--surface:      #1a1a1a;
	--surface-2:    #222222;
	--border:       #333333;
	--text:         #f5f5f5;
	--muted:        #999999;
	--faint:        #555555;
	--brand:        #e8541a;
	--brand-soft:   #f16436;
	--danger:       #cc3344;
}

body {
	background:      var(--bg);
	color:           var(--text);
	font-family:     'Segoe UI', Arial, sans-serif;
	font-size:       14px;
	height:          100vh;
	overflow:        hidden;
}

#dashboardScreen {
	height:         100%;
	display:        flex;
	flex-direction: column;
}

.hidden {
	display: none !important;
}

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

.warn {
	color:      var(--danger);
	font-weight: 600;
}

code {
	font-family: 'JetBrains Mono', Menlo, Consolas, monospace;
	font-size:   0.9em;
}

/* ---- Login screen ---- */

#loginScreen {
	display:         flex;
	align-items:     center;
	justify-content: center;
	min-height:      100vh;
	padding:         24px;
}

.card {
	background:    var(--surface);
	border:        1px solid var(--border);
	border-radius: 16px;
	padding:       clamp(28px, 6vw, 44px);
	width:         min(360px, 100%);
	text-align:    center;
}

.card h1 {
	font-size:     clamp(1.3rem, 4vw, 1.6rem);
	font-weight:   700;
	margin-bottom: 12px;
}

.card p {
	color:       var(--muted);
	line-height: 1.6;
}

.login-link {
	display:         inline-block;
	background:      var(--brand);
	color:           #ffffff;
	padding:         10px 18px;
	border-radius:   8px;
	text-decoration: none;
	margin-top:      16px;
	font-weight:     600;
}

.login-link:hover {
	background: var(--brand-soft);
}

/* ---- Dashboard chrome ---- */

.topbar {
	display:         flex;
	align-items:     center;
	gap:             24px;
	padding:         10px 20px;
	background:      var(--surface);
	border-bottom:   1px solid var(--border);
}

.brand {
	font-weight:   700;
	font-size:     0.95rem;
	letter-spacing: 0.02em;
}

.topnav {
	display: flex;
	gap:     4px;
	flex:    1;
}

.topnav .nav-item {
	padding:         8px 14px;
	border-radius:   6px;
	color:           var(--muted);
	text-decoration: none;
	cursor:          pointer;
	font-size:       0.9rem;
}

.topnav .nav-item:hover {
	color:      var(--text);
	background: var(--surface-2);
}

.topnav .nav-item.active {
	color:      var(--brand-soft);
	background: var(--surface-2);
}

.topbar-right {
	display:     flex;
	gap:         10px;
	align-items: center;
}

.repo-link {
	font-family:     'JetBrains Mono', Menlo, Consolas, monospace;
	font-size:       0.8rem;
	padding:         6px 12px;
	border-radius:   6px;
	background:      var(--surface-2);
	border:          1px solid var(--border);
	color:           var(--text);
	text-decoration: none;
	transition:      border-color 0.15s ease, color 0.15s ease;
}

.repo-link:hover {
	border-color: var(--brand);
	color:        var(--brand-soft);
}

.admin-badge {
	font-size:      0.7rem;
	text-transform: uppercase;
	letter-spacing: 0.06em;
	padding:        3px 9px;
	border-radius:  10px;
	background:     transparent;
	border:         1px solid var(--brand);
	color:          var(--brand-soft);
	font-weight:    600;
}

/* ---- Feature shell ---- */

.feature {
	flex:           1;
	min-height:     0;
	display:        flex;
	flex-direction: column;
}

.feature-toolbar {
	display:         flex;
	align-items:     center;
	justify-content: space-between;
	padding:         12px 20px;
	background:      var(--surface);
	border-bottom:   1px solid var(--border);
}

.feature-title {
	font-size:   0.95rem;
	font-weight: 600;
	color:       var(--muted);
}

.feature-toolbar-left {
	display:     flex;
	align-items: center;
	gap:         12px;
}

.feature-toolbar-actions {
	display:     flex;
	align-items: center;
	gap:         8px;
}

.editor-main {
	display:    grid;
	grid-template-columns: 320px 1fr;
	flex:       1;
	min-height: 0;
	overflow:   hidden;
}

.sidebar {
	background:    var(--surface);
	border-right:  1px solid var(--border);
	overflow:      auto;
	padding:       16px;
}

.sidebar-section {
	margin-bottom: 24px;
}

.section-header {
	font-size:        0.75rem;
	text-transform:   uppercase;
	letter-spacing:   0.06em;
	color:            var(--muted);
	margin-bottom:    8px;
	display:          flex;
	align-items:      center;
	justify-content:  space-between;
	gap:              8px;
}

.section-action {
	font-size:     0.7rem;
	padding:       3px 8px;
	border-radius: 4px;
	background:    transparent;
	border:        1px solid var(--border);
	color:         var(--muted);
	cursor:        pointer;
	letter-spacing: 0;
	text-transform: none;
}

.section-action:hover {
	border-color: var(--brand);
	color:        var(--brand-soft);
}

.path-preview {
	display:       block;
	padding:       8px 10px;
	background:    var(--surface-2);
	border:        1px solid var(--border);
	border-radius: 6px;
	color:         var(--text);
	font-size:     0.85rem;
	word-break:    break-all;
}

#fileFilter {
	width:         100%;
	background:    var(--surface-2);
	border:        1px solid var(--border);
	border-radius: 6px;
	color:         var(--text);
	padding:       8px 10px;
	margin-bottom: 8px;
	font-family:   inherit;
	font-size:     inherit;
}

#fileFilter:focus {
	outline:      none;
	border-color: var(--brand);
}

.file-tree, .staged-list {
	list-style: none;
}

.file-tree li, .staged-list li {
	display:       flex;
	align-items:   center;
	justify-content: space-between;
	padding:       6px 8px;
	border-radius: 4px;
	cursor:        pointer;
	line-height:   1.4;
	font-family:   'JetBrains Mono', Menlo, Consolas, monospace;
	font-size:     0.85rem;
	color:         var(--text);
}

.file-tree li:hover, .staged-list li:hover {
	background: var(--surface-2);
}

.file-tree li.disabled {
	color:  var(--faint);
	cursor: not-allowed;
}

.file-tree li.active,
.staged-list li.active {
	background: var(--surface-2);
	color:      var(--brand-soft);
}

.staged-list li.active span:first-child {
	color: var(--brand-soft);
}

.file-tree li.file-tree-group {
	font-family:     'Segoe UI', Arial, sans-serif;
	font-size:       0.7rem;
	text-transform:  uppercase;
	letter-spacing:  0.08em;
	color:           var(--muted);
	cursor:          default;
	padding:         12px 8px 4px;
	border-bottom:   1px solid var(--border);
	margin-bottom:   4px;
}

.file-tree li.file-tree-group:hover {
	background: transparent;
}

.file-tree li.file-tree-group:first-child {
	padding-top: 4px;
}

.file-tree li.file-tree-scope {
	font-family:    'Segoe UI', Arial, sans-serif;
	font-size:      0.72rem;
	color:          var(--muted);
	cursor:          default;
	padding:        6px 8px 2px 16px;
	text-transform: uppercase;
	letter-spacing: 0.05em;
}

.file-tree li.file-tree-scope:hover {
	background: transparent;
}

.file-tree li.file-tree-category {
	font-family: 'Segoe UI', Arial, sans-serif;
	font-size:   0.8rem;
	color:       var(--faint);
	cursor:      default;
	padding:     4px 8px 2px 28px;
	font-style:  italic;
}

.file-tree li.file-tree-category:hover {
	background: transparent;
}

.file-tree li.file-tree-leaf {
	padding-left: 40px;
}

.file-tree li.file-tree-leaf-shallow {
	padding-left: 28px;
}

.staged-list li.staged-delete span:first-child {
	color: var(--danger);
	text-decoration: line-through;
}

.field-hint {
	font-size:   0.75rem;
	color:       var(--faint);
	margin-top:  4px;
	font-style:  italic;
}

.char-counter {
	font-size:   0.75rem;
	color:       var(--muted);
	margin-top:  4px;
}

.char-counter.over {
	color:       var(--danger);
	font-weight: 600;
}

.staged-list li > span {
	overflow:      hidden;
	text-overflow: ellipsis;
	white-space:   nowrap;
	min-width:     0;
}

.staged-list li .remove-staged {
	color:           var(--muted);
	background:      transparent;
	border:          none;
	cursor:          pointer;
	padding:         0 4px;
	font-size:       1rem;
	flex-shrink:     0;
}

.staged-list li .remove-staged:hover {
	color: var(--danger);
}

/* ---- Editor pane ---- */

.editor-pane {
	overflow: auto;
	padding:  24px;
}

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

.file-header {
	display:       flex;
	align-items:   center;
	gap:           12px;
	margin-bottom: 16px;
}

.file-header code {
	background:    var(--surface);
	padding:       6px 10px;
	border-radius: 4px;
	border:        1px solid var(--border);
}

.tier-pill {
	font-size:     0.7rem;
	text-transform: uppercase;
	letter-spacing: 0.06em;
	padding:       3px 8px;
	border-radius: 10px;
	background:    var(--surface-2);
	color:         var(--muted);
	border:        1px solid var(--border);
}

.tier-pill.admin {
	border-color: var(--brand);
	color:        var(--brand-soft);
}

.tier-pill.staged {
	border-color: #4a8;
	color:        #6c9;
}

#rawTextarea {
	width:         100%;
	min-height:    400px;
	background:    var(--surface);
	border:        1px solid var(--border);
	border-radius: 8px;
	color:         var(--text);
	padding:       16px;
	font-family:   'JetBrains Mono', Menlo, Consolas, monospace;
	font-size:     0.85rem;
	line-height:   1.6;
	resize:        vertical;
	tab-size:      4;
}

#rawTextarea:focus {
	outline:      none;
	border-color: var(--brand);
}

#structuredForm .field {
	display:       block;
	margin-bottom: 16px;
}

#structuredForm label {
	display:       block;
	font-size:     0.8rem;
	color:         var(--muted);
	margin-bottom: 4px;
	text-transform: uppercase;
	letter-spacing: 0.05em;
}

#structuredForm input[type="text"],
#structuredForm textarea {
	width:         100%;
	background:    var(--surface);
	border:        1px solid var(--border);
	border-radius: 6px;
	color:         var(--text);
	padding:       10px 12px;
	font-family:   inherit;
	font-size:     inherit;
}

#structuredForm input[type="text"]:focus,
#structuredForm textarea:focus {
	outline:      none;
	border-color: var(--brand);
}

#structuredForm textarea {
	min-height:  240px;
	font-family: 'JetBrains Mono', Menlo, Consolas, monospace;
	font-size:   0.85rem;
	line-height: 1.6;
	resize:      vertical;
}

#structuredForm .field-row {
	display:     flex;
	align-items: center;
	gap:         10px;
}

#structuredForm .checkbox-field {
	display:     flex;
	align-items: center;
	gap:         8px;
	padding:     8px 0;
}

#structuredForm .remove-field {
	background:    transparent;
	border:        none;
	color:         var(--faint);
	cursor:        pointer;
	font-size:     1.1rem;
	padding:       0 4px;
}

#structuredForm .remove-field:hover {
	color: var(--danger);
}

.add-field-row {
	margin-top:    8px;
	margin-bottom: 16px;
}

#structuredForm select {
	background:    var(--surface);
	border:        1px solid var(--border);
	border-radius: 6px;
	color:         var(--text);
	padding:       8px 12px;
	font-family:   inherit;
	font-size:     inherit;
}

.editor-actions {
	display: flex;
	gap:     8px;
	margin-top: 16px;
}

/* ---- Inline simulate panel ---- */

.simulate-panel {
	margin-top:     12px;
	padding:        14px 16px;
	background:     var(--surface);
	border:         1px solid var(--border);
	border-radius:  8px;
	display:        flex;
	flex-direction: column;
	gap:            10px;
}

.simulate-panel-label {
	font-size:      0.7rem;
	font-weight:    600;
	letter-spacing: 0.06em;
	text-transform: uppercase;
	color:          var(--muted);
}

.file-field {
	display:     flex;
	align-items: center;
	gap:         10px;
	min-width:   0;
}

.file-field-input {
	position:       absolute;
	width:          1px;
	height:         1px;
	opacity:        0;
	pointer-events: none;
}

.file-field-button {
	flex-shrink:   0;
	font-size:     0.85rem;
	font-weight:   600;
	padding:       8px 14px;
	border-radius: 8px;
	border:        1px solid var(--border);
	background:    var(--surface-2);
	color:         var(--text);
	cursor:        pointer;
	transition:    border-color 0.15s ease, color 0.15s ease;
}

.file-field-button:hover {
	border-color: var(--brand);
	color:        var(--brand-soft);
}

.file-field-name {
	color:         var(--muted);
	font-size:     0.82rem;
	overflow:      hidden;
	text-overflow: ellipsis;
	white-space:   nowrap;
	min-width:     0;
}

.simulate-sample {
	width:         100%;
	min-height:    90px;
	background:    var(--bg);
	border:        1px solid var(--border);
	border-radius: 8px;
	color:         var(--text);
	padding:       10px 12px;
	font-family:   'JetBrains Mono', Menlo, Consolas, monospace;
	font-size:     0.85rem;
	line-height:   1.5;
	resize:        vertical;
}

.simulate-sample:focus {
	outline:      none;
	border-color: var(--brand);
}

/* ---- Pull Requests ---- */

.pr-edit-banner {
	display:         flex;
	align-items:     center;
	justify-content: space-between;
	gap:             12px;
	margin-top:      12px;
	padding:         10px 14px;
	background:      var(--surface-2);
	border:          1px solid var(--brand);
	border-radius:   8px;
	color:           var(--text);
	font-size:       0.85rem;
}

.pulls-pane {
	overflow: auto;
	padding:  24px;
}

.pulls-intro {
	max-width:     780px;
	color:         var(--muted);
	font-size:     0.85rem;
	line-height:   1.5;
	margin-bottom: 18px;
}

.pulls-list {
	list-style:     none;
	display:        flex;
	flex-direction: column;
	gap:            10px;
	max-width:      780px;
}

.pull-item {
	display:         flex;
	align-items:     center;
	justify-content: space-between;
	gap:             16px;
	padding:         14px 16px;
	background:      var(--surface);
	border:          1px solid var(--border);
	border-radius:   10px;
	transition:      border-color 0.15s ease;
}

.pull-item.editing {
	border-color: var(--brand);
}

.pull-info {
	min-width: 0;
}

.pull-title-row {
	display:     flex;
	align-items: center;
	gap:         8px;
	min-width:   0;
}

.pull-number {
	flex-shrink:   0;
	font-family:   'JetBrains Mono', Menlo, Consolas, monospace;
	font-size:     0.72rem;
	font-weight:   600;
	padding:       2px 7px;
	border-radius: 6px;
	background:    var(--surface-2);
	border:        1px solid var(--border);
	color:         var(--muted);
}

.pull-item.editing .pull-number {
	border-color: var(--brand);
	color:        var(--brand-soft);
}

.pull-title {
	font-size:     0.9rem;
	font-weight:   600;
	overflow:      hidden;
	text-overflow: ellipsis;
	white-space:   nowrap;
}

.pull-meta {
	margin-top:    5px;
	color:         var(--muted);
	font-size:     0.76rem;
	font-family:   'JetBrains Mono', Menlo, Consolas, monospace;
	overflow:      hidden;
	text-overflow: ellipsis;
	white-space:   nowrap;
}

.pull-actions {
	display:     flex;
	align-items: center;
	gap:         6px;
	flex-shrink: 0;
}

.pull-action {
	display:         inline-flex;
	align-items:     center;
	font-size:       0.78rem;
	font-weight:     600;
	padding:         6px 12px;
	border-radius:   7px;
	border:          1px solid var(--border);
	background:      transparent;
	color:           var(--muted);
	cursor:          pointer;
	text-decoration: none;
	transition:      border-color 0.15s ease, color 0.15s ease, background 0.15s ease;
}

.pull-action:hover:not(:disabled) {
	border-color: var(--brand);
	color:        var(--brand-soft);
	background:   var(--surface-2);
}

.pull-action:disabled {
	opacity: 0.5;
	cursor:  default;
}

.pull-action.danger:hover:not(:disabled) {
	border-color: var(--danger);
	color:        var(--danger);
	background:   transparent;
}

.pull-loading {
	list-style: none;
	color:      var(--muted);
	padding:    8px 0;
}

/* ---- Buttons ---- */

button {
	font-family:   inherit;
	font-size:     0.85rem;
	font-weight:   600;
	padding:       9px 16px;
	border-radius: 8px;
	border:        1px solid var(--border);
	background:    transparent;
	color:         var(--text);
	cursor:        pointer;
	transition:    border-color 0.15s ease, color 0.15s ease;
}

button:hover:not(:disabled) {
	border-color: var(--brand);
	color:        var(--brand-soft);
}

button:disabled {
	opacity:      0.4;
	cursor:       not-allowed;
}

button.primary {
	background:   var(--brand);
	border-color: var(--brand);
	color:        #ffffff;
}

button.primary:hover:not(:disabled) {
	background:   var(--brand-soft);
	border-color: var(--brand-soft);
	color:        #ffffff;
}

button.ghost {
	background: transparent;
}

/* ---- Modal ---- */

.modal {
	position:        fixed;
	inset:           0;
	background:      rgba(0, 0, 0, 0.72);
	display:         flex;
	align-items:     center;
	justify-content: center;
	padding:         24px;
	z-index:         100;
}

.modal-card {
	background:    var(--surface);
	border:        1px solid var(--border);
	border-radius: 16px;
	padding:       28px;
	width:         min(640px, 100%);
	max-height:    80vh;
	overflow:      auto;
}

.modal-card h2 {
	font-size:     1.2rem;
	margin-bottom: 8px;
}

.modal-card .muted {
	margin-bottom: 16px;
	line-height:   1.6;
}

.modal-card textarea {
	width:         100%;
	min-height:    100px;
	background:    var(--surface-2);
	border:        1px solid var(--border);
	border-radius: 6px;
	color:         var(--text);
	padding:       10px 12px;
	font-family:   inherit;
	font-size:     inherit;
	line-height:   1.5;
	resize:        vertical;
}

.modal-card .field {
	margin-bottom: 14px;
}

.modal-card label {
	display:        block;
	font-size:      0.8rem;
	color:          var(--muted);
	margin-bottom:  4px;
	text-transform: uppercase;
	letter-spacing: 0.05em;
}

.modal-card label.checkbox-row {
	display:        flex;
	align-items:    center;
	gap:            10px;
	font-size:      0.85rem;
	color:          var(--text);
	text-transform: none;
	letter-spacing: normal;
	margin:         18px 0 0;
	padding:        11px 13px;
	background:     var(--surface-2);
	border:         1px solid var(--border);
	border-radius:  8px;
	cursor:         pointer;
	transition:     border-color 0.12s ease;
}

.modal-card label.checkbox-row:hover {
	border-color: var(--brand);
}

.modal-card label.checkbox-row input {
	width:        16px;
	height:       16px;
	margin:       0;
	flex-shrink:  0;
	accent-color: var(--brand);
	cursor:       pointer;
}

.modal-card select,
.modal-card input[type="text"] {
	width:         100%;
	background:    var(--surface-2);
	border:        1px solid var(--border);
	border-radius: 6px;
	color:         var(--text);
	padding:       9px 12px;
	font-family:   inherit;
	font-size:     inherit;
}

.modal-card select:focus,
.modal-card input[type="text"]:focus {
	outline:       none;
	border-color:  var(--brand);
}

#newFileCategoryField {
	display:               grid;
	grid-template-columns: 1fr 1fr;
	gap:                   8px;
	align-items:           start;
}

#newFileCategoryField label {
	grid-column: 1 / -1;
}

.modal-actions {
	display:         flex;
	justify-content: flex-end;
	gap:             8px;
	margin-top:      16px;
}

.conflict-row {
	border:        1px solid var(--border);
	border-radius: 8px;
	padding:       12px;
	margin-bottom: 12px;
}

.conflict-row .conflict-path {
	font-family:   'JetBrains Mono', Menlo, Consolas, monospace;
	font-size:     0.85rem;
	margin-bottom: 8px;
}

.conflict-row .conflict-bodies {
	display:               grid;
	grid-template-columns: 1fr 1fr;
	gap:                   8px;
	margin-bottom:         8px;
}

.conflict-row pre {
	background:    var(--surface-2);
	border:        1px solid var(--border);
	border-radius: 4px;
	padding:       8px;
	max-height:    180px;
	overflow:      auto;
	font-family:   'JetBrains Mono', Menlo, Consolas, monospace;
	font-size:     0.8rem;
	line-height:   1.5;
	white-space:   pre-wrap;
}

.conflict-row .conflict-choice {
	display: flex;
	gap:     8px;
}

/* ---- Toast ---- */

.toast {
	position:      fixed;
	bottom:        24px;
	right:         24px;
	background:    var(--surface);
	border:        1px solid var(--border);
	border-radius: 8px;
	padding:       12px 16px;
	color:         var(--text);
	max-width:     360px;
	z-index:       200;
	box-shadow:    0 4px 16px rgba(0, 0, 0, 0.5);
}

.toast.error {
	border-color: var(--danger);
}

.toast.success {
	border-color: var(--brand);
}

/* ---- Mobile menu toggle (hidden on desktop) ---- */

.menu-toggle {
	display:        none;
	background:     transparent;
	border:         1px solid var(--border);
	color:          var(--text);
	padding:        4px 10px;
	border-radius:  6px;
	font-size:      1.05rem;
	line-height:    1;
	cursor:         pointer;
}

.menu-toggle:hover {
	border-color: var(--brand);
	color:        var(--brand-soft);
}

.sidebar-backdrop {
	display:    none;
	position:   fixed;
	inset:      0;
	background: rgba(0, 0, 0, 0.6);
	z-index:    49;
}

.sidebar-backdrop.open {
	display: block;
}

/* ---- Wiki ---- */

#featureWiki .editor-pane {
	display:        flex;
	flex-direction: column;
	overflow:       hidden;
	padding:        0;
}

#featureWiki .empty-state,
#featureWiki .wiki-content,
#featureWiki .wiki-editor {
	flex:       1;
	min-height: 0;
}

.wiki-content {
	overflow:     auto;
	padding:      28px 36px;
	max-width:    920px;
	width:        100%;
	line-height:  1.6;
	color:        var(--text);
}

.wiki-content h1,
.wiki-content h2,
.wiki-content h3,
.wiki-content h4 {
	margin:        24px 0 12px;
	line-height:   1.25;
	color:         var(--text);
}

.wiki-content h1 {
	font-size:     1.7rem;
	border-bottom: 1px solid var(--border);
	padding-bottom: 8px;
	margin-top:    0;
}

.wiki-content h2 {
	font-size:     1.35rem;
	border-bottom: 1px solid var(--border);
	padding-bottom: 6px;
}

.wiki-content h3 { font-size: 1.1rem;  }
.wiki-content h4 { font-size: 1rem;    }

.wiki-content p,
.wiki-content ul,
.wiki-content ol,
.wiki-content blockquote,
.wiki-content pre,
.wiki-content table {
	margin: 0 0 14px;
}

.wiki-content ul,
.wiki-content ol {
	padding-left: 24px;
}

.wiki-content a {
	color:           var(--brand-soft);
	text-decoration: none;
}

.wiki-content a:hover {
	text-decoration: underline;
}

.wiki-content code {
	background:    var(--surface-2);
	padding:       2px 6px;
	border-radius: 4px;
	font-size:     0.9em;
}

.wiki-content pre {
	background:    var(--surface-2);
	padding:       12px 14px;
	border-radius: 8px;
	overflow:      auto;
	border:        1px solid var(--border);
}

.wiki-content pre code {
	background: transparent;
	padding:    0;
}

.wiki-content blockquote {
	border-left: 3px solid var(--brand-soft);
	padding:     4px 14px;
	color:       var(--muted);
	background:  var(--surface);
}

.wiki-content img {
	max-width:     100%;
	height:        auto;
	border-radius: 8px;
	margin:        8px 0;
	border:        1px solid var(--border);
}

.wiki-content table {
	border-collapse: collapse;
	width:           100%;
}

.wiki-content th,
.wiki-content td {
	border:  1px solid var(--border);
	padding: 6px 10px;
	text-align: left;
}

.wiki-content th {
	background: var(--surface);
}

.wiki-content hr {
	border:        none;
	border-top:    1px solid var(--border);
	margin:        20px 0;
}

.wiki-editor {
	display:        flex;
	flex-direction: column;
	flex:           1;
	min-height:     0;
	padding:        20px;
	gap:            12px;
}

.wiki-name-row {
	display:     flex;
	align-items: center;
	gap:         10px;
	flex-wrap:   wrap;
}

.wiki-name-row label {
	color:       var(--muted);
	font-size:   0.8rem;
	text-transform: uppercase;
	letter-spacing: 0.5px;
}

.wiki-name-row input {
	flex:          1;
	min-width:     180px;
	background:    var(--surface-2);
	color:         var(--text);
	border:        1px solid var(--border);
	border-radius: 6px;
	padding:       6px 10px;
	font-family:   'Consolas', 'Menlo', monospace;
	font-size:     0.9rem;
	outline:       none;
}

.wiki-name-row input:focus {
	border-color: var(--brand-soft);
}

.wiki-name-row .path-preview {
	color:     var(--muted);
	font-size: 0.8rem;
}

.wiki-editor textarea {
	flex:          1 1 50%;
	min-height:    0;
	width:         100%;
	background:    var(--surface-2);
	color:         var(--text);
	border:        1px solid var(--border);
	border-radius: 8px;
	padding:       14px;
	font-family:   'Consolas', 'Menlo', monospace;
	font-size:     0.9rem;
	line-height:   1.5;
	resize:        none;
	outline:       none;
}

.wiki-editor textarea:focus {
	border-color: var(--brand-soft);
}

.wiki-editor.dragover textarea {
	border-color: var(--brand);
	background:   var(--surface);
}

.wiki-editor-preview {
	flex:          1 1 50%;
	min-height:    0;
	overflow:      auto;
	background:    var(--surface);
	border:        1px solid var(--border);
	border-radius: 8px;
	padding:       16px 22px;
	line-height:   1.6;
	color:         var(--text);
}

.wiki-editor-preview h1,
.wiki-editor-preview h2,
.wiki-editor-preview h3,
.wiki-editor-preview h4 { margin: 18px 0 10px; line-height: 1.25; }
.wiki-editor-preview h1 { font-size: 1.5rem; border-bottom: 1px solid var(--border); padding-bottom: 6px; margin-top: 0; }
.wiki-editor-preview h2 { font-size: 1.2rem; border-bottom: 1px solid var(--border); padding-bottom: 4px; }
.wiki-editor-preview h3 { font-size: 1.05rem; }
.wiki-editor-preview p,
.wiki-editor-preview ul,
.wiki-editor-preview ol,
.wiki-editor-preview blockquote,
.wiki-editor-preview pre,
.wiki-editor-preview table { margin: 0 0 12px; }
.wiki-editor-preview ul,
.wiki-editor-preview ol { padding-left: 22px; }
.wiki-editor-preview a { color: var(--brand-soft); text-decoration: none; }
.wiki-editor-preview code { background: var(--surface-2); padding: 2px 6px; border-radius: 4px; font-size: 0.9em; }
.wiki-editor-preview pre { background: var(--surface-2); padding: 10px 12px; border-radius: 6px; overflow: auto; border: 1px solid var(--border); }
.wiki-editor-preview pre code { background: transparent; padding: 0; }
.wiki-editor-preview img { max-width: 100%; height: auto; border-radius: 6px; border: 1px solid var(--border); margin: 6px 0; }
.wiki-editor-preview blockquote { border-left: 3px solid var(--brand-soft); padding: 4px 12px; color: var(--muted); }

#wikiList li {
	white-space:   nowrap;
	overflow:      hidden;
	text-overflow: ellipsis;
}

#wikiList li.active {
	background: var(--brand-soft);
	color:      #ffffff;
}

/* ---- Detection ---- */

#detectionForm {
	max-width: 920px;
}

#detectionForm .field {
	display:       block;
	margin-bottom: 18px;
}

#detectionForm label {
	display:        block;
	font-size:      0.8rem;
	color:          var(--muted);
	margin-bottom:  4px;
	text-transform: uppercase;
	letter-spacing: 0.05em;
}

#detectionForm label.checkbox-field {
	display:        flex;
	align-items:    center;
	gap:            8px;
	padding:        8px 0;
	margin-bottom:  12px;
	font-size:      0.85rem;
	color:          var(--text);
	text-transform: none;
	letter-spacing: 0;
}

#detectionForm input[type="text"],
#detectionForm input[type="number"],
#detectionForm textarea {
	width:         100%;
	background:    var(--surface);
	border:        1px solid var(--border);
	border-radius: 6px;
	color:         var(--text);
	padding:       10px 12px;
	font-family:   inherit;
	font-size:     inherit;
}

#detectionForm input[type="number"] {
	width: 120px;
}

#detectionForm input:focus,
#detectionForm textarea:focus {
	outline:      none;
	border-color: var(--brand);
}

#detectionForm textarea {
	line-height: 1.5;
	resize:      vertical;
}

#detectionForm .detection-notes {
	min-height: 70px;
}

#detectionForm .detection-names {
	min-height:  110px;
	font-family: 'JetBrains Mono', Menlo, Consolas, monospace;
	font-size:   0.85rem;
}

#detectionForm .field-row {
	display:     flex;
	align-items: center;
	gap:         10px;
}

.detection-images {
	list-style: none;
}

.detection-images li {
	display:       flex;
	align-items:   center;
	gap:           12px;
	padding:       8px;
	margin-bottom: 8px;
	background:    var(--surface);
	border:        1px solid var(--border);
	border-radius: 8px;
}

.detection-images img {
	width:         56px;
	height:        56px;
	flex-shrink:   0;
	object-fit:    cover;
	border-radius: 50%;
	background:    var(--surface-2);
}

.detection-images img.broken {
	visibility: hidden;
}

.detection-image-info {
	flex:      1;
	min-width: 0;
}

.detection-image-info a {
	display:         block;
	color:           var(--brand-soft);
	text-decoration: none;
	font-size:       0.85rem;
	overflow:        hidden;
	text-overflow:   ellipsis;
	white-space:     nowrap;
}

.detection-images .remove-field {
	background: transparent;
	border:     none;
	color:      var(--faint);
	font-size:  1.1rem;
	padding:    0 4px;
}

.detection-images .remove-field:hover:not(:disabled) {
	color: var(--danger);
}

#detectionList li.active {
	background: var(--brand-soft);
	color:      #ffffff;
}

button.danger {
	color: var(--danger);
}

button.primary.danger {
	background: var(--danger);
	color:      #ffffff;
}

/* ---- Responsive: tablet + phone ---- */

@media (max-width: 768px) {
	body {
		height:   auto;
		overflow: visible;
	}

	#dashboardScreen {
		height:  auto;
		display: block;
	}

	.topbar {
		flex-wrap: wrap;
		gap:       8px 10px;
		padding:   8px 12px;
	}

	.menu-toggle {
		display: inline-flex;
		align-items: center;
	}

	.brand {
		font-size: 0.9rem;
	}

	.topnav {
		order: 5;
		width: 100%;
		flex:  0 0 auto;
	}

	.topbar-right {
		gap:       6px;
		flex-wrap: wrap;
		font-size: 0.8rem;
	}

	.topbar-right strong {
		font-size: 0.85rem;
	}

	.repo-link {
		padding:   5px 9px;
		font-size: 0.72rem;
	}

	.feature {
		flex:       none;
		min-height: 0;
		height:     auto;
	}

	.feature-toolbar {
		padding: 10px 12px;
		gap:     8px;
	}

	.feature-toolbar .feature-title {
		font-size: 0.85rem;
	}

	.editor-main {
		display:  block;
		overflow: visible;
	}

	.sidebar {
		position:    fixed;
		top:         0;
		bottom:      0;
		left:        0;
		width:       86%;
		max-width:   340px;
		z-index:     50;
		transform:   translateX(-100%);
		transition:  transform 0.2s ease;
		box-shadow:  0 0 24px rgba(0, 0, 0, 0.6);
		border-right: 1px solid var(--border);
	}

	.sidebar.open {
		transform: translateX(0);
	}

	.editor-pane {
		padding:  14px;
		overflow: visible;
	}

	.pulls-pane {
		padding:  14px;
		overflow: visible;
	}

	.empty-state {
		padding: 40px 16px;
	}

	.file-header {
		flex-wrap: wrap;
		gap:       8px;
	}

	.file-header code {
		word-break: break-all;
		max-width:  100%;
	}

	#rawTextarea {
		min-height: 280px;
		padding:    12px;
	}

	#structuredForm textarea {
		min-height: 160px;
	}

	#structuredForm .field-row {
		flex-wrap: wrap;
	}

	.editor-actions {
		flex-wrap: wrap;
	}

	.editor-actions button {
		flex: 1 1 calc(50% - 4px);
	}

	.modal {
		padding: 10px;
	}

	.modal-card {
		padding:     18px;
		max-height:  92vh;
		border-radius: 12px;
	}

	.modal-card h2 {
		font-size: 1.05rem;
	}

	#newFileCategoryField {
		grid-template-columns: 1fr;
	}

	.conflict-row .conflict-bodies {
		grid-template-columns: 1fr;
	}

	.modal-actions {
		flex-wrap: wrap-reverse;
	}

	.modal-actions button {
		flex: 1 1 calc(50% - 4px);
	}

	.pull-item {
		flex-wrap: wrap;
	}

	.pull-actions {
		width:           100%;
		justify-content: flex-end;
	}

	.toast {
		bottom:    12px;
		right:     12px;
		left:      12px;
		max-width: none;
	}
}

@media (max-width: 420px) {
	.topbar-right .repo-link[id="repoLink"] {
		display: none;
	}

	.brand {
		display: none;
	}

	.feature-toolbar {
		flex-wrap: wrap;
	}

	.feature-toolbar #submitButton {
		flex: 1 1 100%;
	}
}
