* { box-sizing: border-box; }
html, body {
  margin: 0;
  padding: 0;
  background: #fff;
  color: #111;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}
.hidden { display: none !important; }
.screen { min-height: 100dvh; }
.muted { color: #8e8e93; font-size: 14px; }
.error { color: #ff3b30; font-size: 14px; margin-top: 12px; }

.login-card {
  max-width: 360px;
  margin: 0 auto;
  padding: 48px 24px;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  justify-content: center;
}
.login-card h1 {
  font-size: 34px;
  font-weight: 700;
  margin: 0 0 8px;
  letter-spacing: -0.5px;
}
.login-card input {
  width: 100%;
  margin-top: 24px;
  padding: 16px;
  border: 1px solid #e5e5ea;
  border-radius: 14px;
  font-size: 17px;
  background: #fff;
}
.login-card button {
  margin-top: 16px;
  width: 100%;
  padding: 16px;
  border: none;
  border-radius: 14px;
  background: #111;
  color: #fff;
  font-size: 17px;
  font-weight: 600;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px 8px;
  position: sticky;
  top: 0;
  background: rgba(255,255,255,.92);
  backdrop-filter: blur(12px);
  z-index: 10;
}
.top-title { font-size: 28px; font-weight: 700; letter-spacing: -0.5px; }
.top-sub { font-size: 14px; color: #8e8e93; margin-top: 2px; }

.main-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  padding: 0 16px 12px;
}
.main-tab {
  padding: 14px 16px;
  border: 1px solid #e5e5ea;
  border-radius: 16px;
  background: #fff;
  font-size: 16px;
  font-weight: 700;
}
.main-tab.active {
  background: #111;
  color: #fff;
  border-color: #111;
}

.tabs {
  display: flex;
  gap: 8px;
  padding: 0 16px 12px;
  overflow-x: auto;
}
.tab {
  flex: 0 0 auto;
  padding: 10px 16px;
  border-radius: 999px;
  border: 1px solid #e5e5ea;
  background: #fff;
  font-size: 15px;
}
.tab.active { background: #111; color: #fff; border-color: #111; }
.tab.active[style*="--accent"] { background: var(--accent, #111); border-color: var(--accent, #111); }

.empty {
  padding: 32px 24px;
  text-align: center;
  color: #8e8e93;
  font-size: 15px;
  line-height: 1.5;
}

.bot-banner {
  padding: 0 16px 8px;
}
.bot-badge {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  border-radius: 18px;
  background: #f2f2f7;
  border-left: 4px solid var(--accent, #111);
}
.bot-icon { font-size: 28px; }
.bot-badge strong { display: block; font-size: 16px; }
.bot-badge span { font-size: 13px; color: #8e8e93; }
.bot-hint { margin: 8px 4px 0; font-size: 13px; }

.from-tag { font-size: 14px; margin-right: 4px; }
.pill {
  font-size: 12px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 999px;
  background: #f2f2f7;
  color: #636366;
}
.dialog-preview { display: flex; align-items: flex-start; gap: 4px; }

.chat-view {
  position: fixed;
  inset: 0;
  background: #fff;
  z-index: 25;
  display: flex;
  flex-direction: column;
}
.chat-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid #e5e5ea;
  background: rgba(255,255,255,.95);
  backdrop-filter: blur(12px);
}
.chat-head-info strong { display: block; font-size: 17px; }
.chat-head-info .muted { font-size: 13px; }
.chat-meta-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 8px 16px;
  background: #fafafa;
  border-bottom: 1px solid #eee;
}
.meta-chip {
  font-size: 12px;
  padding: 4px 10px;
  border-radius: 999px;
  background: #fff;
  border: 1px solid #e5e5ea;
  color: #636366;
}
.chat-messages {
  flex: 1;
  overflow: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: #f9f9fb;
}
.msg {
  max-width: 88%;
  padding: 10px 14px;
  border-radius: 18px;
  font-size: 15px;
  line-height: 1.4;
  box-shadow: 0 1px 2px rgba(0,0,0,.04);
}
.msg-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .03em;
  margin-bottom: 4px;
  opacity: .75;
}
.msg-text { white-space: pre-wrap; word-break: break-word; }
.msg time { display: block; margin-top: 6px; font-size: 11px; opacity: .55; }
.msg-user {
  align-self: flex-start;
  background: #fff;
  border: 1px solid #e5e5ea;
  border-bottom-left-radius: 6px;
}
.msg-user.application {
  border-color: #007aff;
  background: #f0f7ff;
}
.msg-bot {
  align-self: flex-end;
  background: #111;
  color: #fff;
  border-bottom-right-radius: 6px;
}
.msg-bot .msg-label { color: rgba(255,255,255,.7); }
.msg-operator {
  align-self: flex-end;
  background: #007aff;
  color: #fff;
  border-bottom-right-radius: 6px;
}
.msg-operator .msg-label { color: rgba(255,255,255,.8); }
.chat-compose {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  border-top: 1px solid #e5e5ea;
  background: #fff;
}
.chat-compose textarea {
  border: 1px solid #e5e5ea;
  border-radius: 16px;
  padding: 12px 14px;
  font-size: 15px;
  resize: none;
  font-family: inherit;
}
.chat-compose button { align-self: end; padding: 12px 18px; }
.chat-status { padding: 0 16px 8px; text-align: center; }

.seg {
  display: flex;
  gap: 8px;
  padding: 0 16px 12px;
}
.seg-btn {
  flex: 1;
  padding: 10px 8px;
  border: none;
  border-radius: 12px;
  background: #f2f2f7;
  font-size: 14px;
  font-weight: 600;
}
.seg-btn.active { background: #111; color: #fff; }

.list { padding: 0 16px 100px; }
.card {
  border: 1px solid #e5e5ea;
  border-radius: 18px;
  padding: 16px;
  margin-bottom: 12px;
  background: #fff;
  box-shadow: 0 1px 0 rgba(0,0,0,.03);
}
.card-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}
.badge {
  font-size: 12px;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 999px;
  text-transform: uppercase;
}
.badge.pending { background: #fff3cd; color: #856404; }
.badge.published { background: #d4edda; color: #155724; }
.badge.rejected { background: #f8d7da; color: #721c24; }
.badge.approved { background: #cce5ff; color: #004085; }
.card h3 { margin: 0 0 8px; font-size: 18px; }
.card p { margin: 0; color: #3a3a3c; font-size: 15px; line-height: 1.4; }
.card time { color: #8e8e93; font-size: 13px; }

.editor {
  position: fixed;
  inset: 0;
  background: #fff;
  z-index: 20;
  overflow: auto;
  padding: 16px 16px 40px;
}
.editor-head {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}
#editorTitle { font-weight: 700; font-size: 18px; }
#content {
  width: 100%;
  border: 1px solid #e5e5ea;
  border-radius: 16px;
  padding: 14px;
  font-size: 15px;
  line-height: 1.45;
  resize: vertical;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}
.field-label {
  display: block;
  margin: 16px 0 8px;
  font-size: 13px;
  font-weight: 600;
  color: #8e8e93;
  text-transform: uppercase;
  letter-spacing: .04em;
}
.media-preview img, .media-preview video {
  width: 100%;
  border-radius: 16px;
  margin-bottom: 8px;
}
.row { margin-top: 12px; }
.upload-btn {
  display: inline-flex;
  align-items: center;
  padding: 12px 16px;
  border-radius: 12px;
  background: #f2f2f7;
  font-weight: 600;
  cursor: pointer;
}
.actions {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  margin-top: 20px;
}
button.primary, button.secondary, button.danger, button.ghost {
  border: none;
  border-radius: 14px;
  padding: 14px 16px;
  font-size: 16px;
  font-weight: 600;
}
button.primary { background: #111; color: #fff; }
button.secondary { background: #f2f2f7; color: #111; }
button.danger { background: #fff; color: #ff3b30; border: 1px solid #ffd6d3; }
button.ghost { background: transparent; color: #007aff; padding: 8px; }

@media (min-width: 768px) {
  .list, .tabs, .seg, .topbar, .main-tabs, .bot-banner { max-width: 720px; margin-left: auto; margin-right: auto; }
  .editor, .chat-view { max-width: 720px; left: 50%; transform: translateX(-50%); width: 100%; border-left: 1px solid #eee; border-right: 1px solid #eee; }
}
