:root{
  --background:#090909;
  --panel-soft:rgba(30,30,30,.72);
  --text:#f2eee8;
  --muted:#938d84;
  --gold:#d5ad72;
  --gold-soft:#9a784d;
  --border:rgba(255,255,255,.10);
}

*{box-sizing:border-box}

html,
body{
  margin:0;
  height:100%;
  background:var(--background);
  color:var(--text);
  font-family:Inter,-apple-system,BlinkMacSystemFont,"Segoe UI",sans-serif;
  overflow:hidden;
}

body{
  height:100dvh;
}

.page{
  height:100dvh;
  display:grid;
  grid-template-columns:minmax(360px,45%) 1fr;
  background:#050505;
  overflow:hidden;
}

.profile{
  position:relative;
  overflow:hidden;
  height:100%;
  min-height:0;
  display:flex;
  align-items:flex-end;
}

.ari-photo{
  position:absolute;
  width:100%;
  height:100%;
  object-fit:cover;
  object-position:center;
  inset:0;
}

.profile-overlay{
  position:absolute;
  inset:0;
  z-index:1;
  background:
    linear-gradient(
      to bottom,
      rgba(0,0,0,.05),
      rgba(0,0,0,.15) 45%,
      rgba(0,0,0,.92)
    );
}

.profile-content{
  position:relative;
  z-index:2;
  width:100%;
  padding:48px;
}

.brand h1{
  margin:0;
  font-family:Georgia,serif;
  font-weight:400;
  font-size:clamp(48px,6vw,88px);
  letter-spacing:5px;
  color:#e4c28d;
}

.brand p{
  margin:6px 0;
  font-family:Georgia,serif;
  font-size:24px;
  color:#d0aa72;
}

.brand span{
  font-size:14px;
  color:#b19a78;
}

.socials{
  margin-top:28px;
  display:flex;
  gap:20px;
  flex-wrap:wrap;
}

.socials a{
  color:var(--text);
  text-decoration:none;
  font-size:14px;
  opacity:.75;
}

.socials a:hover{
  opacity:1;
  color:var(--gold);
}

.track-card{
  margin-top:34px;
  max-width:480px;
  display:flex;
  align-items:center;
  gap:16px;
  padding:15px;
  background:rgba(8,8,8,.78);
  border:1px solid var(--border);
  border-radius:17px;
  backdrop-filter:blur(18px);
}

