:root {
  --page: #f8fbf6;
  --secondary: #eff7ec;
  --soft-green: #eef9e9;
  --light-green: #d7efd0;
  --brand: #3baa44;
  --brand-2: #7dcb44;
  --text: #111411;
  --main: #263126;
  --muted: #6e786b;
  --soft-grey: #99a395;
  --card: #ffffff;
  --border: #dce7d8;
  --shadow: 0 14px 36px rgba(72, 88, 68, 0.1);
  --radius-xl: 28px;
  --radius-lg: 22px;
  --radius-md: 16px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: var(--page);
  color: var(--main);
}

body {
  display: flex;
  justify-content: center;
}

button,
input,
textarea,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  position: relative;
  width: min(100%, 460px);
  min-height: 100vh;
  background: var(--page);
  overflow: hidden;
  border-left: 1px solid rgba(220, 231, 216, 0.55);
  border-right: 1px solid rgba(220, 231, 216, 0.55);
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: max(14px, env(safe-area-inset-top)) 18px 12px;
  background: rgba(248, 251, 246, 0.95);
  border-bottom: 1px solid rgba(220, 231, 216, 0.75);
  backdrop-filter: blur(12px);
}

.logo-button {
  width: 44px;
  height: 44px;
  border: 0;
  padding: 6px;
  background: #fff;
  border-radius: 14px;
  overflow: visible;
  box-shadow: 0 8px 18px rgba(75, 92, 71, 0.09);
}

.logo-button img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.topbar-copy {
  min-width: 0;
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 2px;
}

.topbar-copy strong {
  color: var(--text);
  font-size: 15px;
  line-height: 1.15;
}

.topbar-copy span {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.mode-pill,
.status-pill,
.tag,
.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  background: var(--secondary);
  color: var(--muted);
  border-radius: 999px;
  line-height: 1;
  white-space: nowrap;
}

.mode-pill {
  padding: 7px 10px;
  font-size: 11px;
  font-weight: 700;
  color: var(--brand);
  border-color: rgba(59, 170, 68, 0.22);
  background: var(--soft-green);
}

.screen-host {
  padding: 18px 16px 96px;
}

.screen {
  display: grid;
  gap: 16px;
}

.hero-card,
.card,
.agent-card,
.task-card,
.message-card,
.profile-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
}

