/* Tashub AI — palette and geometry come from the logo: teal ground, white and amber blocks,
   45° chamfered corners. The chamfer is the one recurring shape; everything else stays flat. */
:root {
  --night: #0C221E;      /* page ground */
  --night-2: #091B18;    /* sidebar */
  --deep: #12302A;       /* raised panels */
  --deep-2: #18403A;     /* hover / user bubble */
  --teal: #3F786C;       /* brand */
  --amber: #F6BA5E;
  --chalk: #F1F5F2;
  --mist: #93B5AB;
  --ink: #12302A;        /* text on chalk / amber blocks */
  --line: rgba(241, 245, 242, 0.11);
  --line-strong: rgba(241, 245, 242, 0.22);
  --ok: #7FD1A8;
  --bad: #FF8A7A;

  --chamfer: 14px;
  --font-latin: "Chakra Petch", "Noto Sans Georgian", system-ui, sans-serif;
  --font-ka: "Noto Sans Georgian", "Chakra Petch", system-ui, sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--night);
  color: var(--chalk);
  font-family: var(--font-ka);
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
button { font: inherit; color: inherit; }
a { color: var(--amber); text-underline-offset: 3px; text-decoration-thickness: 1px; }
:focus-visible { outline: 2px solid var(--amber); outline-offset: 2px; }
.num, .ex-code, .h-code { font-family: var(--font-latin); font-variant-numeric: tabular-nums; }

.app {
  display: grid;
  grid-template-columns: 264px minmax(0, 1fr) minmax(380px, 580px);
  height: 100dvh;
  overflow: hidden;
}

/* ---------- sidebar ---------- */
.sidebar {
  background: var(--night-2);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  min-width: 0;
  padding: 18px 14px 12px;
}
.brand { display: flex; align-items: center; gap: 12px; color: var(--chalk); text-decoration: none; padding: 2px 6px 18px; }
.brand-mark { width: 30px; height: 30px; flex: none; }
.brand-name { font-family: var(--font-latin); font-weight: 600; font-size: 19px; letter-spacing: 0.01em; }
.new-chat {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 10px 14px; border: 0; cursor: pointer; font-weight: 500;
  background: var(--deep); color: var(--chalk);
  clip-path: polygon(10px 0, 100% 0, 100% 100%, 0 100%, 0 10px);
}
.new-chat:hover { background: var(--deep-2); }
.history-title { font-size: 12.5px; font-weight: 500; color: var(--mist); margin: 22px 8px 6px; }
.history { flex: 1; overflow-y: auto; display: flex; flex-direction: column; }
.history button {
  text-align: left; background: none; border: 0; cursor: pointer;
  padding: 8px 10px 8px 12px; display: flex; flex-direction: column; line-height: 1.35;
  border-left: 2px solid transparent;
}
.history button:hover { background: var(--deep); }
.history button.active { border-left-color: var(--amber); background: var(--deep); }
.history .h-code { font-size: 14px; }
.history .h-sub { font-size: 12px; color: var(--mist); }
.history .h-empty { color: var(--mist); font-size: 13px; padding: 4px 12px; margin: 0; }
.sidebar-foot { border-top: 1px solid var(--line); padding: 12px 6px 0; font-size: 12px; color: var(--mist); }
.sidebar-foot p { margin: 0 0 6px; }
.sidebar-foot a { color: var(--mist); }

