/* ===== Design tokens ===== */
:root {
  --bg: #ffffff;
  --card-bg: rgba(245, 243, 240, 0.96);
  --border: #d5d0c8;
  --text-primary: #1a1a1a;
  --text-secondary: #6b6b6b;
  --accent: #2b4c7e;
  --accent-light: #d6e4f0;
  --danger: #c0392b;
  --qbox-bg: #dce9f3;
  --qbox-header: #b8cfe0;
  --tab-active-bg: #2b3a52;
  --tab-inactive-bg: #e4e0db;
  --warning-bg: #fff8e6;
  --warning-text: #8a6300;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1a1a1a;
    --card-bg: rgba(38, 36, 33, 0.96);
    --border: #3a3632;
    --text-primary: #e0ddd8;
    --text-secondary: #9a9590;
    --accent: #6b9fd4;
    --accent-light: #2a3a4d;
    --qbox-bg: #253545;
    --qbox-header: #1e2d3d;
    --tab-active-bg: #3a5068;
    --tab-inactive-bg: #2a2826;
    --warning-bg: #2a2410;
    --warning-text: #e0b84a;
  }
}

/* ===== Reset & base ===== */
* { box-sizing: border-box; }
body {
  margin: 0;
  padding: 0;
  background-color: var(--bg);
  background-size: cover;
  background-position: center;
  background-attachment: fixed;
  background-repeat: no-repeat;
  color: var(--text-primary);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  min-height: 100vh;
}

/* ===== Page wrapper — wide ===== */
.page-wrapper {
  max-width: 1300px;
  margin: 20px auto;
  padding: 0 24px;
}

/* Legacy container for sub-pages */
.container {
  max-width: 600px;
  margin: 0 auto;
  padding: 24px 16px 64px;
}

/* ===== Banner — wide and prominent ===== */
.banner-card {
  width: 100%;
  height: 280px;
  overflow: hidden;
  background: var(--card-bg);
  border: 1px solid var(--border);
}
.banner-card img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* ===== Two-column layout ===== */
.two-col {
  display: flex;
  gap: 18px;
  align-items: flex-start;
  margin-top: 0;
  position: relative;
  z-index: 2;
  padding: 0;
}

/* ===== Profile widget (left) ===== */
.profile-widget {
  width: 280px;
  flex-shrink: 0;
  background: var(--card-bg);
  border: 1px solid var(--border);
  padding: 0 22px 28px;
  text-align: center;
  margin-top: 20px;             /* card sits well below banner */
}

/* Avatar pokes above the widget card into the banner */
.avatar-poke {
  display: flex;
  justify-content: center;
  margin-top: -95px;            /* avatar peeks well into the banner */
  margin-bottom: 14px;
}
.profile-avatar {
  width: 160px;
  height: 160px;
  border-radius: 6px;
  object-fit: cover;
  border: 4px solid var(--card-bg);
  box-shadow: 0 3px 16px rgba(0,0,0,0.24);
  display: block;
}

.profile-info {
  margin-bottom: 4px;
}
.profile-name {
  font-weight: 700;
  font-size: 19px;
}
.profile-handle {
  font-size: 13px;
  color: var(--text-secondary);
}

.profile-bio-area {
  margin-top: 16px;
  text-align: left;
}
.profile-bio {
  font-size: 13px;
  line-height: 1.65;
  margin-bottom: 14px;
  white-space: pre-wrap;
}
.profile-links {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.profile-link {
  font-size: 12px;
  padding: 5px 10px;
  border-radius: 4px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--accent);
  text-decoration: none;
  transition: background 0.15s;
  display: inline-block;
  width: fit-content;
}
.profile-link:hover {
  background: var(--accent-light);
}

/* ===== Right column ===== */
.right-col {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0;
  margin-top: 20px;
}

/* ===== Question box ===== */
.qbox {
  background: var(--qbox-bg);
  border: 1px solid var(--border);
}
.qbox-header {
  background: var(--qbox-header);
  padding: 9px 16px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
}
.qbox-body {
  padding: 12px 16px;
}
.qbox-body textarea {
  width: 100%;
  min-height: 56px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: #fff;
  color: #1a1a1a;
  font-size: 14px;
  font-family: inherit;
  resize: vertical;
}
@media (prefers-color-scheme: dark) {
  .qbox-body textarea {
    background: #1e1e1e;
    color: #e0ddd8;
  }
}
.qbox-actions {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 10px;
  padding: 0 16px 10px;
}
.qbox-actions #ask-status {
  font-size: 13px;
  color: var(--text-secondary);
  margin-right: auto;
}

