@font-face {
  font-family: "Idiqlat";
  src: url("../assets/fonts/Idiqlat-ExtraLight.ttf") format("truetype");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Idiqlat";
  src: url("../assets/fonts/Idiqlat-Light.ttf") format("truetype");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Idiqlat";
  src: url("../assets/fonts/Idiqlat-Regular.ttf") format("truetype");
  font-weight: 900;
  font-style: normal;
  font-display: swap;
}

:root {
  color-scheme: dark;
  --bg: #151515;
  --panel: #2a2a2a;
  --panel-soft: #202020;
  --panel-deep: #1f1f1f;
  --field: #696969;
  --field-soft: #363636;
  --outline: #e4e4e4;
  --text: #ffffff;
  --muted: #b4b4b4;
  --subtitle: #d4d4d4;
  --line: rgba(255, 255, 255, 0.08);
  --line-strong: #333333;
  --danger: #ff7272;
  --ok: #76d672;
  --warn: #e9c46a;
  --violet: #c79bff;
  font-family: "Idiqlat", Inter, system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body { min-width: 320px; min-height: 100%; margin: 0; }
body { background: var(--bg); color: var(--text); overflow-x: hidden; }
button, input, select { font: inherit; }
button { cursor: pointer; }
a { color: inherit; text-decoration: none; }
h1, h2, h3, p { margin: 0; overflow-wrap: anywhere; }
input, select {
  border: 0;
  outline: 0;
  color: var(--text);
  background: transparent;
}

[hidden] { display: none !important; }

.welcome-screen {
  position: relative;
  min-height: 100vh;
  background: var(--bg);
  overflow: hidden;
}

.welcome-links {
  position: absolute;
  inset: 0 0 auto;
  z-index: 2;
  display: flex;
  justify-content: space-between;
  padding: 18px;
  color: var(--muted);
  font-size: 24px;
  font-weight: 900;
}

.welcome-center {
  position: absolute;
  inset: 0 0 360px;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 22px;
  text-align: center;
}

.welcome-center h1 {
  font-size: clamp(42px, 8vw, 58px);
  line-height: 1;
  font-weight: 900;
}

.welcome-center p {
  color: var(--subtitle);
  font-size: 22px;
  font-weight: 700;
}

.welcome-panel {
  position: fixed;
  inset: auto 0 0;
  display: grid;
  gap: 16px;
  padding: 32px 18px 34px;
  border-radius: 53px 53px 0 0;
  background: var(--panel);
}

.app-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 56px;
  padding: 12px 20px;
  border-radius: 44px;
  color: var(--text);
  font-size: 20px;
  font-weight: 900;
  text-align: center;
}

.app-button.filled {
  border: 0;
  background: var(--field);
}

.app-button.outlined {
  border: 1.5px solid var(--outline);
  background: transparent;
}

.app-button.wide { width: 100%; }

.phone-shell {
  min-height: 100vh;
  background: var(--bg);
}

.app-view {
  display: none;
  min-height: 100vh;
}

.app-view.active {
  display: flex;
  flex-direction: column;
}

.mobile-topbar {
  position: sticky;
  top: 0;
  z-index: 8;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 64px;
  padding: 16px 18px 12px;
  background: rgba(21, 21, 21, 0.94);
  backdrop-filter: blur(14px);
}

.mobile-topbar strong,
.nav-text,
.screen-actions button,
.screen-actions a {
  color: var(--muted);
  font-size: 22px;
  font-weight: 900;
}

.brand-button,
.nav-text,
.screen-actions button,
.icon-action {
  border: 0;
  background: transparent;
}

.brand-button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 36px;
  color: var(--muted);
  font-size: 22px;
  font-weight: 900;
}

.brand-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--muted);
}

.screen-actions {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 16px;
  min-width: 0;
}

.screen-actions a {
  max-width: 150px;
  white-space: nowrap;
}

