/* =====================================================
	1. TOKENS
   ===================================================== */

:root {
	--bg-900: #0B0F14;
	--bg-800: #151C26;
	--bg-700: #1A2230;

	--text-primary: #E6EAF2;
	--text-secondary: #8793A3;
	--text-muted: #5C6673;

	--border-subtle: #2F394A;
	--border-strong: #444f62;

	--accent: #1C9B83;
	--accent-hover: #24B79A;

	--radius-sm: 2px;
	--radius-md: 4px;

	--transition-fast: 120ms ease;
}

/* =====================================================
   2. RESET & BASE
   ===================================================== */

*,
*::before,
*::after {
	box-sizing: border-box;
}

body {
	margin: 0;
	font-family: "Inter", sans-serif;
	background: var(--bg-900);
	color: var(--text-primary);
}

.init-state {
	display: none;
}

body.system-uninitialized .init-state {
	display: flex;
	flex-direction: column;
	gap: 12px;
}

body.system-uninitialized #output_section,
body.system-uninitialized section:not(.init-state) {
	display: none;
}

.share-training {
	display: none;
}

body.just-initialized .share-training {
	display: flex;
	flex-direction: column;
	gap: 12px;
}

h1, h2, h3, h4, h5, h6,
label {
	font-family: "IBM Plex Sans", sans-serif;
}

h1 {
	margin: 0;
	font-size: 28px;
	font-weight: 700;
}

h2 {
	margin: 0;
	font-size: 20px;
	font-weight: 500;
}

p {
	margin: 0;
	font-size: 16px;
}

p.meta {
	font-size: 12px;
	font-weight: 300;
	color: var(--text-secondary);
}

label {
	font-size: 12px;
	letter-spacing: 0.04em;
	text-transform: uppercase;
	color: var(--text-primary);
}

a {
	color: var(--accent);
	text-decoration: none;
}

a:hover {
	color: var(--accent-hover);
}

/* =====================================================
   3. LAYOUT
   ===================================================== */

.wrapper,
footer {
	padding: 12px;
	display: flex;
	flex-direction: column;
	gap: 18px;
}

header {
	display: flex;
	gap: 16px;
	align-items: flex-end;
}

section {
	display: flex;
	flex-direction: column;
	gap: 8px;
	padding: 12px;
	background: var(--bg-800);
	border: 1px solid var(--border-subtle);
	position: relative;
	box-shadow: inset 0 0 0 1px rgba(255,255,255,0.02);
}

.buttons {
	display: flex;
	gap: 4px;
}

nav ul {
	margin: 0;
	padding: 0;
	display: flex;
	flex-direction: column;
	gap: 8px;
}

nav li {
	list-style: none;
}

/* =====================================================
   4. COMPONENTS
   ===================================================== */

/* ---- Controls ---- */

.control {
	padding: 8px 16px;
	font-size: 16px;
	border-radius: var(--radius-md);
	border: 1px solid var(--border-strong);
	background: var(--bg-700);
	color: var(--text-primary);
	transition: var(--transition-fast);
}

.control--action.is-processing {
	opacity: 0.8;
	pointer-events: none;
	box-shadow: 0 0 0 1px rgba(28,155,131,0.5);
}

body.system-engaged .control--action {
	transition: background 180ms ease, box-shadow 180ms ease;
}

.control--fixed {
	height: 50px;
}

button.control {
	border-radius: var(--radius-sm);
	cursor: pointer;
}

.buttons > .control {
	flex: 1;
}

.control--action {
	background: var(--bg-700);
	color: var(--text-muted);
	border: 1px solid var(--border-strong);
}

.control--action:not(:disabled) {
	background: var(--accent);
	color: var(--bg-900);
	border: 1px solid var(--accent-hover);
}

.control--action:not(:disabled):hover {
	background: var(--accent-hover);
}
.control--danger {
	border: 1px solid var(--accent);
	color: var(--accent);
}

input.control,
textarea.control,
select.control {
	width: 100%;
}

/* ---- Inputs ---- */

.section--decrypted textarea.control{
	padding-top: 30px;
}

input.control,
textarea.control {
	font-family: "JetBrains Mono", monospace;
	resize: none;
	overflow: hidden;
}

textarea.control::placeholder {
	color: var(--text-muted);
	opacity: 1;
}

textarea.control {
	box-sizing: content-box;
	width: calc(100% - 34px); /* 16px + 16px horizontal padding */
}

textarea.control:focus-visible,
input.control:focus-visible {
	outline: none;
	border-color: var(--accent);
}

/* ---- Select ---- */

select.control {
	appearance: none;
	padding-right: 40px;
	background-image:
		linear-gradient(45deg, transparent 50%, var(--text-secondary) 50%),
		linear-gradient(135deg, var(--text-secondary) 50%, transparent 50%);
	background-position:
		calc(100% - 16px) 50%,
		calc(100% - 10px) 50%;
	background-size: 6px 6px;
	background-repeat: no-repeat;
	color: var(--text-secondary);
}

/* ---- Key list ---- */

.key-list {
	margin: 0;
	padding: 0;
	display: flex;
	flex-direction: column;
}

.key-list li.meta {
	list-style: none;
	font-size: 12px;
	font-weight: 300;
	color: var(--text-secondary);
}

.key-item {
	list-style: none;
	display: flex;
	justify-content: space-between;
	align-items: center;
	padding: 4px 0;
	gap: 4px;
}

.key-name {
	font-family: "IBM Plex Sans", sans-serif;
	font-size: 16px;
	font-weight: 300;
	color: var(--text-secondary);
}

.key-actions {
	display: flex;
	gap: 4px;
}


/* ---- Add key utility ---- */

.add-key {
	display: flex;
	flex: 0 0 50px;
	align-items: center;
	justify-content: center;
	width: 50px;
	height: 50px;

	background: transparent;
	border: 1px solid var(--border-strong);

	font-size: 24px;
	font-weight: 300;
	color: var(--text-secondary);

	text-decoration: none;
	transition: var(--transition-fast);
}

.add-key:hover {
	border-color: var(--accent);
	color: var(--accent);
}

/* ---- Dialog ---- */

dialog {
	width: min(420px, calc(100% - 32px));
	padding: 16px;
	background: var(--bg-800);
	border: 1px solid var(--accent);
	color: var(--text-primary);
}

dialog form {
	display: flex;
	flex-direction: column;
	gap: 16px;
}

dialog::backdrop {
	background: rgba(0,0,0,0.3);
	backdrop-filter: blur(2px);
}

/* ---- Impact ---- */

.impact {
	font-size: 12px;
	color: var(--text-muted);
	line-height: 1.5;
	margin-top: 12px;
}

.impact__count {
	color: var(--accent);
	font-weight: 500;
}

/* =====================================================
   5. STATES
   ===================================================== */

.is-decrypted {
	border-color: var(--accent);
}

.section--decrypted::before {
	content: "Decrypted message:";
	position: absolute;
	top: 46px;
    left: 30px;

	font-size: 11px;
	letter-spacing: 0.08em;
	text-transform: uppercase;
	color: var(--accent);

	pointer-events: none;
}

.section--decrypted .control--action {
	opacity: 0.3;
}