/* ==========================================================================
   Tangan Kanan XPP — Minimalist Design System (Ref: Kadal Evidence)
   ========================================================================== */

:root {
	--bg: #090a0c;
	--surface: #101216;
	--elevated: #161920;
	--ink: #f0f3f6;
	--soft: #8b949e;
	--muted: #565e68;
	--line: #1f242c;
	--line-strong: #30363d;
	--tint: #15181e;
	--focus: #58a6ff;
	--accent: #f0f3f6;
	--accent-ink: #090a0c;
	--ok: #3fb950;
	--danger: #f85149;
	--shade: rgba(6, 8, 10, .78);
	--h3: #26a641;
	--h4: #39d353;
	--r: 8px;
	--mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
	--sans: -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

html[data-theme="light"] {
	--bg: #fafafa;
	--surface: #ffffff;
	--elevated: #ffffff;
	--ink: #111827;
	--soft: #6b7280;
	--muted: #9ca3af;
	--line: #e5e7eb;
	--line-strong: #d1d5db;
	--tint: #f3f4f6;
	--focus: #2563eb;
	--accent: #111827;
	--accent-ink: #ffffff;
	--ok: #16a34a;
	--danger: #dc2626;
	--shade: rgba(15, 23, 42, .65);
	--h3: #30a14e;
	--h4: #216e39;
}

* {
	box-sizing: border-box;
}

html {
	-webkit-text-size-adjust: 100%;
}

body {
	margin: 0;
	background: var(--bg);
	color: var(--ink);
	font: 13px/1.45 var(--sans);
	-webkit-font-smoothing: antialiased;
	overflow-x: hidden;
	min-height: 100vh;
	display: flex;
	flex-direction: column;
}

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

:focus-visible {
	outline: 1.5px solid var(--focus);
	outline-offset: 1px;
}

/* ---- Top Bar ---- */
.topbar {
	position: sticky;
	top: 0;
	z-index: 30;
	background: color-mix(in srgb, var(--bg) 86%, transparent);
	backdrop-filter: blur(12px);
	-webkit-backdrop-filter: blur(12px);
	border-bottom: 1px solid var(--line);
}

.topbar-inner {
	max-width: 1500px;
	margin: 0 auto;
	padding: 10px 20px;
	display: flex;
	align-items: center;
	gap: 12px;
	flex-wrap: wrap;
}

.brand {
	display: inline-flex;
	align-items: center;
	gap: 8px;
	font-family: var(--mono);
	font-size: 13px;
	font-weight: 600;
	letter-spacing: -.02em;
	color: var(--ink);
	text-decoration: none;
}

.brand-dot {
	width: 7px;
	height: 7px;
	border-radius: 99px;
	background: var(--h4);
	box-shadow: 0 0 8px var(--h3);
	transition: background .15s, box-shadow .15s;
}

.brand-dot.busy {
	background: var(--focus);
	box-shadow: 0 0 8px var(--focus);
}

.brand-dot.err {
	background: var(--danger);
	box-shadow: 0 0 8px var(--danger);
}

.stats-pill {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	font-family: var(--mono);
	font-size: 11px;
	color: var(--soft);
	background: var(--tint);
	border: 1px solid var(--line);
	padding: 2px 8px;
	border-radius: 99px;
	font-variant-numeric: tabular-nums;
}

.stats-pill.ok {
	color: var(--ok);
	border-color: color-mix(in srgb, var(--ok) 35%, var(--line));
}

.stats-pill.err {
	color: var(--danger);
	border-color: color-mix(in srgb, var(--danger) 35%, var(--line));
}

.controls {
	margin-left: auto;
	display: flex;
	align-items: center;
	gap: 6px;
	flex-wrap: wrap;
}

.ctrl {
	appearance: none;
	background: var(--surface);
	border: 1px solid var(--line);
	border-radius: var(--r);
	padding: 5px 10px;
	font-size: 12px;
	min-height: 30px;
	color: var(--ink);
	transition: border-color .12s, background .12s;
}

.ctrl:hover {
	border-color: var(--line-strong);
}

select.ctrl {
	padding-right: 26px;
	cursor: pointer;
	font-family: var(--mono);
	font-size: 11.5px;
	background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%238b949e' stroke-width='1.4' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
	background-repeat: no-repeat;
	background-position: right 9px center;
}

.ctrl-btn {
	display: inline-flex;
	align-items: center;
	gap: 5px;
	cursor: pointer;
	text-decoration: none;
	color: var(--soft);
	white-space: nowrap;
}

.ctrl-btn:hover {
	color: var(--ink);
}

.ctrl-btn .cnt {
	font-family: var(--mono);
	font-size: 10px;
	background: var(--tint);
	border: 1px solid var(--line);
	border-radius: 99px;
	padding: 0 5px;
	color: var(--ink);
}

.icon-btn {
	width: 30px;
	height: 30px;
	padding: 0;
	display: inline-grid;
	place-items: center;
}

.view-seg {
	display: inline-flex;
	background: var(--bg);
	border: 1px solid var(--line);
	border-radius: var(--r);
	padding: 2px;
}

.view-seg button {
	background: none;
	border: 0;
	border-radius: 5px;
	padding: 3px 9px;
	font-size: 11px;
	font-family: var(--mono);
	color: var(--soft);
	cursor: pointer;
}

.view-seg button.on {
	background: var(--tint);
	color: var(--ink);
	font-weight: 500;
}

/* ---- Main Workspace ---- */
.workspace {
	width: 100%;
	max-width: 1500px;
	margin: 0 auto;
	padding: 16px 20px 32px;
	display: grid;
	grid-template-columns: 1fr 1fr;
	gap: 14px;
	flex: 1;
}

@media (max-width: 960px) {
	.workspace {
		grid-template-columns: 1fr;
	}
}

.panel {
	background: var(--surface);
	border: 1px solid var(--line);
	border-radius: var(--r);
	display: flex;
	flex-direction: column;
	overflow: hidden;
	min-height: 540px;
}

.panel-head {
	padding: 10px 14px;
	border-bottom: 1px solid var(--line);
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 10px;
	flex-wrap: wrap;
}

.panel-title {
	display: flex;
	align-items: center;
	gap: 8px;
	font-size: 12px;
}

.panel-title strong {
	font-family: var(--mono);
	font-weight: 600;
	color: var(--ink);
}

.muted-meta {
	font-family: var(--mono);
	font-size: 11px;
	color: var(--muted);
	font-variant-numeric: tabular-nums;
}

.panel-actions {
	display: flex;
	align-items: center;
	gap: 5px;
	flex-wrap: wrap;
}

.adm-act {
	background: var(--surface);
	border: 1px solid var(--line);
	border-radius: 5px;
	padding: 3px 8px;
	font-family: var(--mono);
	font-size: 11px;
	color: var(--soft);
	cursor: pointer;
	text-decoration: none;
	transition: border-color .12s, color .12s;
}

.adm-act:hover {
	border-color: var(--line-strong);
	color: var(--ink);
}

.adm-act.del:hover {
	border-color: var(--danger);
	color: var(--danger);
}

.adm-act.done {
	border-color: var(--ok);
	color: var(--ok);
}

.editor {
	flex: 1;
	width: 100%;
	background: transparent;
	border: 0;
	padding: 14px;
	color: var(--ink);
	font: 13px/1.6 var(--sans);
	resize: none;
	outline: none;
}

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

.panel-foot {
	padding: 10px 14px;
	border-top: 1px solid var(--line);
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 10px;
	background: var(--tint);
}

.kbd-hint {
	font-family: var(--mono);
	font-size: 11px;
	color: var(--muted);
}

kbd {
	border: 1px solid var(--line-strong);
	border-radius: 4px;
	padding: 1px 5px;
	font-family: var(--mono);
	font-size: 10px;
	color: var(--soft);
	background: var(--surface);
}

.btn-primary {
	background: var(--accent);
	color: var(--accent-ink);
	border: 0;
	border-radius: 6px;
	padding: 6px 14px;
	font-family: var(--mono);
	font-size: 12px;
	font-weight: 600;
	cursor: pointer;
	transition: opacity .12s;
}

.btn-primary:hover {
	opacity: .9;
}

.btn-primary.stop {
	background: var(--danger);
	color: #fff;
}

/* ---- Output Split Sections ---- */
.output-split {
	flex: 1;
	display: flex;
	flex-direction: column;
	gap: 10px;
	padding: 12px;
}

.output-split[hidden],
.output-raw[hidden] {
	display: none;
}

.output-raw {
	flex: 1;
	display: flex;
	flex-direction: column;
}

.sec-box {
	background: var(--bg);
	border: 1px solid var(--line);
	border-radius: 6px;
	display: flex;
	flex-direction: column;
	overflow: hidden;
}

.sec-box:focus-within {
	border-color: var(--line-strong);
}

.sec-box-grow {
	flex: 1;
}

.sec-head {
	padding: 6px 10px;
	border-bottom: 1px solid var(--line);
	background: var(--tint);
	display: flex;
	align-items: center;
	justify-content: space-between;
	font-family: var(--mono);
	font-size: 11px;
	color: var(--soft);
}

.copy-inline {
	background: none;
	border: 0;
	padding: 0;
	color: var(--soft);
	font-family: var(--mono);
	font-size: 11px;
	cursor: pointer;
}

.copy-inline:hover {
	color: var(--ink);
}

.copy-inline.done {
	color: var(--ok);
}

.sec-textarea {
	width: 100%;
	flex: 1;
	background: transparent;
	border: 0;
	padding: 10px;
	color: var(--ink);
	font: 13px/1.55 var(--sans);
	resize: vertical;
	outline: none;
}

.sec-textarea::placeholder {
	color: var(--muted);
}

.sec-editable {
	white-space: pre-wrap;
	word-break: break-word;
	overflow-y: auto;
	min-height: 92px;
}

.sec-editable-lg {
	min-height: 155px;
}

.sec-editable:empty::before {
	content: attr(data-placeholder);
	color: var(--muted);
	pointer-events: none;
}

.sec-editable strong,
.sec-editable b {
	font-weight: 700;
	color: var(--ink);
}

/* ---- Modals (Keys & History) ---- */
.modal-backdrop {
	position: fixed;
	inset: 0;
	z-index: 55;
	background: var(--shade);
	backdrop-filter: blur(8px);
	-webkit-backdrop-filter: blur(8px);
	display: grid;
	place-items: center;
	padding: 16px;
}

.modal-backdrop[hidden] {
	display: none;
}

.admin-modal {
	width: 100%;
	max-width: 560px;
	max-height: calc(100vh - 32px);
	background: var(--surface);
	border: 1px solid var(--line-strong);
	border-radius: 12px;
	box-shadow: 0 24px 64px rgba(0, 0, 0, .5);
	display: flex;
	flex-direction: column;
	overflow: hidden;
}

.adm-head {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 12px;
	padding: 12px 16px;
	border-bottom: 1px solid var(--line);
}

.adm-head h2 {
	margin: 0;
	font-size: 13px;
	font-family: var(--mono);
	font-weight: 600;
	display: flex;
	align-items: center;
	gap: 8px;
}

.adm-ep {
	font-family: var(--mono);
	font-size: 11px;
	font-weight: 400;
	color: var(--soft);
	background: var(--tint);
	border: 1px solid var(--line);
	padding: 2px 8px;
	border-radius: 6px;
}

.adm-body {
	padding: 14px 16px;
	overflow-y: auto;
	display: flex;
	flex-direction: column;
	gap: 12px;
}

.adm-preview {
	font-family: var(--mono);
	font-size: 11px;
	color: var(--soft);
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 8px;
	flex-wrap: wrap;
}

.link-mono {
	color: var(--focus);
	text-decoration: none;
	font-family: var(--mono);
	font-size: 11px;
}

.link-mono:hover {
	text-decoration: underline;
}

.keys-textarea {
	width: 100%;
	background: var(--bg);
	border: 1px solid var(--line);
	border-radius: 6px;
	padding: 10px;
	font-family: var(--mono);
	font-size: 12px;
	line-height: 1.5;
	color: var(--ink);
	resize: vertical;
	outline: none;
}

.keys-textarea:focus {
	border-color: var(--focus);
}

.modal-foot {
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding-top: 4px;
}

.adm-list {
	display: flex;
	flex-direction: column;
	border: 1px solid var(--line);
	border-radius: 8px;
	overflow: hidden;
}

.adm-row {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 10px;
	padding: 10px 12px;
	background: var(--surface);
	border-bottom: 1px solid var(--line);
}

.adm-row:last-child {
	border-bottom: 0;
}

.adm-row:hover {
	background: var(--tint);
}

.hist-info {
	min-width: 0;
	flex: 1;
	display: flex;
	flex-direction: column;
	gap: 3px;
}

.hist-time {
	font-family: var(--mono);
	font-size: 10.5px;
	color: var(--muted);
}

.hist-text {
	font-size: 12px;
	color: var(--soft);
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

@media (max-width: 640px) {
	.topbar-inner, .workspace {
		padding-left: 12px;
		padding-right: 12px;
	}
}
