:root {
  color-scheme: light dark;
  --bg: var(--tg-theme-bg-color, #eef4f0);
  --panel: var(--tg-theme-secondary-bg-color, #ffffff);
  --panel-strong: #ffffff;
  --text: var(--tg-theme-text-color, #15181d);
  --muted: var(--tg-theme-hint-color, #6f7884);
  --accent: var(--tg-theme-button-color, #3390ec);
  --accent-text: var(--tg-theme-button-text-color, #ffffff);
  --line: rgba(91, 103, 118, 0.2);
  --line-strong: rgba(51, 144, 236, 0.38);
  --danger: #c74444;
  --success: #2d8a68;
  --warning: #b77a1f;
  --shadow: 0 12px 28px rgba(25, 31, 40, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 10% 8%, rgba(51, 144, 236, 0.18), transparent 28%),
    radial-gradient(circle at 92% 4%, rgba(45, 138, 104, 0.16), transparent 26%),
    linear-gradient(135deg, #eef4f0 0%, #f7f8fb 44%, #eef5ff 100%);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(51, 144, 236, 0.045) 1px, transparent 1px),
    linear-gradient(90deg, rgba(45, 138, 104, 0.04) 1px, transparent 1px);
  background-size: 28px 28px;
  mask-image: linear-gradient(to bottom, rgba(0, 0, 0, 0.85), transparent 72%);
}

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

.shell {
  position: relative;
  z-index: 1;
  width: min(1100px, 100%);
  margin: 0 auto;
  padding: 16px;
}

.topbar,
.section-head,
.toolbar,
.item-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.topbar {
  margin-bottom: 16px;
  padding: 14px;
  border: 1px solid rgba(255, 255, 255, 0.62);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.66);
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 25px;
  line-height: 1.12;
  letter-spacing: 0;
}

h2 {
  font-size: 17px;
  line-height: 1.25;
  letter-spacing: 0;
}

.topbar p,
.section-head p,
.toolbar p,
.status {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
  margin-top: 3px;
}

.profile-panel,
.preview,
.item {
  background: rgba(255, 255, 255, 0.82);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
}

.profile-panel {
  padding: 14px;
  margin-bottom: 14px;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(300px, 0.72fr);
  gap: 14px;
  align-items: start;
}

.knowledge-column {
  min-width: 0;
}

label {
  display: block;
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 8px;
}

textarea,
input,
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfd;
  background: color-mix(in srgb, var(--panel) 88%, var(--bg));
  color: var(--text);
  padding: 10px 11px;
  outline: none;
}

textarea:focus,
input:focus,
select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 16%, transparent);
}

textarea {
  resize: vertical;
  line-height: 1.4;
}

button {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-strong);
  color: var(--text);
  padding: 9px 12px;
  cursor: pointer;
}

button:active {
  transform: translateY(1px);
}

.primary {
  border-color: var(--accent);
  background: var(--accent);
  color: var(--accent-text);
  font-weight: 650;
}

.danger {
  color: var(--danger);
}

.toolbar {
  margin: 2px 0 10px;
}

.items {
  display: grid;
  gap: 10px;
}

.item {
  --item-accent: var(--accent);
  position: relative;
  overflow: hidden;
  padding: 12px;
  cursor: pointer;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;
}

.item::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 5px;
  background: var(--item-accent);
}

.item::after {
  content: attr(data-type);
  position: absolute;
  top: 10px;
  right: 10px;
  max-width: 110px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  border: 1px solid color-mix(in srgb, var(--item-accent) 40%, transparent);
  border-radius: 999px;
  background: color-mix(in srgb, var(--item-accent) 12%, #ffffff);
  color: color-mix(in srgb, var(--item-accent) 86%, #17202b);
  padding: 3px 8px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
}

.item:hover {
  transform: translateY(-1px);
}

.item.selected {
  border-color: color-mix(in srgb, var(--item-accent) 54%, var(--line));
  box-shadow: 0 16px 34px color-mix(in srgb, var(--item-accent) 18%, rgba(25, 31, 40, 0.08));
}

.item.disabled {
  opacity: 0.68;
}

.item-head,
.tags-row {
  display: grid;
  gap: 8px;
}

.item-head {
  grid-template-columns: minmax(0, 1fr) 150px;
  padding-right: 112px;
}

.tags-row {
  grid-template-columns: 1fr;
  margin-top: 8px;
}

.item .content {
  margin-top: 8px;
}

.item-actions {
  margin-top: 8px;
}

.importance {
  margin-top: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.48);
  padding: 10px;
}

.importance-head,
.importance-scale {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.importance-head span {
  color: var(--muted);
  font-size: 13px;
}

.importance-head strong {
  color: var(--text);
  font-size: 13px;
  font-weight: 750;
  white-space: nowrap;
}

input[type="range"].priority {
  height: 28px;
  border: 0;
  padding: 0;
  margin: 6px 0 2px;
  background: transparent;
  accent-color: var(--item-accent);
}

input[type="range"].priority:focus {
  box-shadow: none;
}

.importance-scale span {
  color: var(--muted);
  font-size: 11px;
}

.check {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: 0;
}

.check input {
  width: auto;
}

.preview {
  position: sticky;
  top: 12px;
  padding: 14px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.9), rgba(255, 255, 255, 0.76)),
    radial-gradient(circle at 12% 0%, rgba(51, 144, 236, 0.18), transparent 36%);
}

.chat-sample {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}

.bubble {
  width: min(100%, 360px);
  border-radius: 8px;
  padding: 11px 12px;
  border: 1px solid var(--line);
  box-shadow: 0 8px 18px rgba(25, 31, 40, 0.06);
}

.bubble p {
  font-size: 14px;
  line-height: 1.38;
  white-space: pre-wrap;
}

.bubble-label {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 4px;
}

.incoming {
  background: #f3f6f3;
  background: color-mix(in srgb, var(--panel) 88%, #d8e3dc);
}

.outgoing {
  justify-self: end;
  background: #eef6ff;
  background: color-mix(in srgb, var(--accent) 13%, var(--panel));
  border-color: color-mix(in srgb, var(--accent) 34%, var(--line));
}

.facts {
  margin-top: 12px;
  border-top: 1px solid var(--line);
  padding-top: 12px;
}

.facts span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 4px;
}

.facts strong {
  display: block;
  font-size: 15px;
  line-height: 1.3;
}

.facts p {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
  margin-top: 6px;
  white-space: pre-wrap;
}

.status {
  min-height: 24px;
  padding: 12px 0 20px;
}

@media (max-width: 760px) {
  .workspace {
    grid-template-columns: 1fr;
  }

  .preview {
    position: static;
  }
}

@media (max-width: 560px) {
  .shell {
    padding: 12px;
  }

  .topbar,
  .toolbar,
  .item-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .item-head,
  .tags-row {
    grid-template-columns: 1fr;
  }

  .item-head {
    padding-right: 0;
    padding-top: 28px;
  }

  .item::after {
    right: 12px;
    left: 12px;
    width: fit-content;
    max-width: calc(100% - 24px);
  }

  .topbar .primary {
    width: 100%;
  }
}