.track-cover{
  width:72px;
  height:72px;
  flex-shrink:0;
  border-radius:9px;
  background:linear-gradient(135deg,#151515,#493029);
}

.track-info{
  display:flex;
  flex-direction:column;
  flex:1;
}

.track-info small{
  color:var(--muted);
  font-size:11px;
  letter-spacing:1.3px;
}

.track-info strong{
  margin-top:3px;
  font-size:20px;
}

.track-info span{
  margin-top:4px;
  font-size:13px;
  color:var(--muted);
}

.play-button{
  width:52px;
  height:52px;
  border-radius:50%;
  border:1px solid var(--gold);
  background:transparent;
  color:var(--gold);
  cursor:pointer;
  font-size:19px;
}

.chat{
  height:100%;
  min-height:0;
  display:flex;
  flex-direction:column;
  overflow:hidden;
  background:radial-gradient(circle at top left, rgba(86,62,39,.10), transparent 30%), #090a0b;
}

.chat-header{
  height:86px;
  display:flex;
  align-items:center;
  gap:14px;
  padding:0 34px;
  border-bottom:1px solid var(--border);
  flex:0 0 auto;
}

.chat-header strong{
  display:block;
  font-size:21px;
}

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

.status-dot{
  width:11px;
  height:11px;
  border-radius:50%;
  background:#28c76f;
  box-shadow:0 0 10px rgba(40,199,111,.35);
  flex-shrink:0;
}

.messages{
  flex:1 1 auto;
  min-height:0;
  overflow-y:auto;
  overflow-x:hidden;
  padding:36px;
  display:flex;
  flex-direction:column;
  gap:20px;
  scrollbar-gutter:stable;
}

.message{
  max-width:72%;
}

.ari-message{
  align-self:flex-start;
}

.user-message{
  align-self:flex-end;
}

.author{
  display:block;
  font-size:12px;
  color:var(--muted);
  margin:0 0 6px 5px;
}

.bubble{
  padding:15px 18px;
  border-radius:18px;
  line-height:1.5;
  background:var(--panel-soft);
  border:1px solid var(--border);
  word-break:break-word;
  overflow-wrap:anywhere;
}

.user-message .bubble{
  background:linear-gradient(135deg,rgba(103,77,49,.95),rgba(54,43,32,.95));
}

.sticker-message{
  max-width:none;
}

.ari-sticker{
  display:block;
  width:168px;
  max-width:42vw;
  height:auto;
}

.quick-actions{
  flex:0 0 auto;
  padding:12px 28px;
  display:flex;
  gap:10px;
  overflow-x:auto;
  overflow-y:hidden;
  border-top:1px solid rgba(255,255,255,.04);
}

.quick-actions button{
  white-space:nowrap;
  padding:10px 14px;
  border-radius:11px;
  background:transparent;
  color:#d8d6d2;
  border:1px solid var(--border);
  cursor:pointer;
}

.chat-input{
  flex:0 0 auto;
  padding:18px 28px 24px;
  display:flex;
  gap:12px;
  border-top:1px solid var(--border);
}

.chat-input textarea{
  flex:1;
  min-height:44px;
  max-height:180px;
  padding:15px 18px;
  border-radius:15px;
  border:1px solid var(--border);
  outline:none;
  color:var(--text);
  background:rgba(20,20,20,.85);
  font:inherit;
  resize:none;
  overflow-y:auto;
}

.chat-input textarea:focus{
  border-color:var(--gold-soft);
}

.send-button{
  width:52px;
  height:52px;
  flex-shrink:0;
  border:none;
  border-radius:50%;
  background:var(--gold);
  color:#17120c;
  font-size:20px;
  cursor:pointer;
}

@media (max-width:850px){
  html,
  body{
    overflow:auto;
  }

  body{
    height:auto;
    min-height:100dvh;
  }

  .page{
    height:auto;
    min-height:100dvh;
    grid-template-columns:1fr;
    overflow:visible;
  }

  .profile{
    min-height:620px;
  }

  .profile-content{
    padding:30px 24px;
  }

  .chat{
    min-height:720px;
    height:auto;
  }

  .messages{
    min-height:0;
    padding:24px 18px;
  }

  .message{
    max-width:88%;
  }

  .quick-actions,
  .chat-input{
    padding-left:18px;
    padding-right:18px;
  }
}

.message-paragraph{
  margin:0;
}

.message-paragraph + .message-paragraph{
  margin-top:12px;
}

.message-spacer{
  height:10px;
}

.message-section{
  margin:14px 0 8px;
  font-size:13px;
  font-weight:600;
  letter-spacing:.5px;
  color:var(--gold);
}

.message-quote{
  margin:10px 0;
  padding:10px 14px;
  border-left:3px solid var(--gold-soft);
  background:rgba(255,255,255,.035);
  border-radius:8px;
  color:#ddd7ce;
}

.message-list{
  margin:8px 0 8px 20px;
  padding:0;
}

.message-list li{
  margin:5px 0;
}
.emoji-wrapper{
  position:relative;
  display:flex;
  align-items:flex-end;
}

.emoji-button{
  width:44px;
  height:44px;
  border-radius:12px;
  border:1px solid var(--border);
  background:rgba(255,255,255,.03);
  color:var(--text);
  font-size:20px;
  cursor:pointer;
}

.emoji-button:hover{
  background:rgba(255,255,255,.07);
}

.emoji-panel{
  position:absolute;
  left:0;
  bottom:54px;
  width:210px;
  padding:10px;
  display:grid;
  grid-template-columns:repeat(4,1fr);
  gap:6px;
  border:1px solid var(--border);
  border-radius:14px;
  background:rgba(18,18,18,.98);
  box-shadow:0 12px 30px rgba(0,0,0,.35);
  z-index:20;
}

.emoji-panel.hidden{
  display:none;
}

.emoji-panel button{
  width:40px;
  height:40px;
  border:0;
  border-radius:9px;
  background:transparent;
  font-size:21px;
  cursor:pointer;
}

.emoji-panel button:hover{
  background:rgba(255,255,255,.08);
}
.emoji-only{
  background:transparent !important;
  border:0 !important;
  padding:4px 6px !important;
  font-size:32px;
  line-height:1;
}


/* Ari mobile chat layout */
@media (max-width:600px){
  html, body{
    height:100%;
    overflow:hidden;
  }

  body, .page{
    height:100dvh;
    min-height:0;
  }

  .page{
    grid-template-columns:1fr;
    grid-template-rows:minmax(230px,38dvh) minmax(0,1fr);
    overflow:hidden;
  }

  .profile{
    height:100%;
    min-height:0;
  }

  .profile-content{
    padding:16px 18px;
  }

  .brand h1{
    font-size:clamp(36px,9vw,52px);
    letter-spacing:2px;
    line-height:1;
  }

  .brand p{
    font-size:17px;
    margin:3px 0;
  }

  .brand span{
    font-size:11px;
  }

  .socials{
    margin-top:10px;
    gap:8px 14px;
  }

  .socials a{
    font-size:12px;
  }

  .track-card{
    margin-top:12px;
    max-width:none;
    padding:8px;
    gap:10px;
  }

  .track-cover{
    width:44px;
    height:44px;
  }

  .track-info strong{
    font-size:16px;
  }

  .track-info span{
    font-size:11px;
  }

  .play-button{
    width:42px;
    height:42px;
    flex-shrink:0;
  }

  .chat{
    height:100%;
    min-height:0;
  }

  .messages{
    flex:1 1 auto;
    min-height:0;
    overflow-y:auto;
  }

  .quick-actions,
  .chat-input{
    flex-shrink:0;
  }
}

@media (max-width:600px) and (max-height:500px){
  html, body{
    height:auto;
    overflow:auto;
  }

  .page{
    height:auto;
    min-height:100dvh;
    grid-template-rows:230px minmax(420px,1fr);
    overflow:visible;
  }

  .chat{
    min-height:420px;
  }
}


/* Compact mobile profile and player */
@media (max-width:600px){
  .page{
    grid-template-rows:minmax(150px,20dvh) minmax(0,1fr);
  }

  .ari-photo{
    object-position:center 38%;
  }

  .profile-content{
    display:grid;
    grid-template-columns:minmax(0,1fr) 128px;
    grid-template-areas:
      "brand track"
      "socials socials";
    column-gap:8px;
    row-gap:8px;
    align-items:end;
    padding:12px 14px;
  }

  .brand{
    grid-area:brand;
    min-width:0;
  }

  .brand h1{
    font-size:clamp(24px,7vw,30px);
    letter-spacing:1px;
    white-space:nowrap;
  }

  .brand p{
    font-size:13px;
    white-space:nowrap;
    overflow:hidden;
    text-overflow:ellipsis;
  }

  .brand span{
    display:none;
  }

  .socials{
    grid-area:socials;
    margin:0;
    gap:6px 14px;
  }

  .socials a{
    font-size:12px;
    text-shadow:0 1px 5px #000;
  }

  .track-card{
    grid-area:track;
    min-width:0;
    max-width:none;
    height:52px;
    margin:0;
    padding:6px;
    gap:5px;
    border-radius:12px;
  }

  .track-cover,
  .track-info small,
  .track-info span{
    display:none;
  }

  .track-info{
    min-width:0;
  }

  .track-info strong{
    margin:0;
    font-size:12px;
    white-space:nowrap;
    overflow:hidden;
    text-overflow:ellipsis;
  }

  .play-button{
    width:38px;
    height:38px;
    flex:0 0 38px;
    font-size:15px;
  }

  .chat-header{
    min-height:64px;
    padding:10px 18px;
  }
}

@media (max-width:350px){
  .brand h1{
    font-size:22px;
  }
}

@media (max-width:600px) and (max-height:500px){
  .page{
    grid-template-rows:170px minmax(420px,1fr);
  }
}


/* Mobile status beside brand */
@media (max-width:600px){
  .chat-header{
    display:none;
  }

  .brand h1{
    display:flex;
    align-items:center;
    gap:9px;
  }

  .brand h1::after{
    content:"";
    display:block;
    width:9px;
    height:9px;
    flex:0 0 9px;
    border-radius:50%;
    background:#32cf86;
    box-shadow:0 0 10px rgba(50,207,134,.75);
  }

  .messages{
    padding-top:16px;
  }
}


/* Ari playlist */
.track-player{
  position:relative;
  z-index:3;
  margin-top:34px;
  max-width:480px;
}

.track-player .track-card{
  margin-top:0;
  max-width:none;
}

.playlist-button{
  width:42px;
  height:42px;
  flex-shrink:0;
  border:1px solid var(--border);
  border-radius:50%;
  background:rgba(255,255,255,.06);
  color:var(--gold);
  cursor:pointer;
  font-size:18px;
}

.track-list{
  position:absolute;
  left:0;
  right:0;
  bottom:calc(100% + 8px);
  max-height:min(280px,38dvh);
  overflow-y:auto;
  padding:6px;
  border:1px solid var(--border);
  border-radius:14px;
  background:rgba(15,15,15,.97);
  box-shadow:0 12px 28px rgba(0,0,0,.45);
}

.track-list[hidden]{
  display:none;
}

.track-option{
  display:block;
  width:100%;
  padding:10px 12px;
  border:0;
  border-radius:9px;
  background:transparent;
  color:var(--text);
  text-align:left;
  font:inherit;
  cursor:pointer;
}

.track-option:hover,
.track-option:focus-visible,
.track-option.active{
  background:rgba(213,173,114,.17);
  color:var(--gold);
}

@media (max-width:600px){
  .track-player{
    margin-top:12px;
    max-width:none;
  }

  .track-list{
    max-height:min(190px,24dvh);
  }

  .playlist-button{
    width:36px;
    height:36px;
  }
}

/* Mobile playlist layout fix */
@media (max-width:600px){
  .page{
    grid-template-rows:minmax(184px,23dvh) minmax(0,1fr);
  }

  .profile-content{
    grid-template-columns:minmax(0,1fr);
    grid-template-areas:"brand" "socials" "track";
    row-gap:7px;
  }

  .track-player{
    grid-area:track;
    width:100%;
    min-width:0;
    margin-top:0;
  }

  .track-player .track-card{
    grid-area:auto;
    width:100%;
    height:46px;
    gap:9px;
  }

  .track-info strong{
    font-size:14px;
  }

  .playlist-button{
    width:auto;
    min-width:62px;
    height:36px;
    padding:0 9px;
    border-radius:9px;
    font-size:13px;
  }

  body.playlist-open::after{
    content:"";
    position:fixed;
    inset:0;
    z-index:9999;
    background:rgba(0,0,0,.68);
  }

  body.playlist-open .track-list{
    position:fixed;
    left:16px;
    right:16px;
    top:50%;
    bottom:auto;
    z-index:10000;
    transform:translateY(-50%);
    max-height:min(380px,65dvh);
    padding:10px;
  }

  body.playlist-open .track-list::before{
    content:"Выбери трек";
    display:block;
    padding:7px 12px 10px;
    color:var(--gold);
    font-size:14px;
  }

  .track-option{
    min-height:44px;
  }
}

@media (max-width:600px) and (max-height:500px){
  .page{
    grid-template-rows:184px minmax(420px,1fr);
  }
}
