
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  margin: 0;
  min-height: 100vh;
  overflow: hidden;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at top left, rgba(255, 45, 85, .20), transparent 32rem),
    linear-gradient(160deg, #020104 0%, #180713 46%, #350018 100%);
  color: #f8eef5;
}
button, input {
  font: inherit;
}
.login {
  width: min(420px, calc(100% - 32px));
  margin: 56px auto;
  padding: 20px;
  border: 1px solid rgba(155, 97, 122, .72);
  border-radius: 8px;
  background: rgba(11, 7, 16, .88);
  box-shadow: 0 24px 60px rgba(0, 0, 0, .32);
}
.shell {
  display: grid;
  grid-template-columns: minmax(240px, 340px) minmax(0, 1fr);
  height: 100vh;
  overflow: hidden;
}
.contacts {
  border-right: 1px solid rgba(155, 97, 122, .55);
  background: rgba(11, 7, 16, .80);
  height: 100vh;
  overflow: hidden;
}
.topbar, .chat-header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  padding: 18px;
  border-bottom: 1px solid rgba(155, 97, 122, .38);
}
h1, h2, p { margin-top: 0; }
h1 { font-size: 1.35rem; }
h2 { font-size: 1.15rem; }
.contact-meta {
  display: flex;
  align-items: center;
  gap: 7px;
  margin: 4px 0 0;
  font-size: .88rem;
}
.eyebrow {
  margin-bottom: 4px;
  color: #ffc857;
  font-size: .75rem;
  font-weight: 750;
  letter-spacing: .14em;
  text-transform: uppercase;
}
.muted, .status {
  color: #d8c1dd;
  line-height: 1.5;
}
label {
  display: block;
  margin: 14px 0 6px;
  font-weight: 650;
}
input {
  width: 100%;
  min-width: 0;
  padding: 10px 12px;
  border: 1px solid #9b617a;
  border-radius: 6px;
  background: #1b1024;
  color: #f8eef5;
}
button {
  padding: 10px 14px;
  border: 0;
  border-radius: 6px;
  background: #ff2d55;
  color: #250008;
  font-weight: 750;
  cursor: pointer;
}
button:disabled {
  opacity: .5;
  cursor: default;
}
.ghost {
  background: #3d1132;
  color: #ffd7df;
}
.link {
  color: #ffc857;
}
.qr-shell {
  display: inline-flex;
  margin-top: 12px;
  padding: 14px;
  border-radius: 8px;
  background: #ffffff;
  border: 1px solid #ffffff;
}
.qr-shell svg {
  display: block;
  width: min(280px, calc(100vw - 88px));
  height: auto;
}
.pairing-code {
  display: inline-block;
  margin-top: 8px;
  padding: 10px 12px;
  border-radius: 6px;
  background: #3d1132;
  color: #ffd7df;
  font-size: 1.2rem;
  font-weight: 750;
  letter-spacing: .08em;
}
.error {
  color: #ff9ab0;
  font-weight: 650;
}
.relationship-list {
  padding: 10px;
  height: calc(100vh - 86px);
  overflow-y: auto;
}
.relationship {
  width: 100%;
  margin-bottom: 8px;
  text-align: left;
  background: transparent;
  color: #f8eef5;
  border: 1px solid rgba(155, 97, 122, .38);
}
.relationship.active {
  border-color: #ff2d55;
  background: #3d1132;
}
.relationship-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: start;
}
.favorite-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border-radius: 999px;
  background: transparent;
  color: #d8c1dd;
  border: 1px solid rgba(155, 97, 122, .38);
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
  user-select: none;
}
.favorite-button.active {
  color: #ffc857;
  border-color: rgba(255, 200, 87, .55);
  background: rgba(255, 200, 87, .12);
}
.relationship small {
  display: block;
  margin-top: 3px;
  color: #d8c1dd;
}
.relationship-main {
  display: flex;
  align-items: center;
  gap: 8px;
}
.presence-dot {
  width: 9px;
  height: 9px;
  flex: 0 0 auto;
  border-radius: 999px;
  background: #6f6074;
  box-shadow: 0 0 0 2px rgba(255, 255, 255, .08);
}
.presence-dot.online {
  background: #2ee66b;
  box-shadow: 0 0 0 2px rgba(46, 230, 107, .16), 0 0 12px rgba(46, 230, 107, .55);
}
.relationship-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.relationship-lines {
  display: grid;
  gap: 3px;
  min-width: 0;
}
.relationship-line {
  display: block;
  min-height: 1.15rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.relationship-line.nickname {
  color: #ffd7df;
}
.relationship-line.meta {
  color: #d8c1dd;
  font-size: .82rem;
}
.chat {
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr) auto auto;
  height: 100vh;
  min-height: 0;
  overflow: hidden;
}
.contact-tabs {
  display: flex;
  gap: 8px;
  padding: 10px 18px;
  border-bottom: 1px solid rgba(155, 97, 122, .28);
}
.tab {
  background: transparent;
  color: #ffd7df;
  border: 1px solid rgba(155, 97, 122, .38);
}
.tab.active {
  background: #3d1132;
  border-color: #ff2d55;
}
.messages {
  padding: 18px;
  overflow-y: auto;
  min-height: 0;
}
.older-row {
  display: flex;
  justify-content: center;
  margin-bottom: 14px;
}
.message {
  max-width: min(680px, 86%);
  margin-bottom: 10px;
  padding: 10px 12px;
  border-radius: 8px;
  background: #1b1024;
  border: 1px solid rgba(155, 97, 122, .35);
  white-space: pre-wrap;
}
.message.mine {
  margin-left: auto;
  background: #3d1132;
  border-color: rgba(255, 45, 85, .48);
}
.message .meta {
  display: block;
  margin-bottom: 4px;
  color: #d8c1dd;
  font-size: .76rem;
}
.message .message-text {
  display: block;
}
.message.locked {
  color: #ffb8c8;
}
.media-attachment {
  display: grid;
  gap: 8px;
}
.media-attachment img,
.media-attachment video {
  display: block;
  max-width: min(520px, 100%);
  max-height: 420px;
  border-radius: 8px;
  background: #050308;
}
.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 12px;
}
.gallery-item {
  display: grid;
  gap: 8px;
  padding: 10px;
  border-radius: 8px;
  background: #1b1024;
  border: 1px solid rgba(155, 97, 122, .35);
}
.gallery-item img,
.gallery-item video {
  width: 100%;
  max-height: 220px;
  object-fit: cover;
  border-radius: 6px;
  background: #050308;
}
.detail-panel {
  min-height: 0;
  overflow-y: auto;
  padding: 18px;
}
.detail-header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  margin-bottom: 14px;
}
.detail-card {
  margin-bottom: 10px;
  padding: 12px;
  border-radius: 8px;
  background: #1b1024;
  border: 1px solid rgba(155, 97, 122, .35);
}
.detail-card h3 {
  margin: 0 0 6px;
  font-size: 1rem;
}
.detail-card p {
  margin-bottom: 6px;
}
.subtabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0 0 14px;
}
.subtab {
  background: transparent;
  color: #ffd7df;
  border: 1px solid rgba(155, 97, 122, .38);
}
.subtab.active {
  background: #3d1132;
  border-color: #ff2d55;
}
.subtab small {
  display: block;
  margin-top: 2px;
  color: #d8c1dd;
  font-weight: 500;
}
.task-objectives {
  display: grid;
  gap: 6px;
  margin: 8px 0;
}
.task-objective {
  display: flex;
  gap: 8px;
  align-items: flex-start;
}
.task-objective.done {
  color: #c9b8cf;
  text-decoration: line-through;
}
.task-meta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.task-chip {
  display: inline-flex;
  padding: 4px 8px;
  border-radius: 999px;
  background: rgba(255, 200, 87, .12);
  color: #ffe1a3;
  font-size: .82rem;
  font-weight: 650;
}
.action-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}
.danger {
  background: #5a1326;
  color: #ffd7df;
}
.contract-content {
  display: grid;
  gap: 10px;
  margin-top: 10px;
}
.contract-section h4 {
  margin: 0 0 4px;
  color: #ffc857;
  font-size: .9rem;
}
.contract-section ul {
  margin: 0;
  padding-left: 20px;
}
.contract-section p {
  white-space: pre-wrap;
}
.contract-editor {
  display: grid;
  gap: 10px;
}
.contract-section-editor {
  display: grid;
  gap: 10px;
  padding: 12px;
  border-radius: 8px;
  background: rgba(27, 16, 36, .68);
  border: 1px solid rgba(155, 97, 122, .35);
}
.contract-editor textarea {
  width: 100%;
  min-height: 92px;
  overflow: hidden;
  resize: none;
  padding: 10px 12px;
  border: 1px solid #9b617a;
  border-radius: 6px;
  background: #1b1024;
  color: #f8eef5;
  font: inherit;
}
.contract-editor textarea.short {
  min-height: 48px;
}
.change-request {
  margin-top: 10px;
  padding: 10px;
  border-radius: 8px;
  background: rgba(255, 200, 87, .10);
  border: 1px solid rgba(255, 200, 87, .28);
}
.empty-state {
  color: #d8c1dd;
}
.composer {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  padding: 14px 18px;
  border-top: 1px solid rgba(155, 97, 122, .38);
}
.chat > .status {
  min-height: 26px;
  margin: 0;
  padding: 0 18px 12px;
}
@media (max-width: 780px) {
  body { overflow: auto; }
  .shell { grid-template-columns: 1fr; height: auto; min-height: 100vh; overflow: visible; }
  .contacts { height: auto; max-height: 38vh; border-right: 0; border-bottom: 1px solid rgba(155, 97, 122, .55); }
  .relationship-list { height: auto; max-height: calc(38vh - 86px); }
  .chat { height: 62vh; min-height: 420px; }
}