.icon-action {
  display: inline-grid;
  place-items: center;
  width: 40px;
  height: 40px;
  color: var(--text);
  font-size: 28px;
  font-weight: 900;
}

.chat-stage {
  display: flex;
  flex: 1;
  flex-direction: column;
  min-height: 0;
  padding-bottom: 86px;
}

.messages {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 12px;
  min-height: 360px;
  padding: 18px 16px 8px;
  overflow: auto;
  scroll-behavior: smooth;
}

.message {
  width: fit-content;
  max-width: min(900px, 90%);
  color: var(--text);
  font-size: 16px;
  line-height: 1.42;
  white-space: pre-wrap;
}

.message.assistant {
  align-self: flex-start;
  padding: 4px;
  background: transparent;
}

.message.user {
  align-self: flex-end;
  max-width: min(720px, 75%);
  margin-bottom: 4px;
  padding: 12px 18px;
  border-radius: 44px 0 44px 44px;
  background: var(--panel-deep);
}

.message.error {
  padding: 12px 16px;
  border-radius: 16px;
  background: rgba(255, 114, 114, 0.12);
  color: #ffd1d1;
}

.message.image-message {
  width: min(910px, 73vw);
  max-width: none;
  padding: 0;
  border-radius: 14px;
  background: transparent;
  overflow: hidden;
}

.message.image-message img,
.message img {
  display: block;
  width: 100%;
  height: clamp(180px, 18vw, 260px);
  object-fit: cover;
}

.loading-text {
  color: var(--muted);
  font-weight: 900;
  animation: shimmer 1.35s ease-in-out infinite;
}

@keyframes shimmer {
  0%, 100% { opacity: 0.4; }
  50% { opacity: 1; }
}

.suggestions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  padding: 0 16px 12px;
}

.suggestions button {
  max-width: 340px;
  min-height: 48px;
  padding: 10px 18px;
  border: 0;
  border-radius: 22px;
  background: rgba(217, 217, 217, 0.07);
  color: var(--text);
  font-size: 16px;
  font-weight: 900;
}

.intent-panel {
  margin: 0 16px 10px;
  padding: 14px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: var(--panel-soft);
}

.intent-panel p {
  color: var(--subtitle);
  font-size: 15px;
  line-height: 1.4;
}

.intent-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.intent-actions button {
  min-height: 38px;
  padding: 0 12px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: #292929;
  color: var(--text);
  font-weight: 900;
}

.composer {
  position: fixed;
  inset: auto 12px 16px;
  z-index: 10;
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr);
  gap: 10px;
}

.round-button,
.composer-field button {
  display: inline-grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border: 0;
  border-radius: 50%;
  background: var(--field);
  color: var(--text);
  font-size: 28px;
  font-weight: 400;
}

.composer-field {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 42px;
  align-items: center;
  min-height: 48px;
  border-radius: 33px;
  background: var(--field);
}

.composer-field input {
  min-width: 0;
  height: 48px;
  padding: 0 16px;
  font-size: 16px;
}

.composer-field input::placeholder {
  color: var(--text);
  opacity: 1;
}

.composer-field button {
  width: 38px;
  height: 38px;
  margin-right: 5px;
  background: #aeaeae;
  font-size: 22px;
}

.recognition-card,
.panel-card,
.day-card,
.plan-summary,
.profile-panel {
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: var(--panel-soft);
}

.recognition-card {
  width: min(1164px, calc(100vw - 32px));
  padding: 14px;
}

.recognition-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.recognition-kicker,
.recognition-card p,
.recognition-card li,
.macro-tile small,
.recipe-meta,
.meal-meta,
.profile-panel small {
  color: rgba(255, 255, 255, 0.62);
}

.recognition-title,
.section-title,
.meal-title {
  color: var(--text);
  font-weight: 900;
}

.recognition-title {
  margin-top: 4px;
  font-size: 20px;
}

