:root {
  --burnt-orange: #F07818;
  --deep-orange: #E07020;
  --maroon: #8B0A28;
  --rust: #C04A10;
  --warm-cream: #F2E8D4;
  --pale-cream: #FBF5E8;
  --gold: #D4A010;
  --bright-gold: #F0BC20;
  --brown: #5C4A3C;
  --black: #1C1008;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--brown);
  background:
    radial-gradient(circle at 50% 18%, rgba(251, 245, 232, .46), transparent 30%),
    linear-gradient(155deg, #C04A10 0%, #E07020 34%, #F07818 64%, #D4A010 100%);
  font-family: "Lora", serif;
}

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

.shell { min-height: 100vh; }

.auth-card {
  width: min(720px, calc(100% - 32px));
  margin: 0 auto;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  text-align: center;
  padding: 48px 0;
}

.auth-card::before {
  content: "ॐ";
  position: fixed;
  inset: 7vh 0 auto;
  z-index: -1;
  color: rgba(251, 245, 232, .13);
  font-family: Georgia, serif;
  font-size: clamp(12rem, 34vw, 28rem);
  line-height: 1;
  text-align: center;
}

.vik-logo {
  width: min(250px, 58vw);
  height: auto;
  margin: 0 auto 26px;
  filter: drop-shadow(0 14px 22px rgba(28, 16, 8, .16));
}

.bar-logo {
  width: 92px;
  height: auto;
  flex: 0 0 auto;
}

.eyebrow {
  margin: 0 0 10px;
  color: rgba(28, 16, 8, .68);
  font-family: "Cormorant Garamond", serif;
  font-variant: small-caps;
  letter-spacing: .16em;
  font-weight: 700;
}

h1, h2, h3 {
  margin: 0;
  color: var(--pale-cream);
  font-family: "Cinzel", serif;
  letter-spacing: 0;
}

h1 {
  font-size: clamp(2.55rem, 8vw, 6rem);
  line-height: 1.02;
  text-shadow: 0 12px 34px rgba(28, 16, 8, .22);
}

h2 { font-size: clamp(1.35rem, 4vw, 2.05rem); }
h3 { color: var(--maroon); font-size: 1.08rem; }

.domain {
  margin: 14px 0 0;
  color: rgba(251, 245, 232, .92);
  font-family: "Cormorant Garamond", serif;
  font-size: 1.16rem;
  font-weight: 700;
  letter-spacing: .08em;
}

.intro {
  width: min(560px, 100%);
  margin: 24px auto 0;
  color: rgba(28, 16, 8, .78);
  font-size: 1.04rem;
  line-height: 1.75;
}

.tabs {
  width: min(520px, 100%);
  margin: 30px auto 0;
  padding: 5px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 5px;
  border: 1px solid rgba(251, 245, 232, .5);
  border-radius: 8px;
  background: rgba(251, 245, 232, .18);
}

.tab {
  min-height: 42px;
  border-color: transparent;
  color: rgba(28, 16, 8, .78);
  background: transparent;
}

.tab:hover,
.tab.active {
  color: var(--maroon);
  background: rgba(251, 245, 232, .82);
}

.form {
  width: min(440px, 100%);
  margin: 22px auto 0;
  display: grid;
  gap: 14px;
}

label {
  display: grid;
  gap: 7px;
  text-align: left;
  color: rgba(28, 16, 8, .78);
  font-family: "Cormorant Garamond", serif;
  font-size: 1.08rem;
  font-weight: 700;
}

.compact-label {
  min-width: 190px;
  gap: 5px;
  color: rgba(251, 245, 232, .84);
  font-size: .95rem;
}

.panel .compact-label {
  color: rgba(92, 74, 60, .82);
}

.compact-label select {
  min-height: 40px;
  padding: 7px 10px;
}

input,
textarea,
select {
  width: 100%;
  min-height: 46px;
  border: 1px solid rgba(139, 10, 40, .24);
  border-radius: 6px;
  padding: 10px 12px;
  color: var(--black);
  background: rgba(251, 245, 232, .9);
}

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

select {
  cursor: pointer;
}

button {
  min-height: 46px;
  border: 1px solid rgba(139, 10, 40, .4);
  border-radius: 6px;
  padding: 10px 16px;
  color: var(--pale-cream);
  background: var(--maroon);
  cursor: pointer;
  font-family: "Cormorant Garamond", serif;
  font-weight: 700;
  letter-spacing: .03em;
}

button:hover { background: #6f0820; }

.secondary {
  color: var(--maroon);
  background: rgba(251, 245, 232, .78);
}

.secondary:hover { background: var(--pale-cream); }

.language-button.active {
  color: var(--pale-cream);
  background: var(--deep-orange);
  border-color: rgba(240, 188, 32, .7);
}

.comment-icon { display: none; }

.hint,
.message,
.empty {
  min-height: 24px;
  margin: 10px 0 0;
  color: rgba(28, 16, 8, .76);
  line-height: 1.55;
}

.hint {
  font-size: .92rem;
  font-style: italic;
}

.reader, .admin {
  min-height: 100vh;
  background: var(--warm-cream);
}

.reader-bar {
  min-height: 72px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 12px 18px;
  background: rgba(28, 16, 8, .96);
  border-bottom: 1px solid rgba(212, 160, 16, .32);
}

.reader-title {
  display: flex;
  align-items: center;
  gap: 16px;
}

.reader-bar .eyebrow { color: rgba(240, 188, 32, .72); }
.reader-bar h2 { color: var(--pale-cream); }

.actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

iframe {
  width: 100%;
  height: calc(100vh - 72px);
  display: block;
  border: 0;
  background: var(--pale-cream);
}

#readerView .reader-bar {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 30;
  min-height: 0;
  width: auto;
  max-width: calc(100vw - 32px);
  padding: 8px;
  border: 1px solid rgba(212, 160, 16, .42);
  border-radius: 8px;
  background: rgba(28, 16, 8, .88);
  box-shadow: 0 16px 36px rgba(28, 16, 8, .2);
}

#readerView .reader-title {
  display: none;
}

