main {
	max-width: 1120px;
}

/* LAYOUT: navegación de secciones + contenido */
#settings {
	display: grid;
	gap: 1.5rem;
	grid-template-columns: 1fr;
}

.settings-nav {
	display: flex;
	flex-wrap: wrap;
	gap: .25rem;
}

.settings-nav a {
	border-radius: var(--radius);
	color: var(--ink-2);
	font-size: .875rem;
	padding: .625rem .75rem;
	text-decoration: none;
}

.settings-nav a:hover {
	background: var(--surface);
	color: var(--ink);
}

.settings-nav a.active {
	background: var(--accent-soft);
	color: var(--accent);
	font-weight: 600;
}

.settings-sections {
	display: flex;
	flex-direction: column;
	gap: 1.25rem;
	min-width: 0;
}

@media (min-width: 900px) {
	#settings {
		align-items: start;
		grid-template-columns: 12rem minmax(0, 1fr);
	}

	.settings-nav {
		flex-direction: column;
		position: sticky;
		top: 5rem;
	}
}

/* TARJETAS */
.settings-card {
	background: var(--surface);
	border: 1px solid var(--line);
	border-radius: var(--radius-lg);
	padding: 1.5rem;
	scroll-margin-top: 5rem;
}

.settings-card-header {
	align-items: flex-start;
	display: flex;
	gap: 1rem;
	justify-content: space-between;
	margin-bottom: 1.25rem;
}

.settings-card-title {
	color: var(--ink);
	font-size: 1.125rem;
	font-weight: 600;
	margin-bottom: .25rem;
}

.settings-card-desc {
	color: var(--muted);
	font-size: .875rem;
	margin-bottom: 1.25rem;
}

.settings-card-header .settings-card-desc {
	margin-bottom: 0;
}

.settings-actions {
	border-top: 1px solid var(--line-soft);
	display: flex;
	justify-content: flex-end;
	margin-top: 1.25rem;
	padding-top: 1.25rem;
}

/* API KEY */
.input-password {
	align-items: center;
	display: flex;
	position: relative;
}

.input-password input {
	background: var(--surface);
	border: 1px solid var(--line);
	border-radius: var(--radius);
	color: var(--ink);
	font-family: var(--font-mono);
	font-size: .875rem;
	min-height: 2.75rem;
	outline: none;
	padding: 0 3rem 0 .75rem;
	width: 100%;
}

.input-password input:focus {
	border-color: var(--accent);
	box-shadow: var(--focus);
}

.input-password input::placeholder {
	color: var(--placeholder);
}

.input-toggle {
	align-items: center;
	background: none;
	border: none;
	border-radius: var(--radius);
	color: var(--muted);
	cursor: pointer;
	display: flex;
	height: 2.25rem;
	justify-content: center;
	position: absolute;
	right: .25rem;
	width: 2.25rem;
}

.input-toggle:hover {
	background: var(--code-bg);
	color: var(--ink);
}

.input-toggle .eye-closed { display: none; }
.input-toggle.visible .eye-open { display: none; }
.input-toggle.visible .eye-closed { display: block; }

.help-text {
	color: var(--muted);
	font-size: .8125rem;
}

.help-text code {
	background: var(--code-bg);
	border-radius: 4px;
	color: var(--ink-2);
	font-size: .75rem;
	padding: .1rem .3rem;
}

/* CAMPOS (formularios de ajustes, musa y plantilla) */
#settings .input > select,
#musaForm .input > select,
#templateForm .input > select {
	appearance: none;
	background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%235B6576' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E") no-repeat right .75rem center;
	cursor: pointer;
	padding-right: 2.25rem;
}

#settings .input > textarea,
#musaForm .input > textarea,
#templateForm .input > textarea {
	resize: vertical;
}

/* TEMPERATURA */
input[type="range"] {
	accent-color: var(--accent);
	appearance: none;
	background: var(--line);
	border-radius: 2px;
	cursor: pointer;
	height: 4px;
	outline: none;
	width: 100%;
}

input[type="range"]::-webkit-slider-thumb {
	appearance: none;
	background: var(--surface);
	border: 2px solid var(--accent);
	border-radius: 50%;
	cursor: pointer;
	height: 18px;
	width: 18px;
}

input[type="range"]::-moz-range-thumb {
	background: var(--surface);
	border: 2px solid var(--accent);
	border-radius: 50%;
	cursor: pointer;
	height: 14px;
	width: 14px;
}

input[type="range"]:disabled {
	cursor: not-allowed;
	opacity: .4;
}

.range-labels {
	color: var(--muted);
	display: flex;
	font-family: var(--font-mono);
	font-size: .75rem;
	justify-content: space-between;
}

.range-with-toggle {
	align-items: center;
	display: flex;
	gap: .75rem;
	min-height: 2.75rem;
}

.range-with-toggle input[type="range"] {
	flex: 1;
}

.range-with-toggle input[type="checkbox"] {
	accent-color: var(--accent);
	display: block;
	height: 1.125rem;
	width: 1.125rem;
}

#temperatureValue,
#musaTemperatureValue {
	font-family: var(--font-mono);
}

/* LISTAS DE MUSAS Y PLANTILLAS */
.musas-empty {
	border: 1px dashed var(--line-strong);
	border-radius: var(--radius-lg);
	color: var(--muted);
	font-size: .9375rem;
	padding: 2rem 1rem;
	text-align: center;
}

.musas-list {
	display: grid;
	gap: .5rem;
}

.musa-item {
	align-items: center;
	background: var(--surface);
	border: 1px solid var(--line);
	border-radius: var(--radius-lg);
	display: flex;
	gap: .875rem;
	min-width: 0;
	padding: .75rem .75rem .75rem 1rem;
}