/* ---------- map ---------- */
.map-panel { position: relative; display: flex; flex-direction: column; min-width: 0; border-right: 1px solid var(--line); }
.topbar {
  height: 56px; flex: none; display: flex; align-items: center; gap: 12px;
  padding: 0 14px; border-bottom: 1px solid var(--line); background: var(--night);
}
.topbar-mark { display: none; width: 24px; height: 24px; flex: none; }
.topbar-title { font-family: var(--font-latin); font-weight: 500; font-size: 15px; color: var(--chalk); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.icon-btn { display: none; border: 0; background: none; padding: 6px; cursor: pointer; color: var(--chalk); }
.icon-btn:hover { background: var(--deep); }
.layer-toggle { margin-left: auto; display: flex; gap: 2px; background: var(--deep); padding: 3px; clip-path: polygon(8px 0, 100% 0, 100% calc(100% - 8px), calc(100% - 8px) 100%, 0 100%, 0 8px); }
.layer-toggle button { border: 0; background: none; padding: 4px 12px; cursor: pointer; font-size: 13px; color: var(--mist); }
.layer-toggle button.active { background: var(--teal); color: var(--chalk); }

.map { flex: 1; min-height: 0; background: var(--night); }
.leaflet-container { font-family: var(--font-ka); background: var(--night); }
/* Light OSM tiles → night teal: invert, then pull the hue toward the brand teal. */
.map .tiles-dark { filter: invert(1) hue-rotate(180deg) sepia(0.45) hue-rotate(118deg) saturate(0.75) brightness(0.78) contrast(1.05); }
.leaflet-bar { border: 0 !important; box-shadow: none !important; }
.leaflet-bar a {
  background: var(--deep) !important; color: var(--chalk) !important; border: 0 !important;
  border-bottom: 1px solid var(--line) !important; width: 32px !important; height: 32px !important; line-height: 32px !important;
}
.leaflet-bar a:hover { background: var(--deep-2) !important; }
.leaflet-control-attribution { background: rgba(9, 27, 24, 0.82) !important; color: var(--mist) !important; font-size: 10.5px; }
.leaflet-control-attribution a { color: var(--mist) !important; }
.leaflet-tooltip { background: var(--deep); color: var(--chalk); border: 0; border-radius: 0; box-shadow: none; font-family: var(--font-latin); }
.leaflet-tooltip::before { display: none; }

/* ---------- parcel plate: the logo's five blocks ---------- */
.plate-wrap { position: absolute; left: 18px; bottom: 18px; z-index: 500; width: min(372px, calc(100% - 36px)); }
.plate-wrap[hidden] { display: none; }
.plate {
  --c: 22px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  filter: drop-shadow(0 18px 30px rgba(3, 12, 10, 0.55));
}
.plate { cursor: pointer; }
.plate:focus-visible { outline: 2px solid var(--amber); outline-offset: 4px; }
/* Collapsed: only the top pair of blocks, the lower corners close the shape. */
.plate.collapsed .blk-mid, .plate.collapsed .blk-bl, .plate.collapsed .blk-br { display: none; }
.plate.collapsed .blk-tl { clip-path: polygon(var(--c) 0, 100% 0, 100% 100%, var(--c) 100%, 0 calc(100% - var(--c)), 0 var(--c)); }
.plate.collapsed .blk-tr { clip-path: polygon(0 0, calc(100% - var(--c)) 0, 100% var(--c), 100% calc(100% - var(--c)), calc(100% - var(--c)) 100%, 0 100%); }
.blk { color: var(--ink); padding: 12px 16px 13px; min-width: 0; }
.blk .v { font-family: var(--font-latin); font-weight: 600; font-size: 26px; line-height: 1.1; font-variant-numeric: tabular-nums; }
.blk .v small { font-size: 15px; font-weight: 500; }
.blk .l { font-size: 12px; line-height: 1.35; color: rgba(18, 48, 42, 0.72); margin-top: 3px; }
.blk-tl { background: var(--amber); clip-path: polygon(var(--c) 0, 100% 0, 100% 100%, 0 100%, 0 var(--c)); padding-left: 22px; }
.blk-tr { background: var(--chalk); clip-path: polygon(0 0, calc(100% - var(--c)) 0, 100% var(--c), 100% 100%, 0 100%); }
.blk-mid { background: var(--chalk); grid-column: 1 / -1; display: grid; grid-template-columns: repeat(3, 1fr); gap: 0; padding: 0; }
.blk-mid > div { padding: 11px 16px 12px; }
.blk-mid > div + div { border-left: 1px solid rgba(18, 48, 42, 0.14); }
.blk-mid .v { font-size: 22px; }
.blk-bl { background: var(--chalk); clip-path: polygon(0 0, 100% 0, 100% 100%, var(--c) 100%, 0 calc(100% - var(--c))); padding-left: 22px; }
.blk-br { background: var(--amber); clip-path: polygon(0 0, 100% 0, 100% calc(100% - var(--c)), calc(100% - var(--c)) 100%, 0 100%); }
.blk-tl .zone-name { font-family: var(--font-ka); font-size: 12px; font-weight: 500; }
.blk-tl .zone-more { font-family: var(--font-latin); font-size: 12.5px; font-weight: 600; margin-top: 2px; }
.plate-status {
  display: inline-block; margin-bottom: 6px; padding: 5px 14px 6px 12px;
  font-weight: 600; font-size: 13.5px; border-left: 3px solid currentColor;
  clip-path: polygon(0 0, calc(100% - 9px) 0, 100% 9px, 100% 100%, 0 100%);
}
.plate-status.v-allowed { background: var(--teal); color: var(--chalk); }
.plate-status.v-conditional, .plate-status.v-partial, .plate-status.v-limited { background: var(--amber); color: var(--ink); }
.plate-status.v-not_allowed { background: #B5473A; color: var(--chalk); }
.plate-status.v-unknown { background: var(--deep-2); color: var(--chalk); }
.plate-flag {
  margin-top: 6px; background: var(--deep); color: var(--chalk); font-size: 12.5px; padding: 7px 12px 7px 14px;
  border-left: 3px solid var(--amber);
}

/* Assembly: the blocks slide into the octagon when a parcel loads. */
@keyframes from-tl { from { transform: translate(-14px, -14px); opacity: 0; } }
@keyframes from-tr { from { transform: translate(14px, -14px); opacity: 0; } }
@keyframes from-mid { from { transform: scaleX(0.7); opacity: 0; } }
@keyframes from-bl { from { transform: translate(-14px, 14px); opacity: 0; } }
@keyframes from-br { from { transform: translate(14px, 14px); opacity: 0; } }
.plate.assemble .blk-tl { animation: from-tl 0.5s cubic-bezier(0.2, 0.8, 0.2, 1) both; }
.plate.assemble .blk-tr { animation: from-tr 0.5s 0.06s cubic-bezier(0.2, 0.8, 0.2, 1) both; }
.plate.assemble .blk-mid { animation: from-mid 0.5s 0.12s cubic-bezier(0.2, 0.8, 0.2, 1) both; }
.plate.assemble .blk-bl { animation: from-bl 0.5s 0.18s cubic-bezier(0.2, 0.8, 0.2, 1) both; }
.plate.assemble .blk-br { animation: from-br 0.5s 0.24s cubic-bezier(0.2, 0.8, 0.2, 1) both; }

/* ---------- chat ---------- */
.chat { display: flex; flex-direction: column; min-width: 0; min-height: 0; background: var(--night); }
.messages { flex: 1; overflow-y: auto; padding: 26px 24px 10px; }
.messages::-webkit-scrollbar { width: 10px; }
.messages::-webkit-scrollbar-thumb { background: var(--deep-2); border: 3px solid var(--night); }

.empty { max-width: 440px; margin: 8vh auto 0; }
.empty-mark { width: 64px; height: 64px; display: block; overflow: visible; }
.empty-mark > * { transform-box: fill-box; transform-origin: center; animation: 0.6s cubic-bezier(0.2, 0.8, 0.2, 1) both; }
.empty-mark .m1 { animation-name: from-tl; }
.empty-mark .m2 { animation-name: from-tr; animation-delay: 0.07s; }
.empty-mark .m3 { animation-name: from-mid; animation-delay: 0.14s; }
.empty-mark .m4 { animation-name: from-bl; animation-delay: 0.21s; }
.empty-mark .m5 { animation-name: from-br; animation-delay: 0.28s; }
.empty h1 {
  font-stretch: 75%; font-weight: 700; font-size: 34px; line-height: 1.12;
  margin: 26px 0 12px; letter-spacing: -0.005em;
}
.empty p { color: var(--mist); margin: 0 0 26px; max-width: 40ch; }
.examples { display: flex; flex-direction: column; gap: 6px; }
.example {
  display: flex; align-items: baseline; justify-content: space-between; gap: 14px;
  text-align: left; cursor: pointer; border: 0; padding: 11px 16px;
  background: var(--deep);
  clip-path: polygon(10px 0, 100% 0, 100% 100%, 0 100%, 0 10px);
}
.example:hover { background: var(--deep-2); }
.ex-code { color: var(--amber); font-weight: 500; font-size: 15px; }
.ex-hint { color: var(--mist); font-size: 13px; text-align: right; }

.msg { margin: 0 0 26px; display: flex; }
.msg.user { justify-content: flex-end; }
.msg.user .bubble {
  background: var(--deep-2); padding: 9px 18px 10px; max-width: 85%;
  white-space: pre-wrap; overflow-wrap: anywhere;
  clip-path: polygon(0 0, calc(100% - 10px) 0, 100% 10px, 100% 100%, 0 100%);
}
.msg.assistant { gap: 14px; }
.msg.assistant .avatar { flex: none; width: 22px; height: 22px; margin-top: 3px; }
.msg.assistant .content { min-width: 0; flex: 1; }

.content h3 { font-stretch: 80%; font-weight: 700; font-size: 18px; line-height: 1.3; margin: 22px 0 8px; color: var(--chalk); }
.content h3:first-child { margin-top: 0; }
.content p { margin: 6px 0; }
.content strong { font-weight: 600; color: #fff; }
.content ul { margin: 6px 0; padding-left: 0; list-style: none; }
.content li { margin: 4px 0; padding-left: 18px; position: relative; }
.content li::before { content: ""; position: absolute; left: 2px; top: 0.68em; width: 6px; height: 6px; background: var(--teal); transform: rotate(45deg); }
.content blockquote { margin: 10px 0; padding: 8px 14px; border-left: 2px solid var(--amber); background: rgba(63, 120, 108, 0.14); color: var(--chalk); }
.content blockquote p { margin: 0; }
.content table { border-collapse: collapse; width: 100%; margin: 10px 0; font-size: 14px; display: block; overflow-x: auto; }
.content th, .content td { border-bottom: 1px solid var(--line); padding: 7px 12px 7px 0; text-align: left; vertical-align: top; }
.content th { color: var(--mist); font-weight: 500; font-size: 12.5px; border-bottom-color: var(--line-strong); }
.content td strong { font-family: var(--font-latin); }
.content code { font-family: var(--font-latin); background: var(--deep); padding: 1px 7px; font-size: 0.95em; color: var(--amber); }
.content sub { color: var(--mist); font-size: 12px; line-height: 1.5; vertical-align: baseline; display: inline-block; }
.content em { color: var(--mist); }
.content a { overflow-wrap: anywhere; }

/* Verdict: the first thing in every parcel answer. */
.verdict {
  --vc: 14px;
  margin: 0 0 20px; padding: 14px 18px 15px 20px;
  background: var(--deep); color: var(--chalk);
  clip-path: polygon(var(--vc) 0, 100% 0, 100% calc(100% - var(--vc)), calc(100% - var(--vc)) 100%, 0 100%, 0 var(--vc));
  border-left: 4px solid var(--mist);
}
.verdict p { margin: 0; }
.verdict .v-head { font-stretch: 78%; font-weight: 700; font-size: 23px; line-height: 1.2; }
.verdict .v-sum { margin-top: 6px; }
.verdict .v-sub { margin-top: 10px; font-weight: 600; }
.verdict ul { margin: 4px 0 0; }
.verdict li::before { background: currentColor; opacity: 0.55; }
.v-allowed { background: var(--teal); border-left-color: var(--chalk); }
.v-conditional, .v-partial, .v-limited { background: var(--amber); color: var(--ink); border-left-color: var(--ink); }
.v-conditional .v-sub, .v-partial .v-sub, .v-limited .v-sub { color: var(--ink); }
.v-not_allowed { background: #B5473A; border-left-color: var(--chalk); }
.v-unknown { background: var(--deep-2); }

.typing { display: inline-flex; gap: 5px; padding: 9px 0 4px; }
.typing span { width: 7px; height: 7px; background: var(--amber); transform: rotate(45deg); animation: pulse 1.2s infinite ease-in-out; }
.typing span:nth-child(2) { animation-delay: 0.15s; background: var(--chalk); }
.typing span:nth-child(3) { animation-delay: 0.3s; }
@keyframes pulse { 0%, 80%, 100% { opacity: 0.25; } 40% { opacity: 1; } }
.status-line { color: var(--mist); font-size: 13px; }

/* ---------- composer ---------- */
.composer { padding: 10px 24px 14px; }
.composer-frame {
  --k: var(--chamfer);
  padding: 1px; background: var(--line-strong);
  clip-path: polygon(var(--k) 0, 100% 0, 100% calc(100% - var(--k)), calc(100% - var(--k)) 100%, 0 100%, 0 var(--k));
}
.composer-frame:focus-within { background: var(--amber); }
.composer-box {
  display: flex; align-items: flex-end; gap: 10px; background: var(--deep);
  padding: 9px 9px 9px 20px;
  clip-path: polygon(var(--k) 0, 100% 0, 100% calc(100% - var(--k)), calc(100% - var(--k)) 100%, 0 100%, 0 var(--k));
}
.composer textarea {
  flex: 1; border: 0; outline: 0; resize: none; background: transparent; color: var(--chalk);
  font: inherit; line-height: 1.5; max-height: 180px; padding: 7px 0; overflow-y: hidden;
}
.composer textarea::placeholder { color: var(--mist); }
.send {
  flex: none; width: 38px; height: 38px; border: 0; cursor: pointer;
  background: var(--amber); color: var(--ink); display: grid; place-items: center;
  clip-path: polygon(0 0, 100% 0, 100% calc(100% - 9px), calc(100% - 9px) 100%, 0 100%);
}
.send:disabled { background: var(--deep-2); color: var(--mist); cursor: default; }
.send:focus-visible { outline-offset: -4px; outline-color: var(--ink); }
.disclaimer { text-align: center; font-size: 11.5px; color: var(--mist); margin: 8px 0 0; }

.scrim { display: none; }

/* Call-to-action under answers: Tashub's phone + call-back request. */
.cta {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px;
  margin-top: 12px; padding: 10px 14px; background: var(--deep);
  clip-path: polygon(10px 0, 100% 0, 100% 100%, 0 100%, 0 10px);
}
.cta-text { flex: 1 1 180px; font-size: 13.5px; color: var(--mist); }
.cta a.cta-phone { font-family: var(--font-latin); font-weight: 600; color: var(--amber); text-decoration: none; white-space: nowrap; }
.cta button {
  border: 0; cursor: pointer; padding: 7px 14px; font-weight: 600; font-size: 13.5px;
  background: var(--amber); color: var(--ink);
  clip-path: polygon(0 0, 100% 0, 100% calc(100% - 7px), calc(100% - 7px) 100%, 0 100%);
}
.cta button:disabled { background: var(--teal); color: var(--chalk); cursor: default; }

/* ---------- registration gate ---------- */
.gate { position: fixed; inset: 0; z-index: 2000; display: grid; place-items: center; padding: 16px; background: rgba(4, 14, 12, 0.86); backdrop-filter: blur(3px); }
.gate[hidden] { display: none; }
.gate-card {
  width: min(400px, 100%); background: var(--deep); padding: 28px 26px 22px;
  clip-path: polygon(18px 0, 100% 0, 100% calc(100% - 18px), calc(100% - 18px) 100%, 0 100%, 0 18px);
}
.gate-mark { width: 44px; height: 44px; display: block; }
.gate-card h1 { font-stretch: 78%; font-weight: 700; font-size: 26px; line-height: 1.15; margin: 18px 0 6px; }
.gate-card > p { color: var(--mist); margin: 0 0 18px; font-size: 14px; }
.field { display: block; margin-bottom: 12px; }
.field > span { display: block; font-size: 12.5px; color: var(--mist); margin-bottom: 5px; }
.field input, .phone-input { width: 100%; background: var(--night); border: 1px solid var(--line-strong); color: var(--chalk); font: inherit; padding: 9px 12px; outline: 0; }
.field input:focus, .phone-input:focus-within { border-color: var(--amber); }
.phone-input { display: flex; align-items: center; gap: 8px; padding: 0 12px; }
.phone-input input { border: 0; padding: 9px 0; background: transparent; font-family: var(--font-latin); letter-spacing: 0.02em; }
.phone-input .prefix { font-family: var(--font-latin); color: var(--mist); }
.gate-error { color: var(--bad); font-size: 13px; min-height: 1.2em; margin: 2px 0 8px !important; }
.gate-btn {
  width: 100%; border: 0; cursor: pointer; padding: 11px; font-weight: 600; font-size: 15px;
  background: var(--amber); color: var(--ink);
  clip-path: polygon(0 0, 100% 0, 100% calc(100% - 10px), calc(100% - 10px) 100%, 0 100%);
}
.gate-btn:disabled { opacity: 0.6; cursor: default; }
.gate-note { font-size: 11.5px !important; margin: 12px 0 0 !important; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ---------- responsive ---------- */
@media (max-width: 1180px) {
  .app { grid-template-columns: minmax(0, 1fr) minmax(360px, 500px); }
  .sidebar { position: fixed; inset: 0 auto 0 0; width: 280px; z-index: 1000; transform: translateX(-100%); transition: transform 0.2s ease; }
  .app.menu-open .sidebar { transform: none; }
  .app.menu-open .scrim { display: block; position: fixed; inset: 0; background: rgba(4, 14, 12, 0.6); z-index: 999; }
  .icon-btn, .topbar-mark { display: inline-block; }
}
@media (max-width: 760px) {
  .app { grid-template-columns: 1fr; grid-template-rows: 44dvh minmax(0, 1fr); }
  .map-panel { border-right: 0; border-bottom: 1px solid var(--line); }
  .topbar { height: 50px; }
  .plate-wrap { left: 10px; bottom: 10px; width: min(300px, calc(100% - 20px)); }
  .plate { --c: 14px; gap: 4px; }
  .blk { padding: 7px 11px 8px; }
  .blk-tl, .blk-bl { padding-left: 15px; }
  .blk .v { font-size: 19px; }
  .blk-mid > div { padding: 7px 11px 8px; }
  .blk-mid .v { font-size: 17px; }
  .blk .l { font-size: 11px; }
  .blk-mid .l, .blk-tl .zone-name, .plate-flag { display: none; }
  .plate-status { font-size: 12.5px; margin-bottom: 4px; }
  .verdict .v-head { font-size: 20px; }
  .messages { padding: 18px 16px 8px; }
  .composer { padding: 8px 16px 10px; }
  .empty { margin-top: 2vh; }
  .empty-mark { width: 48px; height: 48px; }
  .empty h1 { font-size: 27px; margin-top: 18px; }
  .ex-hint { display: none; }
}
