* {
	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;
	min-height:      100vh;
}

.hidden {
	display: none !important;
}

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

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 {
	height: calc(100vh - 53px);
	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);
}

.editor-main {
	display:    grid;
	grid-template-columns: 320px 1fr;
	flex:       1;
	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;
}

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

.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;
}

/* ---- 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 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);
}
