/* ============================================================
   SONAI Skin Analyzer — giao diện
   Palette: nền hồng kem, tím mận đậm cho heading, hồng san hô
   cho điểm số, xanh sage cho trạng thái tốt.
   ============================================================ */

.sonai-skin {
	--bg: #fbf6f4;
	--card: #ffffff;
	--ink: #2c2230;
	--muted: #8a7d86;
	--plum: #43293d;
	--plum-soft: #6b4a63;
	--rose: #d96a6a;
	--rose-soft: #f3dcdc;
	--sage: #5fae8e;
	--gold: #e0a93f;
	--line: #efe4e0;
	--radius: 18px;
	--shadow: 0 10px 40px -18px rgba(67, 41, 61, .35);

	font-family: "Be Vietnam Pro", system-ui, -apple-system, "Segoe UI", sans-serif;
	color: var(--ink);
	background: var(--bg);
	max-width: 760px;
	margin: 0 auto;
	padding: 8px;
	line-height: 1.6;
	box-sizing: border-box;
}
.sonai-skin *,
.sonai-skin *::before,
.sonai-skin *::after { box-sizing: border-box; }

/* ---------- Hero / màn chụp ---------- */
.ss-hero { text-align: center; padding: 26px 16px 10px; }
.ss-hero h1 {
	font-size: clamp(28px, 6vw, 44px);
	font-weight: 800;
	letter-spacing: -.02em;
	color: var(--plum);
	margin: 0 0 4px;
	line-height: 1.05;
}
.ss-hero h1 .ss-ai {
	font-size: .42em;
	vertical-align: super;
	color: var(--rose);
	font-weight: 700;
}
.ss-hero p {
	margin: 0;
	color: var(--plum-soft);
	font-weight: 500;
	font-size: clamp(13px, 3.4vw, 16px);
}
.ss-reward {
	display: inline-block;
	margin-top: 12px;
	background: var(--rose-soft);
	color: var(--rose);
	font-weight: 600;
	font-size: 13px;
	padding: 6px 14px;
	border-radius: 999px;
}

.ss-stage {
	background: var(--card);
	border: 1px solid var(--line);
	border-radius: var(--radius);
	box-shadow: var(--shadow);
	padding: 18px;
	margin: 16px 0;
}

.ss-frame {
	position: relative;
	width: 100%;
	aspect-ratio: 3 / 4;
	max-height: 480px;
	border-radius: 14px;
	overflow: hidden;
	background: #efe7e9 url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='80' height='80'%3E%3C/svg%3E");
	display: flex;
	align-items: center;
	justify-content: center;
}
.ss-frame video,
.ss-frame img,
.ss-frame canvas {
	width: 100%;
	height: 100%;
	object-fit: cover;
	display: block;
}
.ss-frame .ss-frame-hint {
	position: absolute;
	inset: 0;
	display: flex;
	flex-direction: column;
	gap: 8px;
	align-items: center;
	justify-content: center;
	color: var(--plum-soft);
	font-weight: 500;
	text-align: center;
	padding: 24px;
}
.ss-frame .ss-frame-hint svg { width: 46px; height: 46px; opacity: .55; }

/* khung ngắm mặt */
.ss-guide {
	position: absolute;
	inset: 12%;
	border: 2px dashed rgba(217, 106, 106, .6);
	border-radius: 50% / 42%;
	pointer-events: none;
}

