/* ===== TITV Tools – giao diện dùng chung cho mọi công cụ ===== */
:root {
    --bg: #f4f5f7;
    --card: #ffffff;
    --text: #1d2330;
    --muted: #667085;
    --line: #e4e7ec;
    --accent: #1f5eff;
    --accent-dark: #1749cc;
    --accent-soft: #eaf0ff;
    --error: #c0362c;
    --warn: #b26a00;
    --radius: 12px;
    --container: 1040px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
    margin: 0;
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

a { color: var(--accent); }
h1, h2, h3 { line-height: 1.25; letter-spacing: -0.01em; }

.container { width: 100%; max-width: var(--container); margin: 0 auto; padding: 0 20px; }
.container.wide { max-width: 1240px; }
main.container { flex: 1; padding-top: 24px; padding-bottom: 48px; }

/* Header / footer */
.site-header { background: #fff; border-bottom: 1px solid var(--line); }
.header-inner { display: flex; align-items: center; justify-content: space-between; height: 60px; }
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); text-decoration: none; font-weight: 700; font-size: 1.1rem; }
.site-nav a { color: var(--muted); text-decoration: none; font-weight: 500; }
.site-nav a:hover, .site-nav a[aria-current] { color: var(--text); }
.site-footer { border-top: 1px solid var(--line); background: #fff; color: var(--muted); font-size: .875rem; }
.site-footer p { margin: 18px 0; text-align: center; }
.site-footer a { color: inherit; }

/* Tiêu đề trang công cụ */
.breadcrumb { font-size: .875rem; color: var(--muted); display: flex; gap: 8px; margin-bottom: 8px; }
.breadcrumb a { color: var(--muted); text-decoration: none; }
.breadcrumb a:hover { color: var(--accent); }
.page-head h1 { margin: 0 0 4px; font-size: 1.8rem; }
.lead { margin: 0 0 24px; color: var(--muted); }

/* Trang chủ */
.hero { text-align: center; padding: 24px 0 12px; }
.hero h1 { font-size: 2.2rem; margin: 0 0 6px; }
.search { max-width: 520px; margin: 0 auto 12px; }
.search input { width: 100%; padding: 13px 16px; font-size: 1rem; border-radius: 999px; }
.category h2 { font-size: 1.05rem; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; margin: 28px 0 12px; }

.tool-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px; }
.tool-grid.compact { grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 10px; }
.tool-card {
    display: flex; gap: 14px; align-items: flex-start;
    background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
    padding: 16px; color: var(--text); text-decoration: none;
    transition: border-color .15s, box-shadow .15s, transform .15s;
}
.tool-card:hover { border-color: var(--accent); box-shadow: 0 4px 16px rgba(31, 94, 255, .08); transform: translateY(-1px); }
.tool-grid.compact .tool-card { padding: 12px 14px; }
.tool-icon {
    flex: none; width: 44px; height: 44px; border-radius: 10px;
    display: grid; place-items: center;
    background: var(--accent-soft); color: var(--accent); font-weight: 700; font-size: 1.2rem;
}
.tool-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.tool-name { font-weight: 600; }
.tool-desc { color: var(--muted); font-size: .9rem; }
.badge { font-style: normal; font-size: .7rem; background: #e6f6ec; color: #18794e; padding: 1px 6px; border-radius: 4px; vertical-align: middle; }
.empty { text-align: center; color: var(--muted); padding: 32px 0; }

.related { margin-top: 40px; }
.related h2 { font-size: 1.05rem; margin: 0 0 12px; }

/* Thành phần dùng chung cho các công cụ */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; }
.grid-2 { display: grid; grid-template-columns: 1.2fr 1fr; gap: 20px; }
@media (max-width: 760px) { .grid-2 { grid-template-columns: 1fr; } }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }

label { display: block; font-weight: 600; font-size: .9rem; margin: 14px 0 6px; }
label:first-child { margin-top: 0; }
input[type=text], input[type=search], input[type=url], input[type=number], select, textarea {
    width: 100%; padding: 11px 12px;
    border: 1px solid var(--line); border-radius: 8px;
    font: inherit; background: #fff; color: inherit;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: transparent; }
input[type=range] { width: 100%; accent-color: var(--accent); }
input[type=color] { width: 100%; height: 42px; padding: 3px; border: 1px solid var(--line); border-radius: 8px; background: #fff; cursor: pointer; }

.btn, button {
    display: inline-flex; align-items: center; justify-content: center;
    padding: 10px 16px; border-radius: 8px;
    border: 1px solid var(--line); background: #fff; color: var(--text);
    font: inherit; font-weight: 600; text-decoration: none; cursor: pointer;
}
.btn:hover, button:hover { border-color: #c5cad3; }
.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.primary:hover { background: var(--accent-dark); border-color: var(--accent-dark); }
.btn-block { width: 100%; margin-top: 20px; padding: 12px; font-size: 1rem; }

.error { color: var(--error); margin: 6px 0 0; font-size: .9rem; }
.hint { color: var(--warn); font-size: .85rem; margin: 8px 0 0; }
.muted { color: var(--muted); }

/* Tài khoản & menu người dùng */
.site-nav { display: flex; align-items: center; gap: 18px; }
.btn-sm { padding: 6px 12px; font-size: .9rem; }
.site-nav a.btn-sm { color: var(--text); }
.user-menu { position: relative; }
.user-menu summary { list-style: none; display: flex; align-items: center; gap: 8px; cursor: pointer; font-weight: 500; }
.user-menu summary::-webkit-details-marker { display: none; }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--accent); color: #fff; display: grid; place-items: center; font-weight: 700; font-size: .9rem; }
.user-pop { position: absolute; right: 0; top: calc(100% + 8px); background: #fff; border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 10px 30px rgba(0,0,0,.1); padding: 10px; min-width: 220px; z-index: 50; display: grid; gap: 4px; }
.user-pop a, .user-pop button { display: block; width: 100%; text-align: left; padding: 8px 10px; border: 0; border-radius: 6px; background: none; color: var(--text); font-weight: 500; text-decoration: none; }
.user-pop a:hover, .user-pop button:hover { background: var(--bg); }
.user-pop .muted { padding: 4px 10px 8px; border-bottom: 1px solid var(--line); margin-bottom: 4px; overflow-wrap: anywhere; }
@media (max-width: 560px) { .user-name { display: none; } }
.small { font-size: .85rem; }

.container.narrow { max-width: 460px; }
.auth h1 { margin: 0 0 4px; font-size: 1.6rem; }
.auth .lead { margin-bottom: 18px; }
.auth input[type=email], .auth input[type=password] { width: 100%; padding: 11px 12px; border: 1px solid var(--line); border-radius: 8px; font: inherit; }
.auth .check { display: flex; gap: 8px; align-items: center; font-weight: 400; margin-top: 14px; }
.auth .links { display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-top: 16px; font-size: .9rem; }
.notice { background: #ecfdf3; color: #067647; border: 1px solid #abefc6; border-radius: 8px; padding: 10px 12px; margin-bottom: 14px; font-size: .92rem; }
.alert { background: #fef3f2; color: var(--error); border: 1px solid #fecdca; border-radius: 8px; padding: 10px 12px; margin-bottom: 14px; font-size: .92rem; }
.table { width: 100%; border-collapse: collapse; margin: 12px 0; }
.table th, .table td { text-align: left; padding: 8px; border-bottom: 1px solid var(--line); font-size: .92rem; }

/* Trình cài đặt */
.container.narrow:has(.install) { max-width: 560px; }
.install-steps { display: flex; gap: 6px; margin-bottom: 18px; font-size: .8rem; flex-wrap: wrap; }
.install-steps span { padding: 4px 10px; border-radius: 999px; background: var(--bg); color: var(--muted); }
.install-steps .on { background: var(--accent); color: #fff; }
.install-steps .ok { background: #ecfdf3; color: #067647; }
.install-req { list-style: none; padding: 0; margin: 0 0 18px; display: grid; gap: 4px; font-size: .9rem; }
.install-req .ok { color: #067647; }
.install-req .warn { color: var(--warn); }
.install-req .bad { color: var(--error); font-weight: 600; }
.install-row { grid-template-columns: 1fr 120px; }
.install-h2 { font-size: 1rem; margin: 22px 0 0; padding-top: 14px; border-top: 1px solid var(--line); }
.install-code { width: 100%; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: .8rem; padding: 10px; border: 1px solid var(--line); border-radius: 8px; background: #f8fafc; }

/* ===== Toàn màn hình dùng chung ===== */
.fs-only { display: none !important; }
.fs-on .fs-only { display: inline-block !important; }
.fs-on .fs-hide { display: none !important; }
.fs-stage.fs-on {
    width: 100vw; height: 100vh; max-width: none; margin: 0;
    border: 0; border-radius: 0; box-shadow: none;
    background: #fff; overflow: auto;
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2vh;
}
.fs-stage.fs-pseudo { position: fixed !important; inset: 0; z-index: 2000; height: 100dvh; }
.fs-stage:fullscreen { width: 100vw; height: 100vh; }
.fs-stage::backdrop { background: #fff; }
html.fs-lock, html.fs-lock body { overflow: hidden; }
.fs-on .fs-qr { width: min(82vh, 92vw) !important; height: auto !important; max-width: none !important; aspect-ratio: 1; border: 0 !important; }
.fs-exit {
    position: absolute; top: 14px; right: 14px; width: 44px; height: 44px; padding: 0;
    border-radius: 50%; border: 1px solid var(--line); background: #fff; color: var(--text);
    font-size: 1.2rem; line-height: 1; z-index: 5; opacity: .6;
}
.fs-exit:hover { opacity: 1; }
.fs-stage { position: relative; }
.fs-qr { cursor: zoom-in; }
.fs-on .fs-qr { cursor: zoom-out; }

/* Đầu trang trên điện thoại */
.brand span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.site-nav a, .site-nav .btn-sm { white-space: nowrap; }
@media (max-width: 560px) {
    .header-inner { gap: 10px; }
    .brand { min-width: 0; font-size: 1rem; }
    .site-nav { gap: 10px; }
    .site-nav > a:first-child { display: none; }
}