.musa-item:hover {
	border-color: var(--line-strong);
}

/* Compartida contigo: solo lectura */
.musa-item:has(.musa-tag.shared) {
	background: var(--surface-alt);
	border-style: dashed;
}

.musa-icon {
	color: var(--accent);
	display: flex;
	flex-shrink: 0;
}

.musa-info {
	flex: 1;
	min-width: 0;
}

.musa-name {
	color: var(--ink);
	font-size: .9375rem;
	font-weight: 600;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.musa-prompt-preview {
	color: var(--muted);
	font-size: .8125rem;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.musa-meta {
	display: flex;
	flex-shrink: 0;
	gap: .375rem;
}

.musa-meta:not(:has(*)) {
	display: none;
}

.musa-tag {
	background: var(--code-bg);
	border-radius: 4px;
	color: var(--ink-2);
	font-family: var(--font-mono);
	font-size: .75rem;
	padding: .2rem .45rem;
	white-space: nowrap;
}

.musa-tag.shared {
	background: transparent;
	color: var(--muted);
	max-width: 16rem;
	overflow: hidden;
	text-overflow: ellipsis;
}

.musa-actions {
	display: flex;
	flex-shrink: 0;
	gap: .125rem;
}

.musa-action-btn {
	align-items: center;
	background: none;
	border: 1px solid transparent;
	border-radius: var(--radius);
	color: var(--muted);
	cursor: pointer;
	display: flex;
	height: 2.5rem;
	justify-content: center;
	width: 2.5rem;
}

.musa-action-btn:hover {
	background: var(--code-bg);
	color: var(--ink);
}

.musa-action-btn.share:hover {
	background: var(--accent-soft);
	color: var(--accent);
}

.musa-action-btn.delete:hover {
	background: var(--danger-soft);
	color: var(--danger);
}

/* MODAL COMPARTIR */
#shareForm {
	display: grid;
	gap: 1rem;
	margin-top: 1rem;
}

#shareForm .settings-card-desc {
	margin-bottom: 0;
}

#shareForm .musas-empty {
	padding: 1rem;
}

.share-add {
	display: flex;
	gap: .5rem;
}

#shareForm .share-add input {
	background: var(--surface);
	border: 1px solid var(--line);
	border-radius: var(--radius);
	color: var(--ink);
	flex: 1;
	font-family: inherit;
	font-size: .9375rem;
	min-height: 2.75rem;
	min-width: 0;
	outline: none;
	padding: 0 .75rem;
}

#shareForm .share-add input:focus {
	border-color: var(--accent);
	box-shadow: var(--focus);
}

#shareForm .share-add .btn {
	min-height: 2.75rem;
}

.share-list {
	display: grid;
	gap: .375rem;
	list-style: none;
	margin: 0;
	padding: 0;
}

.share-list li {
	align-items: center;
	border: 1px solid var(--line);
	border-radius: var(--radius);
	display: flex;
	gap: .5rem;
	justify-content: space-between;
	padding: .25rem .25rem .25rem .75rem;
}

.share-list li span {
	font-family: var(--font-mono);
	font-size: .875rem;
	min-width: 0;
	overflow: hidden;
	text-overflow: ellipsis;
}

/* MODALES DE MUSA Y PLANTILLA */
#musaForm,
#templateForm {
	display: grid;
	gap: 1.25rem;
	margin-top: 1rem;
}

#musaForm textarea {
	min-height: 140px;
}

#templateForm h3 {
	border-top: 1px solid var(--line-soft);
	margin: 0;
	padding-top: 1rem;
}

#templateForm h3 + .settings-card-desc {
	margin-bottom: 0;
	margin-top: -1rem;
}

#templateForm textarea {
	font-family: var(--font-mono);
	font-size: .8125rem;
	min-height: 160px;
}

/* Interruptores dentro de los formularios (label.input con .toogle) */
#templateForm label.input:has(.toogle) {
	align-items: center;
	cursor: pointer;
	flex-direction: row;
	justify-content: space-between;
}

#templateForm .input > input.template-color-input {
	cursor: pointer;
	height: 2.75rem;
	padding: .25rem;
	width: 4rem;
}

#templateForm .input > input[type="file"] {
	font-size: .875rem;
	padding: .5rem;
}

.template-fallback-fields {
	border: 1px solid var(--line);
	border-radius: var(--radius-lg);
	padding: 1rem;
}

.template-fallback-fields[open] {
	display: grid;
	gap: 1.25rem;
}

.template-fallback-fields > summary {
	color: var(--ink);
	cursor: pointer;
	font-size: .9375rem;
	font-weight: 600;
	user-select: none;
}

.template-img-preview {
	border: 1px solid var(--line);
	border-radius: var(--radius);
	display: block;
	margin-top: .25rem;
	max-height: 120px;
	max-width: 100%;
	object-fit: contain;
}

.btn-remove-img {
	align-self: flex-start;
	background: var(--surface);
	border: 1px solid var(--line);
	border-radius: var(--radius);
	color: var(--danger);
	cursor: pointer;
	font-family: inherit;
	font-size: .8125rem;
	min-height: 2.25rem;
	padding: 0 .75rem;
}

.btn-remove-img:hover {
	background: var(--danger-soft);
	border-color: var(--danger);
}

/* RESPONSIVE */
@media (max-width: 768px) {
	.settings-card {
		padding: 1.25rem;
	}

	.settings-card-header {
		flex-direction: column;
	}

	.musa-item {
		flex-wrap: wrap;
	}

	.musa-meta {
		order: 3;
		width: 100%;
	}
}