.ss-actions {
	display: flex;
	gap: 10px;
	flex-wrap: wrap;
	justify-content: center;
	margin-top: 16px;
}
.ss-btn {
	appearance: none;
	border: 0;
	cursor: pointer;
	font-family: inherit;
	font-weight: 600;
	font-size: 15px;
	padding: 13px 22px;
	border-radius: 999px;
	transition: transform .12s ease, box-shadow .2s ease, background .2s;
	display: inline-flex;
	align-items: center;
	gap: 8px;
}
.ss-btn:active { transform: translateY(1px) scale(.99); }
.ss-btn-primary { background: var(--rose); color: #fff; box-shadow: 0 8px 20px -8px rgba(217, 106, 106, .8); }
.ss-btn-primary:hover { background: #cf5757; }
.ss-btn-ghost { background: #f6ecea; color: var(--plum); }
.ss-btn-ghost:hover { background: #efe0dd; }
.ss-btn-shutter {
	width: 66px; height: 66px; padding: 0; border-radius: 50%;
	background: var(--rose); color: #fff; justify-content: center;
	box-shadow: 0 0 0 4px #fff, 0 0 0 6px var(--rose);
}
.ss-btn-shutter svg { width: 26px; height: 26px; }
.ss-btn:disabled { opacity: .5; cursor: not-allowed; }

.ss-hidden { display: none !important; }

/* ---------- Loading ---------- */
.ss-loading { text-align: center; padding: 50px 20px; }
.ss-spinner {
	width: 52px; height: 52px; margin: 0 auto 18px;
	border: 4px solid var(--rose-soft);
	border-top-color: var(--rose);
	border-radius: 50%;
	animation: ss-spin .9s linear infinite;
}
@keyframes ss-spin { to { transform: rotate(360deg); } }
.ss-loading p { color: var(--plum-soft); font-weight: 500; margin: 0; }

/* ---------- Lỗi ---------- */
.ss-error {
	background: var(--rose-soft);
	color: #a23b3b;
	border-radius: 14px;
	padding: 16px 18px;
	margin: 14px 0;
	font-weight: 500;
}

/* ============================================================
   KẾT QUẢ
   ============================================================ */
.ss-result { margin-top: 8px; }

.ss-score-head { text-align: center; margin: 8px 0 18px; }
.ss-score-head .ss-score-label { color: var(--plum-soft); font-weight: 600; font-size: 15px; }
.ss-score-head .ss-score-big {
	font-size: clamp(40px, 10vw, 64px);
	font-weight: 800;
	color: var(--rose);
	line-height: 1;
	margin: 4px 0;
}
.ss-score-head .ss-score-big small { font-size: .4em; color: var(--muted); font-weight: 600; }
.ss-score-head .ss-score-tag { font-weight: 600; color: var(--plum); }

/* ảnh kết quả + chấm đánh dấu */
.ss-annot-wrap {
	position: relative;
	width: 100%;
	max-width: 420px;
	margin: 0 auto;
	border-radius: 14px;
	overflow: hidden;
	box-shadow: var(--shadow);
}
.ss-annot-wrap img { width: 100%; display: block; }
.ss-dot {
	position: absolute;
	width: 13px; height: 13px;
	border-radius: 2px;
	transform: translate(-50%, -50%);
	border: 2px solid #fff;
	background: transparent;
	box-shadow: 0 0 0 1px rgba(255, 255, 255, .85), 0 1px 3px rgba(0, 0, 0, .35);
}

.ss-legend {
	display: flex;
	flex-wrap: wrap;
	gap: 10px 18px;
	justify-content: center;
	margin: 16px 0 6px;
	font-size: 13px;
	color: var(--ink);
}
.ss-legend span { display: inline-flex; align-items: center; gap: 7px; }
.ss-legend i { width: 13px; height: 13px; border-radius: 2px; border: 2px solid #ccc; background: transparent; }

/* khối card chung */
.ss-card {
	background: var(--card);
	border: 1px solid var(--line);
	border-radius: var(--radius);
	padding: 18px 20px;
	margin: 14px 0;
	box-shadow: var(--shadow);
}
.ss-section-title {
	font-size: 13px;
	font-weight: 700;
	letter-spacing: .08em;
	text-transform: uppercase;
	color: var(--rose);
	margin: 26px 0 10px;
}

/* tổng quan tuổi/loại da/tone */
.ss-overview { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.ss-fact {
	background: #f7f0ee;
	border-radius: 14px;
	padding: 14px 16px;
}
.ss-fact .ss-fact-k { font-size: 12px; color: var(--muted); font-weight: 600; }
.ss-fact .ss-fact-v { font-size: 20px; font-weight: 700; color: var(--plum); }

/* tone màu */
.ss-tones { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 8px; }
.ss-tone-swatch { width: 52px; height: 52px; border-radius: 50%; box-shadow: inset 0 0 0 1px rgba(0,0,0,.08); }

/* thanh điểm */
.ss-metric { margin: 18px 0; }
.ss-metric-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.ss-metric-head b { color: var(--plum); }
.ss-metric-head .ss-metric-tag { font-weight: 600; color: var(--rose); font-size: 14px; }
.ss-metric .ss-bar {
	position: relative;
	height: 10px;
	border-radius: 999px;
	margin: 14px 0 6px;
	background: linear-gradient(90deg, #5fae8e 0%, #d7c24a 50%, #d96a6a 100%);
}
.ss-metric .ss-bar .ss-pin {
	position: absolute;
	top: 50%;
	width: 4px; height: 22px;
	background: var(--plum);
	border-radius: 3px;
	transform: translate(-50%, -50%);
}
.ss-metric .ss-bar .ss-pin::after {
	content: attr(data-score);
	position: absolute;
	top: -22px; left: 50%;
	transform: translateX(-50%);
	font-size: 11px; font-weight: 700; color: var(--plum);
	white-space: nowrap;
}
.ss-metric small { color: var(--muted); }
.ss-metric .ss-metric-detail { font-size: 14px; color: var(--ink); margin-top: 4px; }

/* chẩn đoán */
.ss-diagnosis h2 { color: var(--plum); font-size: 22px; margin: 0 0 12px; }
.ss-diagnosis p { margin: 0 0 12px; }
.ss-diagnosis strong { color: var(--plum); }

/* danh sách gợi ý */
.ss-list { margin: 6px 0 0; padding: 0; list-style: none; }
.ss-list li { padding: 8px 0; border-bottom: 1px dashed var(--line); }
.ss-list li:last-child { border-bottom: 0; }
.ss-list li b { color: var(--plum); }
.ss-group-title { font-weight: 700; color: var(--plum); margin: 14px 0 4px; }

/* lịch sử */
.ss-history-row {
	display: flex; justify-content: space-between; gap: 10px;
	padding: 8px 0; border-bottom: 1px dashed var(--line); font-size: 14px;
}
.ss-history-row:last-child { border-bottom: 0; }

/* chatbox */
.ss-chat .ss-chat-log { display: flex; flex-direction: column; gap: 10px; margin: 12px 0; }
.ss-bubble { padding: 11px 15px; border-radius: 16px; max-width: 88%; font-size: 14px; }
.ss-bubble-user { align-self: flex-end; background: var(--rose); color: #fff; border-bottom-right-radius: 5px; }
.ss-bubble-ai { align-self: flex-start; background: #f6ecea; color: var(--ink); border-bottom-left-radius: 5px; white-space: pre-wrap; }
.ss-suggests { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0; }
.ss-chip {
	background: #f6ecea; color: var(--plum); border: 1px solid var(--line);
	border-radius: 999px; padding: 7px 13px; font-size: 13px; cursor: pointer;
	font-family: inherit;
}
.ss-chip:hover { background: #efe0dd; }
.ss-chat-input { display: flex; gap: 8px; align-items: flex-end; }
.ss-chat-input textarea {
	flex: 1; resize: vertical; min-height: 48px; max-height: 140px;
	border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px;
	font-family: inherit; font-size: 14px; color: var(--ink); background: #fff;
}
.ss-chat-input textarea:focus { outline: 2px solid var(--rose-soft); border-color: var(--rose); }

/* nút liên hệ + miễn trừ */
.ss-cta-contact {
	display: block; text-align: center; text-decoration: none;
	background: linear-gradient(90deg, var(--rose), #b94fb6);
	color: #fff; font-weight: 700; padding: 15px; border-radius: 16px; margin: 18px 0;
}
.ss-disclaimer { text-align: center; font-size: 12px; color: var(--muted); margin: 16px 0 30px; }

.ss-restart { display: block; margin: 10px auto 0; }

/* Lịch sử soi da (localStorage) */
.ss-hist-wrap { max-width: 680px; margin: 18px auto 0; text-align: center; }
.ss-hist-toggle {
	background: #4a2f17;
	color: #f3e7d6;
	border: 1px solid #6b4322;
	border-radius: 8px;
	padding: 9px 20px;
	font-size: 14px; font-weight: 600;
	font-family: inherit; cursor: pointer;
}
.ss-hist-toggle:hover { background: #5a3a1d; }
.ss-hist-panel {
	margin: 12px auto 0;
	background: #fff;
	border: 1px solid var(--ss-line, #ece4e1);
	border-radius: 14px;
	padding: 8px;
	box-shadow: 0 10px 30px -16px rgba(0,0,0,.3);
	text-align: left;
}
.ss-hist-row {
	display: flex; justify-content: space-between; align-items: center; gap: 10px;
	width: 100%;
	background: #faf7f5;
	border: 1px solid var(--ss-line, #ece4e1);
	border-radius: 10px;
	padding: 11px 14px;
	margin-bottom: 6px;
	font-family: inherit; font-size: 14px; color: var(--ss-ink, #2c2230);
	cursor: pointer; text-align: left;
}
.ss-hist-row:hover { border-color: var(--ss-rose, #d96a6a); background: #fff; }
.ss-hist-date { color: var(--ss-muted, #8a7d86); font-size: 13px; }
.ss-hist-score b { color: var(--ss-rose, #d96a6a); }
.ss-hist-clear {
	display: block; width: 100%;
	background: none; border: 0; color: #b23b3b;
	font-family: inherit; font-size: 13px; cursor: pointer;
	padding: 8px; margin-top: 2px;
}
.ss-hist-clear:hover { text-decoration: underline; }
.ss-hist-note { text-align: center; font-size: 12px; color: var(--ss-muted, #8a7d86); padding: 2px 0 6px; }

/* responsive */
@media (max-width: 480px) {
	.ss-stage { padding: 12px; }
	.ss-card { padding: 16px; }
}

/* tôn trọng reduced motion */
@media (prefers-reduced-motion: reduce) {
	.ss-spinner { animation-duration: 2.2s; }
	.ss-btn { transition: none; }
}
