/* Cross Stitch Desk tools. Uses theme variables when present, with fallbacks. */
.csdt-tool {
	--t-ink: var(--csd-ink, #2a2420);
	--t-muted: var(--csd-muted, #5e554c);
	--t-accent: var(--csd-red, #a8323e);
	--t-accent-dark: var(--csd-red-dark, #86262f);
	--t-soft: var(--csd-red-soft, #f8e7e4);
	--t-line: var(--csd-line, #e4d8c6);
	--t-paper: var(--csd-paper, #fffdf9);
	--t-bg: var(--csd-cream, #f8f3ea);
	--t-radius: var(--csd-radius, 16px);
	margin: 0 0 2.5rem;
	color: var(--t-ink);
	font-size: 1rem;
}
.csdt-tool *,
.csdt-tool *::before,
.csdt-tool *::after { box-sizing: border-box; }
.csdt-loading,
.csdt-noscript,
.csdt-error {
	padding: 1.25rem;
	border: 1px dashed var(--t-line);
	border-radius: var(--t-radius);
	background: var(--t-paper);
}
.csdt-error { border-color: var(--t-accent); }

.csdt-panel {
	background: var(--t-paper);
	border: 1px solid var(--t-line);
	border-radius: var(--t-radius);
	padding: 1.25rem 1.25rem 1.1rem;
	margin: 0 0 1rem;
	box-shadow: 0 1px 2px rgba(42, 36, 32, 0.04), 0 10px 24px -18px rgba(42, 36, 32, 0.25);
}
.csdt-panel__title {
	font-size: 1.15rem !important;
	margin: 0 0 1rem !important;
	padding: 0 !important;
	border: 0 !important;
}
.csdt-panel__title::before,
.csdt-panel__title::after { display: none !important; }
.csdt-subtitle { font-size: 1.05rem !important; margin: 1.25rem 0 0.5rem !important; }

.csdt-grid {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
	gap: 0.9rem 1.1rem;
	margin: 0 0 0.75rem;
}
.csdt-field { display: flex; flex-direction: column; gap: 0.35rem; min-width: 0; position: relative; }
.csdt-field--wide { grid-column: 1 / -1; margin-bottom: 0.9rem; }
.csdt-field label { font-weight: 600; font-size: 0.92rem; }
.csdt-field input[type="number"],
.csdt-field input[type="text"],
.csdt-field input[type="search"],
.csdt-field input[type="date"],
.csdt-field select,
.csdt-field textarea {
	width: 100%;
	min-height: 44px;
	padding: 0.55rem 0.7rem;
	font: inherit;
	color: var(--t-ink);
	background: #fff;
	border: 1px solid #b9ab95;
	border-radius: 10px;
}
.csdt-field textarea { min-height: 90px; resize: vertical; font-size: 1.05rem; }
.csdt-field input[type="color"] { width: 100%; height: 44px; padding: 2px; border: 1px solid #b9ab95; border-radius: 10px; background: #fff; cursor: pointer; }
.csdt-field input[type="range"] { width: 100%; accent-color: var(--t-accent); min-height: 32px; }
.csdt-field--check { flex-direction: row; flex-wrap: wrap; align-items: center; gap: 0.5rem; }
.csdt-field--check input { width: 20px; height: 20px; accent-color: var(--t-accent); margin: 0; }
.csdt-field--check label { font-weight: 500; }
.csdt-field--check .csdt-hint { flex-basis: 100%; padding-left: 28px; }
.csdt-hint { font-size: 0.82rem; color: var(--t-muted); line-height: 1.4; }
.csdt-tool :focus-visible { outline: 3px solid var(--t-accent); outline-offset: 2px; }

.csdt-upload { display: flex; gap: 1rem; align-items: stretch; flex-wrap: wrap; margin-bottom: 0.75rem; }
.csdt-file {
	flex: 1 1 260px;
	display: flex;
	align-items: center;
	justify-content: center;
	text-align: center;
	min-height: 140px;
	padding: 1.25rem;
	border: 2px dashed #c4b39b;
	border-radius: var(--t-radius);
	background: repeating-linear-gradient(0deg, transparent 0 11px, rgba(168, 50, 62, 0.05) 11px 12px), repeating-linear-gradient(90deg, transparent 0 11px, rgba(168, 50, 62, 0.05) 11px 12px), var(--t-bg);
	cursor: pointer;
	position: relative;
	transition: border-color 0.15s, background-color 0.15s;
}
.csdt-file:hover,
.csdt-file.is-over { border-color: var(--t-accent); }
.csdt-file:focus-within { outline: 3px solid var(--t-accent); outline-offset: 2px; }
.csdt-file--small { min-height: 80px; margin: 0.75rem 0; }
.csdt-file__input { position: absolute; width: 1px; height: 1px; opacity: 0; overflow: hidden; }
.csdt-file__text strong { color: var(--t-accent-dark); font-size: 1.05rem; }
.csdt-file__text small { color: var(--t-muted); }
.csdt-thumb { max-width: 160px; max-height: 160px; border-radius: 10px; border: 1px solid var(--t-line); align-self: center; }

.csdt-more { margin: 0.25rem 0 0.75rem; border-top: 1px solid var(--t-line); padding-top: 0.6rem; }
.csdt-more summary { cursor: pointer; font-weight: 600; color: var(--t-accent-dark); padding: 0.35rem 0; min-height: 32px; }
.csdt-more[open] summary { margin-bottom: 0.75rem; }

.csdt-actions { display: flex; flex-wrap: wrap; gap: 0.6rem; align-items: center; margin: 0.5rem 0; }
.csdt-btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-height: 46px;
	padding: 0.6rem 1.2rem;
	font: inherit;
	font-weight: 600;
	color: var(--t-accent-dark);
	background: #fff;
	border: 2px solid var(--t-accent);
	border-radius: 999px;
	cursor: pointer;
	line-height: 1.2;
}
.csdt-btn:hover { background: var(--t-soft); }
.csdt-btn--primary { color: #fff; background: var(--t-accent); }
.csdt-btn--primary:hover { background: var(--t-accent-dark); border-color: var(--t-accent-dark); color: #fff; }
.csdt-btn--quiet { border-color: var(--t-line); color: var(--t-muted); }
.csdt-btn[disabled] { opacity: 0.5; cursor: not-allowed; }
.csdt-progress { flex: 1 1 160px; height: 10px; accent-color: var(--t-accent); }
.csdt-status { color: var(--t-muted); font-size: 0.92rem; margin: 0.35rem 0 0; min-height: 1.4em; }
.csdt-note { font-size: 0.85rem; color: var(--t-muted); margin: 0.5rem 0 0; line-height: 1.5; }

.csdt-result { margin: 0 0 0.75rem; display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 0.6rem; }
.csdt-result__row { background: var(--t-bg); border: 1px solid var(--t-line); border-radius: 12px; padding: 0.7rem 0.85rem; margin: 0; }
.csdt-result__row dt { font-size: 0.8rem; color: var(--t-muted); font-weight: 600; text-transform: none; margin: 0 0 0.2rem; }
.csdt-result__row dd { margin: 0; font-weight: 600; font-size: 1rem; line-height: 1.35; }
.csdt-result__row--big { background: var(--t-soft); border-color: #ecc8c2; }
.csdt-result__row--big dd { font-size: 1.2rem; color: var(--t-accent-dark); }

.csdt-viewbar { display: flex; flex-wrap: wrap; gap: 0.75rem 1.25rem; align-items: end; justify-content: space-between; margin: 0.5rem 0 0.6rem; }
.csdt-viewbar .csdt-field { flex: 0 1 200px; }
.csdt-seg { display: inline-flex; flex-wrap: wrap; border: 1px solid #b9ab95; border-radius: 999px; overflow: hidden; background: #fff; }
.csdt-seg button { font: inherit; font-size: 0.9rem; font-weight: 600; min-height: 42px; padding: 0.45rem 0.95rem; border: 0; background: transparent; color: var(--t-ink); cursor: pointer; }
.csdt-seg button + button { border-left: 1px solid var(--t-line); }
.csdt-seg button[aria-pressed="true"] { background: var(--t-accent); color: #fff; }
.csdt-canvaswrap { overflow: auto; max-height: 75vh; border: 1px solid var(--t-line); border-radius: 12px; background: #fbf8f2; padding: 0; -webkit-overflow-scrolling: touch; }
.csdt-canvas { display: block; max-width: none; image-rendering: pixelated; }
.csdt-canvas--paper { image-rendering: auto; box-shadow: 0 2px 10px rgba(0, 0, 0, 0.12); margin: 12px; }
.csdt-pickcanvas { display: block; max-width: 100%; height: auto; cursor: crosshair; border-radius: 10px; margin-top: 0.5rem; }

.csdt-tablewrap { overflow-x: auto; border: 1px solid var(--t-line); border-radius: 12px; }
.csdt-table { width: 100%; border-collapse: collapse; margin: 0 !important; font-size: 0.92rem; background: #fff; border: 0 !important; }
.csdt-table th,
.csdt-table td { padding: 0.5rem 0.7rem !important; border: 0 !important; border-bottom: 1px solid var(--t-line) !important; text-align: left; vertical-align: middle; }
.csdt-table thead th { background: var(--t-bg); font-size: 0.82rem; }
.csdt-table tbody tr:last-child > * { border-bottom: 0 !important; }
.csdt-num { text-align: right !important; font-variant-numeric: tabular-nums; }
.csdt-sym { font-family: Arial, Helvetica, sans-serif; font-weight: 700; font-size: 1rem; text-align: center !important; width: 3.5em; }
.csdt-swatch { display: inline-block; width: 28px; height: 18px; border-radius: 4px; border: 1px solid rgba(0, 0, 0, 0.25); vertical-align: middle; }
.csdt-swatch--big { width: 46px; height: 46px; border-radius: 10px; flex: none; }
.csdt-grid--export { margin-top: 1rem; }

.csdt-target { display: flex; gap: 0.8rem; align-items: center; font-weight: 600; margin-bottom: 0.9rem; }
.csdt-matches { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 0.6rem; }
.csdt-match { display: flex; gap: 0.75rem; align-items: center; padding: 0.6rem; border: 1px solid var(--t-line); border-radius: 12px; background: #fff; margin: 0 !important; }
.csdt-match__body { display: flex; flex-direction: column; line-height: 1.3; min-width: 0; }
.csdt-match__body small { color: var(--t-muted); font-size: 0.8rem; }
.csdt-lookup { list-style: none; margin: 0; padding: 0; position: absolute; top: 100%; left: 0; right: 0; z-index: 5; background: #fff; border: 1px solid var(--t-line); border-radius: 10px; box-shadow: 0 10px 24px -12px rgba(0, 0, 0, 0.3); }
.csdt-lookup:empty { display: none; }
.csdt-lookup li { margin: 0 !important; }
.csdt-lookup button { display: flex; gap: 0.4rem; align-items: center; width: 100%; text-align: left; font: inherit; font-size: 0.92rem; padding: 0.55rem 0.7rem; min-height: 42px; border: 0; background: transparent; cursor: pointer; color: var(--t-ink); }
.csdt-lookup button:hover,
.csdt-lookup button:focus { background: var(--t-soft); }

.csdt-meter { height: 18px; border-radius: 999px; background: var(--t-bg); border: 1px solid var(--t-line); overflow: hidden; margin: 0 0 0.9rem; }
.csdt-meter span { display: block; height: 100%; background: repeating-linear-gradient(45deg, var(--t-accent) 0 8px, var(--t-accent-dark) 8px 16px); transition: width 0.3s; }

@media (max-width: 600px) {
	.csdt-panel { padding: 1rem 0.85rem; border-radius: 12px; }
	.csdt-grid { grid-template-columns: 1fr; }
	.csdt-seg { width: 100%; }
	.csdt-seg button { flex: 1 1 auto; padding: 0.45rem 0.6rem; }
	.csdt-actions .csdt-btn { flex: 1 1 100%; }
}
@media print {
	.csdt-panel:not(.csdt-out) { display: none; }
}
.entry-content .csdt-tool ul,
.entry-content .csdt-tool ol { padding-left: 0; margin-left: 0; }
.entry-content .csdt-tool li { margin-bottom: 0; }
.entry-content .csdt-tool a::after { content: none !important; }