/* ===== Tab pills (under qbox, right column) ===== */
.tab-pills {
  display: flex;
  gap: 0;
}
.tab-pills a {
  flex: 1;
  text-align: center;
  padding: 11px 16px;
  font-size: 14px;
  font-weight: 700;
  text-decoration: none;
  color: var(--text-secondary);
  background: var(--tab-inactive-bg);
  border: 1px solid var(--border);
  border-top: none;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.tab-pills a:first-child {
  border-right: none;
}
.tab-pills a:hover {
  color: var(--text-primary);
}
.tab-pills a.active {
  background: var(--tab-active-bg);
  color: #fff;
  border-color: var(--tab-active-bg);
}

/* ===== Content area (under tabs, right column) ===== */
.content-area {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-top: none;
  min-height: 300px;
  padding: 18px;
}
.tab-panel {
  display: none;
}
.tab-panel.active {
  display: block;
}

/* ===== Works grid ===== */
.works-grid {
  display: grid;
  gap: 12px;
}
.card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px 16px;
  text-decoration: none;
  display: block;
  color: inherit;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.card:hover {
  border-color: var(--accent);
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}
.card-title { font-weight: 600; font-size: 15px; margin-bottom: 3px; }
.card-date { font-size: 13px; color: var(--text-secondary); }

/* ===== Message cards ===== */
.msg-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px 18px;
  margin-bottom: 12px;
}
.msg-sender {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-secondary);
  margin-bottom: 4px;
  text-transform: lowercase;
}
.msg-sender-owner {
  color: var(--accent);
}
.msg-question {
  font-size: 16px;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
  overflow-wrap: break-word;
  color: var(--text-primary);
  margin-bottom: 0;
}
.msg-divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 10px 0;
}
.msg-reply {
  font-size: 16px;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
  overflow-wrap: break-word;
}
.msg-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 10px;
  font-size: 13px;
  color: var(--text-secondary);
}
.msg-actions { display: flex; gap: 8px; margin-top: 12px; }

/* ===== Form elements (sub-pages) ===== */
h1 {
  font-size: 20px;
  font-weight: 600;
  margin-bottom: 4px;
}
.subtitle {
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: 20px;
}
textarea, input[type=text] {
  width: 100%;
  padding: 10px 12px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--card-bg);
  color: var(--text-primary);
  font-size: 14px;
  font-family: inherit;
}
textarea { min-height: 100px; resize: vertical; }

button {
  padding: 9px 20px;
  border-radius: 4px;
  border: 1px solid var(--accent);
  background: var(--accent);
  color: #fff;
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
  transition: opacity 0.15s;
}
button:hover { opacity: 0.88; }
button.secondary {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-primary);
}

/* ===== Utility ===== */
.loading-note, .empty-hint {
  font-size: 14px;
  color: var(--text-secondary);
  padding: 32px 0;
  text-align: center;
}
.error-note {
  font-size: 13px;
  color: var(--danger);
  margin-top: 8px;
}
.success-note {
  font-size: 13px;
  color: var(--text-secondary);
  margin-top: 8px;
}
.honeypot { position: absolute; left: -9999px; opacity: 0; }

/* ===== Share button ===== */
.msg-share {
  display: flex;
  justify-content: flex-end;
  margin-top: 10px;
  padding-top: 8px;
}
.share-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  color: var(--text-secondary);
  text-decoration: none;
  transition: color 0.15s, background 0.15s;
}
.share-btn:hover {
  color: var(--accent);
  background: var(--accent-light);
}

/* ===== Responsive ===== */
@media (max-width: 800px) {
  .two-col {
    flex-direction: column;
    align-items: stretch;
    margin-top: 10px;
    padding: 0 10px;
    gap: 14px;
  }
  .profile-widget {
    width: 100%;
    margin-top: -40px;
  }
  .avatar-poke {
    margin-top: -40px;
  }
  .right-col {
    margin-top: 0;
    width: 100%;
  }
  .banner-card {
    height: 180px;
  }
  .page-wrapper {
    margin: 0;
    padding: 0;
  }
}