.confidence-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 9px 10px;
  border-radius: 8px;
  background: #2b2b2b;
  color: var(--text);
  font-size: 13px;
  font-weight: 900;
}

.confidence-badge span { color: var(--violet); }

.section-title {
  margin-top: 16px;
  margin-bottom: 8px;
  font-size: 15px;
}

.macro-row,
.ingredient-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.macro-tile {
  width: 108px;
  padding: 10px;
  border-radius: 8px;
  background: var(--panel);
}

.macro-tile strong {
  display: block;
  font-size: 16px;
}

.ingredient-pill {
  padding: 7px 10px;
  border: 1px solid #383838;
  border-radius: 8px;
  background: #292929;
  color: rgba(255, 255, 255, 0.84);
  font-size: 13px;
}

.recipe-steps {
  display: grid;
  gap: 7px;
  padding: 0;
  list-style: none;
}

.recipe-steps li {
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr);
  gap: 6px;
}

.similar-list {
  display: grid;
  gap: 8px;
}

.similar-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 24px;
  gap: 12px;
  padding: 11px 12px;
  border-radius: 8px;
  background: #292929;
}

.planner-screen,
.profile-screen,
.history-list {
  flex: 1;
  padding: 0 12px 24px;
  overflow: auto;
}

.planner-form {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 12px;
  padding: 12px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: var(--panel-soft);
}

.planner-form label,
.connect-form label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
}

.planner-form input,
.planner-form select,
.connect-form input,
.connect-form select {
  width: 100%;
  height: 38px;
  padding: 0 12px;
  border-radius: 18px;
  background: var(--panel);
}

.plan-output {
  display: grid;
  gap: 12px;
}

.plan-summary,
.day-card {
  padding: 16px;
}

.summary-grid {
  display: grid;
  gap: 8px;
  margin-top: 14px;
}

.summary-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  color: var(--muted);
  font-size: 15px;
}

.summary-row strong { color: var(--text); }

.progress-bar {
  height: 8px;
  margin: 10px 0;
  overflow: hidden;
  border-radius: 4px;
  background: #333333;
}

.progress-bar span {
  display: block;
  height: 100%;
  width: var(--value, 0%);
  background: #ededed;
}

.day-tabs {
  display: flex;
  gap: 8px;
  margin: 16px 0;
  overflow-x: auto;
}

.day-tabs button {
  flex: 0 0 auto;
  min-height: 36px;
  padding: 0 16px;
  border: 1.5px solid var(--outline);
  border-radius: 8px;
  background: transparent;
  color: var(--text);
  font-weight: 900;
}

.day-tabs button.active {
  background: #ededed;
  color: var(--bg);
}

.meal-list {
  display: grid;
  gap: 10px;
}

.meal-card {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: start;
  padding: 16px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: var(--panel-soft);
}

.meal-check {
  display: inline-grid;
  place-items: center;
  width: 18px;
  height: 18px;
  margin-top: 3px;
  border: 2px solid var(--outline);
  border-radius: 2px;
  color: var(--bg);
  font-size: 14px;
}

.meal-check.checked {
  background: var(--outline);
}

.tier-badge {
  padding: 6px 9px;
  border-radius: 6px;
  background: #2b4430;
  color: #9af59e;
  font-size: 11px;
  text-transform: uppercase;
}

.profile-screen {
  padding-inline: 18px;
}

.profile-head {
  display: grid;
  justify-items: center;
  gap: 12px;
  padding: 2px 0 24px;
}

.profile-head h1 {
  font-size: 22px;
  font-weight: 900;
}

.edit-profile-pill {
  min-height: 40px;
  padding: 0 22px;
  border: 1px solid #969696;
  border-radius: 33px;
  background: transparent;
  color: var(--text);
  font-weight: 900;
}

.section-label {
  margin: 18px 0 8px;
  color: var(--text);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 1.2px;
  text-transform: uppercase;
}

.profile-panel {
  padding: 0 16px;
  border: 0;
  border-radius: 28px;
  background: #222222;
}