.hero-card {
  padding: 22px;
  background: linear-gradient(145deg, #ffffff 0%, #eef9e9 100%);
}

.hero-row {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: flex-start;
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  font-size: 26px;
  color: var(--text);
  line-height: 1.05;
  letter-spacing: 0;
}

h2 {
  font-size: 20px;
  color: var(--text);
  line-height: 1.15;
  letter-spacing: 0;
}

h3 {
  font-size: 16px;
  color: var(--text);
  line-height: 1.2;
  letter-spacing: 0;
}

p,
li {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.45;
}

ul {
  margin: 0;
  padding-left: 18px;
}

.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.section-title small {
  color: var(--muted);
  font-size: 12px;
}

.search-wrap {
  position: relative;
}

.search-input,
.task-input,
.select-input {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: #fff;
  color: var(--main);
  outline: none;
}

.search-input {
  height: 48px;
  padding: 0 16px 0 42px;
}

.search-wrap::before {
  content: "⌕";
  position: absolute;
  left: 16px;
  top: 50%;
  color: var(--soft-grey);
  transform: translateY(-50%);
}

.task-input {
  min-height: 118px;
  resize: vertical;
  padding: 14px;
  line-height: 1.4;
}

.select-input {
  height: 42px;
  padding: 0 12px;
}

.chips {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 2px;
  scrollbar-width: none;
}

.chips::-webkit-scrollbar {
  display: none;
}

.chip {
  border: 1px solid var(--border);
  background: #fff;
  color: var(--muted);
  border-radius: 999px;
  padding: 9px 13px;
  font-size: 13px;
  white-space: nowrap;
}

.chip.is-active {
  color: var(--text);
  border-color: rgba(59, 170, 68, 0.35);
  background: var(--light-green);
}

.agent-grid {
  display: grid;
  gap: 12px;
}

.agent-card {
  display: grid;
  gap: 12px;
  padding: 14px;
}

.agent-card-header,
.task-head,
.message-head {
  display: flex;
  gap: 10px;
  align-items: flex-start;
}

.agent-icon,
.message-icon {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  border-radius: 16px;
  background: var(--soft-green);
  border: 1px solid rgba(59, 170, 68, 0.18);
  color: var(--text);
  font-size: 20px;
}

.agent-meta,
.task-meta,
.message-meta {
  min-width: 0;
  flex: 1;
}

.agent-meta p,
.task-meta p,
.message-meta p {
  margin-top: 4px;
}

.agent-actions,
.detail-actions,
.task-actions,
.room-actions {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

.btn {
  border: 0;
  border-radius: 16px;
  padding: 12px 15px;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: var(--text);
  background: var(--secondary);
  font-weight: 700;
}

.btn.primary {
  background: var(--brand);
  color: #fff;
  box-shadow: 0 10px 24px rgba(59, 170, 68, 0.18);
}

.btn.secondary {
  background: #fff;
  border: 1px solid var(--border);
  color: var(--main);
}

.btn.full {
  width: 100%;
}

.btn:disabled {
  cursor: not-allowed;
  opacity: 0.62;
}

.status-pill,
.badge {
  padding: 7px 9px;
  font-size: 11px;
  font-weight: 700;
}

.status-available {
  color: #237d2b;
  background: #edf9e8;
  border-color: #cfecc8;
}

.status-busy,
.status-in_progress,
.status-queued {
  color: #7c5c0d;
  background: #fff5d8;
  border-color: #f1dea2;
}

.status-skill-only,
.status-waiting_user {
  color: #496245;
  background: #eef5eb;
  border-color: #d9e5d5;
}

.status-completed {
  color: #237d2b;
  background: #edf9e8;
  border-color: #cfecc8;
}

.status-failed,
.status-stopped {
  color: #94372d;
  background: #fff0ee;
  border-color: #f1cbc5;
}

.tag-row,
.template-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.tag {
  padding: 7px 9px;
  font-size: 12px;
}

.template-chip {
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 9px 10px;
  background: var(--soft-green);
  color: var(--main);
  font-size: 13px;
}

.card {
  padding: 16px;
  display: grid;
  gap: 12px;
}

.split-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.stat-card {
  padding: 13px 10px;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: #fff;
}

.stat-card strong {
  display: block;
  font-size: 20px;
  color: var(--text);
}

.stat-card span {
  color: var(--muted);
  font-size: 12px;
}

.task-card {
  padding: 14px;
  display: grid;
  gap: 12px;
}

.task-card.is-selected {
  border-color: rgba(59, 170, 68, 0.5);
  box-shadow: 0 16px 34px rgba(59, 170, 68, 0.13);
}

.task-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.task-foot small,
.timestamp {
  color: var(--soft-grey);
  font-size: 12px;
}

.empty {
  padding: 20px;
  border: 1px dashed var(--border);
  border-radius: var(--radius-lg);
  color: var(--muted);
  background: rgba(255, 255, 255, 0.55);
  text-align: center;
}

.detail-header {
  display: grid;
  gap: 12px;
}

.detail-card {
  padding: 18px;
}

.detail-title {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
}

.room-controls {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.room-controls .search-wrap {
  grid-column: 1 / -1;
}

.segmented {
  display: flex;
  border: 1px solid var(--border);
  padding: 4px;
  border-radius: 16px;
  background: #fff;
}

.segmented button {
  flex: 1;
  border: 0;
  border-radius: 12px;
  padding: 8px;
  background: transparent;
  color: var(--muted);
}

.segmented button.is-active {
  background: var(--light-green);
  color: var(--text);
  font-weight: 700;
}

.message-list {
  display: grid;
  gap: 12px;
}

.message-card {
  padding: 13px;
}

.message-card.is-pinned {
  border-color: rgba(59, 170, 68, 0.45);
  background: #fbfff9;
}

.message-text {
  margin-top: 10px;
  color: var(--main);
  font-size: 14px;
  line-height: 1.48;
}

.pin-btn {
  border: 0;
  background: var(--secondary);
  color: var(--muted);
  border-radius: 12px;
  padding: 7px 9px;
  font-size: 12px;
}

.pin-btn.is-active {
  color: var(--brand);
  background: var(--soft-green);
}

.profile-card {
  padding: 18px;
  display: grid;
  gap: 12px;
}

.profile-logo {
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  padding: 6px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: #fff;
}

.profile-logo img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.settings-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}

.settings-row:last-child {
  border-bottom: 0;
}

.bottom-nav {
  position: fixed;
  left: 50%;
  bottom: 0;
  z-index: 25;
  width: min(100%, 460px);
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 4px;
  padding: 8px 9px max(8px, env(safe-area-inset-bottom));
  background: rgba(255, 255, 255, 0.96);
  border-top: 1px solid var(--border);
  transform: translateX(-50%);
  backdrop-filter: blur(12px);
}

.nav-item {
  border: 0;
  background: transparent;
  color: var(--muted);
  border-radius: 15px;
  padding: 7px 4px;
  display: grid;
  gap: 3px;
  place-items: center;
  min-width: 0;
}

.nav-item span {
  font-size: 18px;
  line-height: 1;
}

.nav-item small {
  font-size: 10px;
  line-height: 1.1;
}

.nav-item.is-active {
  background: var(--soft-green);
  color: var(--text);
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 82px;
  z-index: 30;
  width: min(calc(100% - 28px), 432px);
  padding: 13px 14px;
  border-radius: 17px;
  background: var(--text);
  color: #fff;
  box-shadow: 0 16px 32px rgba(17, 20, 17, 0.2);
  transform: translateX(-50%);
}

.hidden {
  display: none !important;
}

@media (min-width: 430px) {
  .agent-grid.two {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
