* { box-sizing: border-box; }
:root {
    color-scheme: light;
    --paper: #f7f5ef;
    --card: #fffefb;
    --ink: #262435;
    --muted: #625c6c;
    --line: #e6e0e6;
    --accent: #5b36a5;
    --dark: #392264;
    --wash: #eee7fa;
    font-family: "Leelawadee UI", "Noto Sans Thai", Tahoma, sans-serif;
}
[hidden] { display: none !important; }
body { margin: 0; color: var(--ink); background: var(--paper); line-height: 1.6; }
a { color: var(--accent); }
button, input, select { font: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid #936bd0; outline-offset: 3px; }
.wrap { width: min(950px, calc(100% - 48px)); margin-inline: auto; }
.top { background: var(--card); border-bottom: 1px solid var(--line); }
.top-row { display: flex; align-items: center; justify-content: space-between; min-height: 76px; gap: 12px; }
.brand { display: inline-flex; align-items: center; gap: 11px; color: var(--ink); text-decoration: none; font-size: 1.2rem; font-weight: 750; line-height: 1.2; }
.brand strong { color: var(--accent); }
.brand small { display: block; color: var(--muted); font-size: .72rem; font-weight: 500; margin-top: 3px; }
.brand-logo {
    display: block;
    flex: 0 0 auto;
    width: auto;
    height: auto;
    max-width: clamp(64px, 12vw, 110px);
    max-height: clamp(34px, 6vw, 48px);
    object-fit: contain;
}
nav { display: flex; gap: clamp(10px, 3vw, 30px); align-items: center; }
nav a { color: var(--dark); font-weight: 700; text-decoration: none; }
nav a:hover { text-decoration: underline; }
.hero { margin-block: 34px 20px; border-radius: 27px; background: #eae2f8; display: grid; grid-template-columns: minmax(0, 1fr) 220px; align-items: center; gap: 16px; overflow: hidden; padding: clamp(25px, 5vw, 48px); }
.eyebrow { font-size: .83rem; font-weight: 750; color: var(--dark); margin: 0 0 8px; }
.eyebrow span { display: inline-block; width: 8px; height: 8px; background: var(--accent); border-radius: 50%; margin-right: 5px; }
h1, h2, h3 { margin: 0; line-height: 1.25; }
h1 { font-size: clamp(2.6rem, 7vw, 4.75rem); letter-spacing: -.04em; }
.hero-art { display: block; width: 100%; height: auto; }
h1 em { color: var(--accent); font-style: normal; white-space: nowrap; }
.hero p:last-child { color: var(--dark); margin: 12px 0 0; max-width: 47ch; }
.panel { margin-block: 18px; padding: clamp(20px, 4vw, 34px); background: var(--card); border: 1px solid var(--line); border-radius: 22px; box-shadow: 0 4px 20px #37245d08; scroll-margin-top: 16px; }
.panel h2 { font-size: 1.55rem; margin-bottom: 18px; }
.mode { border: 0; padding: 0; margin: 0 0 18px; display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.sr-only, .mode input, .copy-input { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip-path: inset(50%); }
.mode span { display: block; padding: 10px 13px; border: 1px solid var(--line); border-radius: 12px; cursor: pointer; text-align: center; font-weight: 700; }
.mode b { margin-right: 5px; }
.mode input:checked + span { background: var(--wash); color: var(--dark); border-color: #ae94d4; }
.mode input:focus-visible + span { outline: 3px solid #936bd0; outline-offset: 2px; }
.field { display: block; margin: 0 0 15px; font-weight: 700; }
.field small { margin-left: 6px; color: var(--muted); font-weight: 400; }
input:not([type=radio]), select { width: 100%; min-width: 0; color: var(--ink); background: #fcfafc; border: 1px solid #d9d2df; border-radius: 10px; padding: 10px 12px; min-height: 46px; }
input::placeholder { color: #777080; opacity: 1; }
.field input { display: block; margin-top: 5px; }
.grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.form-end, .dialog-head { display: flex; justify-content: space-between; align-items: center; gap: 14px; }
.form-end > span { color: var(--muted); font-size: .88rem; }
.primary, .secondary, .danger { border: 1px solid transparent; padding: 8px 14px; border-radius: 10px; font-weight: 700; min-height: 44px; display: inline-flex; align-items: center; justify-content: center; gap: 10px; text-decoration: none; }
.primary { background: var(--accent); color: white; }
.primary:hover { background: var(--dark); }
.secondary { border-color: #dcd0ed; background: #f7f2fd; color: var(--dark); }
.secondary:hover { background: var(--wash); }
.danger { border-color: #f4d3d9; background: #fff3f4; color: #8e2741; }
.danger:hover { background: #fce3e7; }
.search { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; gap: 9px; margin-bottom: 14px; }
.empty { padding: 28px 12px; text-align: center; background: #faf7fc; color: var(--muted); border-radius: 12px; }
.entry { display: flex; justify-content: space-between; align-items: center; gap: 15px; padding: 15px 0; border-bottom: 1px solid var(--line); }
.entry-info { min-width: 0; }
.entry h3 { font-size: 1.1rem; overflow-wrap: anywhere; }
.entry p { font-size: .88rem; color: var(--muted); margin: 4px 0; overflow-wrap: anywhere; }
.badge { display: inline-block; background: var(--wash); color: var(--dark); padding: 2px 7px; border-radius: 5px; font-size: .69rem; font-weight: 800; margin-bottom: 5px; }
.url, code { overflow-wrap: anywhere; }
.destination { display: block; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.actions { display: flex; flex-wrap: wrap; gap: 7px; align-items: center; }
.entry .actions { flex-shrink: 0; }
.pages { justify-content: center; margin-top: 16px; }
.alert { padding: 12px 16px; border-radius: 12px; background: #e5f5e9; color: #215731; }
.error { background: #ffedf0; color: #8e2741; }
dialog { width: min(440px, calc(100% - 32px)); border: 1px solid var(--line); border-radius: 20px; padding: 20px; background: var(--card); color: var(--ink); }
dialog::backdrop { background: #21153299; }
.qr-box { display: grid; justify-items: center; padding-top: 10px; gap: 10px; }
.qr-image { width: min(100%, 250px); aspect-ratio: 1; height: auto; border: 1px solid var(--line); }
.toast { position: fixed; inset: auto 20px 20px auto; padding: 10px 16px; border-radius: 8px; background: var(--dark); color: white; }
footer { text-align: center; padding: 15px 0 26px; font-size: .84rem; color: var(--muted); }
@media (max-width: 670px) {
    .wrap { width: calc(100% - 28px); }
    .hero { grid-template-columns: minmax(0, 1fr); margin-top: 18px; }
    .hero-art { display: none; }
    .entry { align-items: flex-start; flex-direction: column; }
    .entry-info { max-width: 100%; }
}
@media (max-width: 470px) {
    .top-row { min-height: 68px; }
    .top nav { font-size: .83rem; }
    .brand { font-size: 1rem; gap: 6px; }
    .brand small { font-size: .63rem; }
    .grid { grid-template-columns: 1fr; gap: 0; }
    .search { grid-template-columns: 1fr auto; }
    .search input { grid-column: 1 / -1; }
    .form-end { align-items: stretch; flex-direction: column; }
}