.profile-row,
.product-row,
.server-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 16px;
  min-height: 52px;
  border-bottom: 1px solid var(--line);
}

.profile-row:last-child,
.product-row:last-child,
.server-row:last-child { border-bottom: 0; }

.profile-row span,
.product-row span {
  color: var(--text);
  font-size: 16px;
  font-weight: 900;
}

.product-row span {
  display: grid;
  gap: 3px;
}

.profile-row input,
.profile-row select,
.product-row input {
  min-width: 90px;
  max-width: min(340px, 52vw);
  height: 40px;
  padding: 0 18px;
  border-radius: 24px;
  background: var(--panel);
  color: var(--text);
  text-align: right;
  font-size: 17px;
  font-weight: 900;
}

.product-row input {
  min-width: min(520px, 48vw);
  max-width: min(620px, 54vw);
  color: var(--muted);
  font-size: 13px;
}

.inline-link {
  display: block;
  width: 100%;
  margin: 4px 0 12px;
  border: 0;
  background: transparent;
  color: var(--text);
  text-align: right;
  text-decoration: underline;
  font-size: 13px;
  font-weight: 900;
}

.save-button {
  margin-top: 28px;
}

.status-line {
  min-height: 24px;
  color: var(--muted);
}

.status-line.error { color: var(--danger); }

.server-row {
  padding: 12px 0;
}

.server-row span:first-child {
  display: grid;
  gap: 4px;
}

.status-dot {
  display: inline-block;
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: var(--muted);
}

.status-dot.online { background: var(--ok); }
.status-dot.offline { background: var(--danger); }
.status-dot.pending { background: var(--warn); }

.connect-form {
  display: grid;
  grid-template-columns: 180px minmax(0, 1fr) auto auto;
  gap: 10px;
  padding: 14px 0 16px;
}

.history-list {
  display: grid;
  align-content: start;
  gap: 10px;
  color: var(--muted);
}

.history-item {
  width: 100%;
  min-height: 56px;
  padding: 14px 16px;
  border: 0;
  border-radius: 16px;
  background: var(--panel-soft);
  color: var(--text);
  text-align: left;
  font-size: 16px;
  font-weight: 900;
}

@media (min-width: 900px) {
  .message.assistant .recognition-card {
    max-width: calc(100vw - 64px);
  }

  .planner-screen,
  .profile-screen,
  .history-list {
    padding-inline: 18px;
  }
}

@media (max-width: 900px) {
  .screen-actions { gap: 10px; }
  .screen-actions a { max-width: 118px; }
  .screen-actions button,
  .screen-actions a,
  .mobile-topbar strong,
  .nav-text,
  .brand-button { font-size: 18px; }
  .planner-form { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .connect-form { grid-template-columns: 1fr; }
  .product-row { grid-template-columns: 1fr; padding: 12px 0; }
  .product-row input { min-width: 0; max-width: none; width: 100%; text-align: left; }
}

@media (max-width: 640px) {
  .welcome-center { inset-bottom: 260px; }
  .welcome-panel { padding-bottom: 28px; border-radius: 34px 34px 0 0; }
  .mobile-topbar { align-items: flex-start; padding-inline: 14px; }
  .screen-actions { flex-wrap: wrap; }
  .chat-stage { padding-bottom: 78px; }
  .messages { padding-inline: 12px; }
  .message { max-width: 95%; }
  .message.user { max-width: 84%; }
  .message.image-message { width: min(100%, calc(100vw - 24px)); }
  .suggestions { flex-direction: column; align-items: stretch; }
  .suggestions button { max-width: none; }
  .planner-form { grid-template-columns: 1fr; }
  .macro-tile { width: calc(50% - 4px); }
  .profile-screen { padding-inline: 12px; }
  .profile-row { grid-template-columns: 1fr auto; }
  .profile-row input,
  .profile-row select { max-width: 46vw; }
}
