/* ============ My Bonsai Web – CSS (perf tuned) ================= */

:root{
  --bg:#e3d4ae;
  --ink:#1f1b16;
  --muted:#776b5a;
  --brand:#c60000;
  --surface:#fff7e1;
  --btn:#2f6f3e;
  --btn-ghost:#cabd9b;
  --shadow:0 6px 20px rgba(0,0,0,.12);
}

*{box-sizing:border-box;}
html,body{
  height:100%;
  overscroll-behavior-y: auto;
}
body{
  margin:0;
  background:var(--bg);
  font-family:system-ui,-apple-system,Segoe UI,Roboto,sans-serif;
  color:var(--ink);
  -webkit-font-smoothing:antialiased;
  -moz-osx-font-smoothing:grayscale;
}

/* Prevent accidental text selection on mobile & remove tap highlight globally */
* {
  -webkit-user-select: none;
  -ms-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: rgba(0,0,0,0);
}

/* screen container */
.screen{
  max-width:980px;
  margin:0 auto;
  padding:16px 16px 32px;
}
[aria-hidden="true"]{display:none}

/* Logo */
.brand{
  display:flex; gap:.3rem;
  font-size:40px; font-weight:800;
  margin-bottom:20px;
}
.brand-mark{color:var(--brand); font-family:"Brush Script MT", cursive;}
.brand-name{}

/* Quảng cáo */
.ad-card{
  display:flex; gap:16px; align-items:center;
  background:var(--surface);
  padding:16px; border-radius:16px;
  box-shadow:var(--shadow);
}
.ad-art{
  flex:1; min-height:120px;
  display:grid; place-items:center;
  border:2px dashed #b9cbe0;
  border-radius:12px;
  font-weight:700;
}

/* Buttons */
.btn{border:0; cursor:pointer; padding:12px 16px; border-radius:12px; font-weight:600;}
.btn-big{
  flex:1; background:#2a2a2a; color:white;
  display:flex; align-items:center; justify-content:center; gap:10px;
}
.btn-download{background:#1a7bd9; color:white;}
.btn-wide{width:100%; background:#263d7a; color:white;}
.btn-pill{flex:1; border-radius:999px; background:var(--btn); color:white;}
.btn-pill.flag{background:#8c7300;}
.btn-pill.ghost{background:var(--btn-ghost); color:black;}
.icon-left .icon{font-size:20px;}

.actions .row{display:flex; gap:16px; margin:16px 0;}

/* Editor layout */
.toolbar{
  display:flex; justify-content:space-between; align-items:center;
  background:#434343; padding:8px 12px; border-radius:12px; color:white;
}
.tool{background:none; border:0; color:white; font-size:16px; cursor:pointer;}
.tool.danger{color:#ffb3b3;}

.editor{
  margin-top:16px;
  display:grid;
  grid-template-columns:1fr 280px;
  gap:16px;
  height: calc(100vh - 80px);
  overflow: hidden;
}


/* Canvas */
.canvas-wrap{
  background:#111; padding:8px;
  border-radius:12px; box-shadow:var(--shadow);
  display:flex; justify-content:center; align-items:center;
  min-height: 0;
}
#canvas{
  background:#222;
  border-radius:8px;
  max-width:100%;
  height:auto;
  cursor:default;
  touch-action: none;
  -ms-touch-action: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: auto;
}

/* Sidebar */
.sidebar{
  background:white;
  border-radius:12px;
  padding:10px;
  box-shadow:var(--shadow);
  display:flex;
  flex-direction:column;
  height:100%;
  overflow: hidden;
}

.sidebar-head{
  display:flex; justify-content:space-between; align-items:center;
  font-weight:700; margin-bottom:8px;
}
.tiny{
  padding:4px 8px; font-size:12px; border:1px solid #ddd; border-radius:8px;
  background:#fafafa; cursor:pointer;
}

/* Sticker list */
.thumbs{
  display:grid; gap:10px;
  grid-template-columns:repeat(2,1fr);
  overflow:auto;
  flex:1 1 auto;
  content-visibility:auto;
  contain-intrinsic-block-size: 800px;
}
.thumb{
  background:#f0f0f0; border:1px solid #ccc;
  border-radius:10px; padding:8px;
  display:grid; place-items:center;
  aspect-ratio:1.2/1;
  cursor:pointer;
  transition:transform .08s ease;
  -webkit-tap-highlight-color: transparent;
}
.thumb:active{ transform:scale(.98); }
.thumb img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

/* Hint cố định */
.hint{
  flex:0 0 auto;
  margin-top:10px;
  padding:8px; background:#f5f5f5;
  font-size:12px; color:#666;
  border-top:1px solid #eee;
}

/* Mobile tối thiểu */
@media(max-width:880px){
  .editor{grid-template-columns:1fr;}
  .sidebar{order:-1;}
}
#thumbs-chi {
  grid-template-columns: 1fr !important;
}
#thumbs-chi, #thumbs-chau, #thumbs-cay {
  max-height: calc(100vh - 140px);
  overflow-y: auto;
  padding-right: 4px;
}
#thumbs-chi, #thumbs-chau, #thumbs-cay {
  flex: 1 1 auto;
  min-height: 0;
}
#thumbs-khac {
  max-height: calc(100vh - 140px);
  overflow-y: auto;
  padding-right: 4px;
  flex: 1 1 auto;
  min-height: 0;
}