#readerView iframe {
  height: 100vh;
}

#readerView .actions {
  gap: 6px;
}

#readerView button {
  min-height: 38px;
  padding: 7px 11px;
}

.comments-panel {
  position: fixed;
  right: 18px;
  top: 18px;
  bottom: 82px;
  z-index: 35;
  width: min(430px, calc(100vw - 36px));
  display: grid;
  grid-template-rows: auto 1fr auto;
  border: 1px solid rgba(212, 160, 16, .42);
  border-radius: 8px;
  background: var(--pale-cream);
  box-shadow: 0 22px 60px rgba(28, 16, 8, .22);
  overflow: hidden;
}

.comments-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px;
  border-bottom: 1px solid rgba(92, 74, 60, .14);
  background: rgba(242, 232, 212, .72);
}

.comments-header h3 { color: var(--maroon); }
.comments-header .eyebrow { margin-bottom: 4px; color: rgba(139, 10, 40, .68); }
.comments-header button { min-height: 36px; padding: 7px 11px; }

.comments-list {
  overflow: auto;
  padding: 14px 16px;
}

.comment-card {
  padding: 12px 0;
  border-bottom: 1px solid rgba(92, 74, 60, .14);
}

.comment-card p {
  margin: 8px 0;
  color: var(--black);
  line-height: 1.55;
}

.comment-meta {
  display: flex;
  align-items: baseline;
  gap: 8px;
  flex-wrap: wrap;
  color: rgba(92, 74, 60, .78);
  font-size: .9rem;
}

.comment-meta strong {
  color: var(--maroon);
}

.comment-meta span {
  padding: 2px 7px;
  border-radius: 999px;
  color: var(--pale-cream);
  background: var(--deep-orange);
  font-size: .78rem;
}

.comment-replies {
  margin-left: 18px;
  padding-left: 14px;
  border-left: 2px solid rgba(212, 160, 16, .35);
}

.text-button {
  min-height: 0;
  padding: 0;
  border: 0;
  color: var(--maroon);
  background: transparent;
  text-decoration: underline;
}

.text-button:hover {
  background: transparent;
  color: var(--rust);
}

.comment-form {
  padding: 14px 16px 16px;
  border-top: 1px solid rgba(92, 74, 60, .14);
  background: rgba(242, 232, 212, .62);
}

.comment-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 10px;
}

.replying-to {
  margin: 0 0 10px;
  color: var(--maroon);
  font-style: italic;
}

#editorFrame {
  height: min(78vh, 820px);
  min-height: 520px;
  border: 1px solid rgba(212, 160, 16, .38);
  border-radius: 6px;
  background: var(--pale-cream);
}

.admin { padding-bottom: 36px; }

.admin-grid {
  width: min(1120px, calc(100% - 32px));
  margin: 26px auto 0;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.panel {
  margin: 0;
  padding: 20px;
  border: 1px solid rgba(212, 160, 16, .3);
  border-radius: 8px;
  background: var(--pale-cream);
  box-shadow: 0 18px 42px rgba(28, 16, 8, .08);
}

.user-list { grid-column: 1 / -1; }
.journal-editor-panel { grid-column: 1 / -1; }

.editor-tools {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0 0 12px;
}

.editor-tools button {
  min-height: 38px;
  padding: 8px 13px;
}

.panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.panel-heading p {
  margin: 6px 0 0;
  color: rgba(92, 74, 60, .78);
  line-height: 1.45;
}

.user-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(170px, auto) auto auto;
  gap: 12px;
  align-items: center;
  padding: 12px 0;
  border-top: 1px solid rgba(92, 74, 60, .16);
}

.user-row strong { color: var(--black); }
.user-row span { color: rgba(92, 74, 60, .78); }

.hidden { display: none !important; }

@media (max-width: 760px) {
  .reader-bar { align-items: flex-start; flex-direction: column; }
  #readerView .reader-bar {
    left: 12px;
    right: 12px;
    bottom: 12px;
    flex-direction: row;
    align-items: center;
    justify-content: center;
  }
  #readerView .actions {
    justify-content: center;
  }
  #readerView .comment-toggle {
    width: 42px;
    padding: 7px;
  }
  .comment-word { display: none; }
  .comment-icon { display: inline; font-size: 1.05rem; }
  .comments-panel {
    inset: auto 12px 66px 12px;
    width: auto;
    height: min(72vh, 620px);
  }
  .reader-title { align-items: flex-start; }
  .bar-logo { width: 76px; margin-top: 5px; }
  iframe { height: calc(100vh - 142px); }
  .admin-grid { grid-template-columns: 1fr; }
  .user-row { grid-template-columns: 1fr; }
  .auth-card { width: min(100% - 24px, 680px); }
  .tabs { grid-template-columns: 1fr; }
}