/* Hàng nút cuộn */
.scroll-row {
  display: flex;
  gap: 8px;
  margin: 8px 0 10px;
  position: sticky;
  top: 0;
  padding: 6px 0;
  background: rgba(245, 240, 230, 0.9);
  z-index: 5;
  border-radius: 10px;
}

.scroll-btn {
  padding: 6px 10px;
  border: 1px solid #b8a98a;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 600;
  min-width: 42px;
}
.scroll-btn:hover { filter: brightness(0.95); }

/* Layout fixes */
.canvas-wrap,
.sidebar {
  min-height: 0;
}
.canvas-wrap {
  height: 100%;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}
#canvas {
  height: 100%;
  width: auto;
  max-height: 100%;
  max-width: 100%;
}

/* Tabs */
.tabs {
  display: grid !important;
  grid-template-columns: repeat(2, 1fr);
  gap: 6px;
}
.tab {
  font-size: 13px;
  padding: 6px 4px;
  border: 1px solid #bbb;
  border-radius: 10px;
  background: #f9f9f9;
  cursor: pointer;
}
.tab.active {
  background: white;
  border-color: #777;
  font-weight: 650;
  box-shadow: 0 2px 6px rgba(0,0,0,0.15);
}

/* Thumbs style overrides */
.thumb{
    width:66.666%;
    margin:8px auto;
    padding:10px;
    border:1px solid #ddd;
    border-radius:16px;
    background:#fff;
    aspect-ratio:auto !important;
    max-height:none !important;
    overflow:visible !important;
    display:flex;
    justify-content:center;
    align-items:center;
}
.thumb img{
    display:block;
    max-width:100%;
    width:100%;
    height:auto;
    object-fit:contain;
}

/* Mobile adjustments */
@media (max-width: 880px) {
  .editor {
    grid-template-columns: 1fr;
    gap: 12px;
    height: auto;
    min-height: 100vh;
  }
  .canvas-wrap {
    order: 0;
    width: 100%;
    min-height: 320px;
    height: auto;
    align-self: stretch;
    margin-bottom: 12px;
  }
  .sidebar {
    order: 1;
    width: 100%;
    height: auto;
    min-height: 0;
    max-height: none;
    overflow: visible;
    padding: 10px;
  }
  #canvas {
    width: 100%;
    height: auto;
    max-height: 60vh;
    display: block;
  }
  .tabs {
    grid-template-columns: repeat(2, 1fr);
  }
  .thumb {
    width: 100%;
    margin: 8px 0;
  }
  .scroll-row {
    position: sticky;
    top: 0;
    background: rgba(245,240,230,0.95);
    z-index: 6;
  }
}

/* Button camera icon layout */
#btn-camera {
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center;
  gap: 8px;
  vertical-align: middle;
  padding: 10px 16px;
}
#btn-camera .icon {
  display: inline-flex !important;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  font-size: 20px;
  line-height: 1;
  vertical-align: middle;
  margin: 0;
  padding: 0;
}
#btn-camera > span,
#btn-camera > span > span,
#btn-camera .btn-text {
  display: inline-flex;
  align-items: center;
  line-height: 1;
  vertical-align: middle;
}
#btn-camera img.icon, #btn-camera img {
  width: 28px;
  height: 28px;
  object-fit: contain;
  display: inline-block;
  vertical-align: middle;
}

/* Language selector styling */
.lang-wrap { margin-left:12px; }
#lang-select {
  border-radius:10px;
  padding:6px 8px;
  border:1px solid #cfcfcf;
  background:white;
  font-weight:600;
  cursor:pointer;
}

/* Flags */
.lang-flags {
  display: flex;
  gap: 8px;
  margin-left: 0;
  align-items: center;
}
.flag-btn {
  width: 32px;
  height: 22px;
  object-fit: cover;
  border-radius: 4px;
  cursor: pointer;
  border: 2px solid transparent;
  transition: transform .15s ease, border-color .15s ease;
}
.flag-btn:hover { transform: scale(1.07); }
.flag-btn.active { border-color: red; }

/* Visually-hidden for sr-only label */
.sr-only {
  position: absolute !important;
  height: 1px; width: 1px;
  overflow: hidden; clip: rect(1px, 1px, 1px, 1px);
  white-space: nowrap; border: 0; padding: 0; margin: -1px;
}
