/* ── Reset & Base ────────────────────────────────────── */
*,
*::before,
*::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  font-size: 18px;
}

body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background-color: #f0f2f5;
  color: #333;
  display: flex;
  min-height: 100vh;
}

/* ── Sidebar ────────────────────────────────────────── */
.sidebar {
  width: 240px;
  flex-shrink: 0;
  background: #fff;
  border-right: 1px solid #e4e7ec;
  display: flex;
  flex-direction: column;
  height: 100vh;
  position: sticky;
  top: 0;
  transition: margin-left 0.25s ease, opacity 0.25s ease;
}

.sidebar--collapsed {
  margin-left: -240px;
  opacity: 0;
  pointer-events: none;
}

.sidebar__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 16px 12px;
}

.sidebar__title {
  font-size: 1rem;
  font-weight: 700;
}

.sidebar__toggle {
  background: none;
  border: none;
  cursor: pointer;
  color: #777;
  padding: 4px;
  border-radius: 6px;
}

.sidebar__toggle:hover {
  color: #333;
  background: #f0f2f5;
}

.sidebar__new-btn {
  margin: 0 12px 12px;
  padding: 9px 0;
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  color: #fff;
  background: #5a6f9a;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.2s;
}

.sidebar__new-btn:hover {
  background: #47597e;
}

.sidebar__list {
  list-style: none;
  overflow-y: auto;
  flex: 1;
  padding: 0 8px 16px;
}

.sidebar__item {
  padding: 10px 12px;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s;
  margin-bottom: 2px;
}

.sidebar__item:hover {
  background: #f0f2f5;
}

.sidebar__item--active {
  background: #e8ecf4;
}

.sidebar__item-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.sidebar__item-title {
  font-size: 0.88rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
}

.sidebar__item-fav {
  color: #e05070;
  font-size: 0.82rem;
  flex-shrink: 0;
}

.sidebar__item-time {
  display: block;
  font-size: 0.75rem;
  color: #999;
  margin-top: 2px;
}

.sidebar__rename-input {
  width: 100%;
  font-family: inherit;
  font-size: 0.88rem;
  font-weight: 600;
  padding: 2px 6px;
  border: 1px solid #7b8fbc;
  border-radius: 4px;
  outline: none;
  background: #fff;
}

.sidebar__empty {
  padding: 16px 12px;
  font-size: 0.84rem;
  color: #aaa;
  text-align: center;
}

/* ── Sidebar open button (when collapsed) ───────────── */
.sidebar__open-btn {
  position: fixed;
  top: 16px;
  left: 16px;
  z-index: 10;
  background: #fff;
  border: 1px solid #e4e7ec;
  border-radius: 8px;
  padding: 8px;
  cursor: pointer;
  color: #555;
  box-shadow: 0 1px 4px rgba(0,0,0,0.08);
}

.sidebar__open-btn:hover {
  color: #333;
  background: #f7f8fa;
}

.sidebar__open-btn[hidden] {
  display: none;
}

/* ── Main Area ──────────────────────────────────────── */
.main-area {
  flex: 1;
  display: flex;
  justify-content: flex-start;
  align-items: flex-start;
  padding: 0 12px;
  min-height: 100vh;
}

/* ── Card Container ─────────────────────────────────── */
.card {
  display: flex;
  max-width: 1280px;
  width: 100%;
  background: #fff;
  border-radius: 0;
  box-shadow: none;
  overflow: hidden;
  min-height: 100vh;
}

/* On very wide screens, give the card a soft frame but keep it pinned to the top-left */
@media (min-width: 1440px) {
  .main-area {
    padding: 10px 12px;
    align-items: flex-start;
  }

  .card {
    border-radius: 14px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.06);
    min-height: calc(100vh - 20px);
  }
}

/* ── Left Column — Wrapper (photos + video) ─────────── */
.card__left {
  flex: 0 0 58%;
  display: flex;
  flex-direction: column;
  gap: 12px;
  align-self: flex-start;
  padding: 14px 10px 12px;
}

.card__image-pair {
  display: flex;
  flex-direction: row;
  gap: 8px;
  background: transparent;
}

/* ── Instruction Video ──────────────────────────────── */
.card__video-wrap {
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.card__video-label {
  font-weight: 600;
  font-size: 0.85rem;
  color: #444;
}

.card__video {
  width: 100%;
  aspect-ratio: 16 / 9;
  background: #000;
  border-radius: 8px;
  display: block;
}

.card__image {
  background-color: #f5f7fa;
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  cursor: pointer;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background-color 0.2s;
  border-radius: 10px;
  overflow: hidden;
}

.card__image--half {
  flex: 1 1 50%;
  aspect-ratio: 4 / 3;
}

.card__image:hover {
  background-color: #e9edf3;
}

.image-upload-hint {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  color: #9aa3b3;
  font-size: 0.88rem;
  pointer-events: none;
}

.image-upload-hint[hidden] {
  display: none;
}

/* Take the hidden file input out of layout flow entirely */
.card__image input[type="file"] {
  position: absolute;
  width: 0;
  height: 0;
  opacity: 0;
  pointer-events: none;
}

/* ── Right Column — Content ─────────────────────────── */
.card__content {
  flex: 1;
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  overflow-y: auto;
}

/* ── User Info Header ───────────────────────────────── */
.user-header {
  display: flex;
  align-items: center;
  gap: 12px;
}

.user-header__avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: #b8c1cf;
  object-fit: cover;
  flex-shrink: 0;
}

.user-header__meta {
  display: flex;
  flex-direction: column;
}

.user-header__name {
  font-weight: 600;
  font-size: 0.95rem;
}

.user-header__time {
  font-size: 0.8rem;
  color: #888;
}

/* ── Activity Category ──────────────────────────────── */
.category-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.category-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 4px;
  margin: -4px;
  transition: outline 0.2s;
}

.cat-chip {
  display: inline-block;
  padding: 7px 16px;
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 500;
  border-radius: 999px;
  background: #eef1f6;
  color: #4a5568;
  border: 2px solid transparent;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s;
}

.cat-chip:hover {
  background: #dde3ed;
}

.cat-chip--selected {
  background: #d6dff2;
  border-color: #7b8fbc;
  color: #2d3a54;
  font-weight: 600;
}

/* ── Editable Fields ────────────────────────────────── */
.field-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field-label {
  font-weight: 600;
  font-size: 0.85rem;
}

.field-textarea {
  width: 100%;
  font-family: inherit;
  font-size: 0.88rem;
  line-height: 1.55;
  color: #333;
  padding: 10px 12px;
  border: 1px solid #dde1e8;
  border-radius: 8px;
  resize: vertical;
  transition: border-color 0.2s;
}

.field-textarea:focus {
  outline: none;
  border-color: #7b8fbc;
}

/* ── Q&A Section ────────────────────────────────────── */
.qa-section {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.qa-item__question {
  display: block;
  font-weight: 700;
  font-size: 0.9rem;
  margin-bottom: 4px;
}

/* ── Tags Section ───────────────────────────────────── */
.tags-section__label {
  font-weight: 600;
  font-size: 0.85rem;
  margin-bottom: 8px;
}

.tags-section__label--sub {
  margin-top: 14px;
}

.tags-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.tags-hint {
  font-weight: 400;
  font-size: 0.78rem;
  color: #999;
}

.tag-chip {
  display: inline-block;
  padding: 5px 14px;
  font-family: inherit;
  font-size: 0.8rem;
  border-radius: 999px;
  background: #eef1f6;
  color: #4a5568;
  border: 2px solid transparent;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s;
}

.tag-chip:hover {
  background: #dde3ed;
}

.tag-chip--selected {
  background: #d6dff2;
  border-color: #7b8fbc;
  color: #2d3a54;
  font-weight: 600;
}

/* ── Comments / Action Bar ──────────────────────────── */
.comments-section__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.comments-section__label {
  font-weight: 600;
  font-size: 0.85rem;
}

/* ── Star Rating ────────────────────────────────────── */
.rating {
  display: inline-flex;
  gap: 2px;
}

.rating__star {
  background: none;
  border: none;
  padding: 2px;
  cursor: pointer;
  color: #d4d8df;
  line-height: 0;
  transition: color 0.12s;
}

.rating__star svg {
  fill: currentColor;
  display: block;
  pointer-events: none;
}

.rating__star--filled {
  color: #f5b301;
}

.rating__star:hover {
  transform: scale(1.05);
}

.action-bar {
  display: flex;
  gap: 16px;
}

.action-btn {
  background: none;
  border: none;
  cursor: pointer;
  color: #777;
  font-size: 1.15rem;
  padding: 4px;
  border-radius: 6px;
  transition: color 0.2s, background 0.2s;
}

.action-btn:hover {
  color: #333;
  background: #f0f2f5;
}

.action-btn--active {
  color: #e05070;
}

.action-btn--active:hover {
  color: #c03858;
}

/* ── Comment Input & List ───────────────────────────── */
.comment-input-wrap {
  display: flex;
  gap: 8px;
  align-items: flex-end;
  margin-bottom: 8px;
}

.comment-input-wrap[hidden] {
  display: none;
}

.comment-submit-btn {
  flex-shrink: 0;
  padding: 8px 16px;
  font-family: inherit;
  font-size: 0.82rem;
  font-weight: 600;
  color: #fff;
  background: #5a6f9a;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.2s;
}

.comment-submit-btn:hover {
  background: #47597e;
}

.comment-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.comment-item {
  font-size: 0.85rem;
  line-height: 1.5;
  color: #555;
  padding: 8px 12px;
  background: #f7f8fa;
  border-radius: 8px;
}

/* ── Save Bar ───────────────────────────────────────── */
.save-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.entry-counter {
  font-size: 0.8rem;
  color: #999;
}

.save-bar__buttons {
  display: flex;
  gap: 8px;
}

.save-btn {
  padding: 10px 22px;
  font-family: inherit;
  font-size: 0.88rem;
  font-weight: 600;
  color: #fff;
  background: #5a6f9a;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.2s;
}

.save-btn:hover {
  background: #47597e;
}

.save-btn--secondary {
  background: #fff;
  color: #5a6f9a;
  border: 1px solid #5a6f9a;
}

.save-btn--secondary:hover {
  background: #f0f3f8;
}

/* ── AI Reflection Chat ─────────────────────────────── */
.card__chat-wrap {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.chat-panel {
  display: flex;
  flex-direction: column;
  background: #f7f8fa;
  border: 1px solid #e4e7ec;
  border-radius: 10px;
  height: 300px;
  overflow: hidden;
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.chat-empty {
  color: #999;
  font-size: 0.82rem;
  text-align: center;
  padding: 20px 12px;
  line-height: 1.5;
}

.chat-empty[hidden] {
  display: none;
}

.chat-msg {
  max-width: 85%;
  padding: 8px 12px;
  border-radius: 12px;
  font-size: 0.85rem;
  line-height: 1.5;
  word-wrap: break-word;
  white-space: pre-wrap;
}

.chat-msg--user {
  align-self: flex-end;
  background: #5a6f9a;
  color: #fff;
  border-bottom-right-radius: 4px;
}

.chat-msg--assistant {
  align-self: flex-start;
  background: #fff;
  color: #333;
  border: 1px solid #e4e7ec;
  border-bottom-left-radius: 4px;
}

.chat-msg--loading {
  font-style: italic;
  color: #999;
  letter-spacing: 2px;
}

.chat-input-row {
  display: flex;
  gap: 6px;
  padding: 8px;
  border-top: 1px solid #e4e7ec;
  background: #fff;
}

.chat-input {
  flex: 1;
  font-family: inherit;
  font-size: 0.85rem;
  line-height: 1.4;
  padding: 8px 10px;
  border: 1px solid #dde1e8;
  border-radius: 8px;
  resize: none;
  max-height: 80px;
  transition: border-color 0.2s;
}

.chat-input:focus {
  outline: none;
  border-color: #7b8fbc;
}

.chat-input:disabled {
  opacity: 0.6;
}

.chat-send-btn {
  padding: 8px 14px;
  font-family: inherit;
  font-size: 0.82rem;
  font-weight: 600;
  color: #fff;
  background: #5a6f9a;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.2s;
}

.chat-send-btn:hover:not(:disabled) {
  background: #47597e;
}

.chat-send-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* ── Setup Button & Modal ───────────────────────────── */
.card__setup-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 18px;
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  color: #5a6f9a;
  background: #fff;
  border: 1.5px solid #5a6f9a;
  border-radius: 8px;
  cursor: pointer;
  align-self: flex-start;
  margin-top: 4px;
  transition: background 0.2s, color 0.2s;
}

.card__setup-btn:hover,
.card__setup-btn--active {
  background: #5a6f9a;
  color: #fff;
}

.setup-modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.setup-modal[hidden] {
  display: none;
}

.setup-modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
}

.setup-modal__content {
  position: relative;
  background: #fff;
  border-radius: 14px;
  padding: 36px 40px 32px;
  max-width: 960px;
  width: 100%;
  max-height: 92vh;
  overflow-y: auto;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.25);
}

.setup-modal__close {
  position: absolute;
  top: 12px;
  right: 14px;
  background: none;
  border: none;
  font-size: 1.6rem;
  line-height: 1;
  cursor: pointer;
  color: #999;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}

.setup-modal__close:hover {
  background: #f0f2f5;
  color: #333;
}

.setup-modal__title {
  font-size: 1.35rem;
  font-weight: 700;
  margin-bottom: 24px;
  color: #333;
}

.setup-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 36px;
  align-items: start;
}

@media (max-width: 600px) {
  .setup-grid {
    grid-template-columns: 1fr;
    gap: 20px;
  }
}

.setup-face-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.setup-face {
  position: relative;
  width: 100%;
  max-width: 360px;
  aspect-ratio: 200 / 260;
}

.face-svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.setup-face-hint {
  font-size: 0.9rem;
  color: #888;
}

.face-hotspot {
  position: absolute;
  width: 13%;
  aspect-ratio: 1;
  border-radius: 50%;
  border: 2px dashed #999;
  background: rgba(255, 255, 255, 0.55);
  cursor: pointer;
  transform: translate(-50%, -50%);
  transition: transform 0.15s, border-color 0.2s, background-color 0.2s;
  padding: 0;
}

.face-hotspot:hover {
  transform: translate(-50%, -50%) scale(1.15);
  border-style: solid;
}

.face-hotspot[data-area="forehead"]    { left: 50%; top: 28%; }
.face-hotspot[data-area="middle"]      { left: 50%; top: 41%; }
.face-hotspot[data-area="left-eye"]    { left: 35%; top: 46%; }
.face-hotspot[data-area="right-eye"]   { left: 65%; top: 46%; }
.face-hotspot[data-area="nose"]        { left: 50%; top: 63%; }
.face-hotspot[data-area="left-cheek"]  { left: 30%; top: 60%; }
.face-hotspot[data-area="right-cheek"] { left: 70%; top: 60%; }

.face-hotspot[data-skin-type="oily"]        { background: #f5b301; border-color: #c79100; border-style: solid; }
.face-hotspot[data-skin-type="dry"]         { background: #c9a07a; border-color: #9a7551; border-style: solid; }
.face-hotspot[data-skin-type="combo-oily"]  { background: #f97316; border-color: #c2580f; border-style: solid; }
.face-hotspot[data-skin-type="combo-dry"]   { background: #f4a4a4; border-color: #c87878; border-style: solid; }
.face-hotspot[data-skin-type="normal"]      { background: #84c98d; border-color: #5ba266; border-style: solid; }
.face-hotspot[data-skin-type="sensitive"]   { background: #e35d5d; border-color: #b03a3a; border-style: solid; }

.setup-section + .setup-section {
  margin-top: 28px;
}

.setup-label {
  font-weight: 600;
  font-size: 1.02rem;
  margin-bottom: 12px;
  color: #333;
}

.setup-hint {
  font-weight: 400;
  font-size: 0.86rem;
  color: #999;
}

.skin-types {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.skin-type {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 18px;
  font-family: inherit;
  font-size: 0.98rem;
  font-weight: 500;
  border-radius: 999px;
  background: #fff;
  color: #4a5568;
  border: 2px solid #ddd;
  cursor: pointer;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.skin-type::before {
  content: '';
  display: inline-block;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--skin-color, #ccc);
  flex-shrink: 0;
}

.skin-type[data-type="oily"]        { --skin-color: #f5b301; }
.skin-type[data-type="dry"]         { --skin-color: #c9a07a; }
.skin-type[data-type="combo-oily"]  { --skin-color: #f97316; }
.skin-type[data-type="combo-dry"]   { --skin-color: #f4a4a4; }
.skin-type[data-type="normal"]      { --skin-color: #84c98d; }
.skin-type[data-type="sensitive"]   { --skin-color: #e35d5d; }

.skin-type:hover {
  border-color: var(--skin-color);
}

.skin-type--active {
  border-color: var(--skin-color);
  box-shadow: 0 0 0 2px var(--skin-color);
  font-weight: 600;
}

.price-list {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.price-chip {
  display: inline-block;
  padding: 9px 16px;
  font-family: inherit;
  font-size: 0.95rem;
  border-radius: 999px;
  background: #eef1f6;
  color: #4a5568;
  border: 2px solid transparent;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s;
}

.price-chip:hover {
  background: #dde3ed;
}

.price-chip--selected {
  background: #d6dff2;
  border-color: #7b8fbc;
  color: #2d3a54;
  font-weight: 600;
}

/* ── Sidebar Backdrop (mobile) ──────────────────────── */
.sidebar-backdrop {
  display: none;
}

/* ── Dividers ───────────────────────────────────────── */
.divider {
  border: none;
  border-top: 1px solid #eaedf2;
}

/* ── Mobile / Responsive ────────────────────────────── */
@media (max-width: 768px) {

  body {
    flex-direction: column;
  }

  /* Sidebar becomes a slide-over drawer */
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    z-index: 100;
    width: 280px;
    height: 100vh;
    box-shadow: 2px 0 16px rgba(0, 0, 0, 0.15);
    transition: transform 0.25s ease;
    transform: translateX(0);
  }

  .sidebar--collapsed {
    transform: translateX(-100%);
    margin-left: 0;
    opacity: 1;
  }

  /* Dark backdrop behind drawer */
  .sidebar-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 90;
    background: rgba(0, 0, 0, 0.35);
  }

  .sidebar-backdrop[hidden] {
    display: none;
  }

  /* Open button repositioned for mobile */
  .sidebar__open-btn {
    top: 12px;
    left: 12px;
    padding: 10px;
  }

  /* Main area — full width, no centering padding */
  .main-area {
    padding: 12px;
    padding-top: 56px; /* room for the open-sidebar button */
    align-items: flex-start;
    min-height: auto;
  }

  /* Card stacks vertically */
  .card {
    flex-direction: column;
    border-radius: 10px;
  }

  /* Left column (photos + video) takes full width */
  .card__left {
    flex: none;
    width: 100%;
    padding: 16px 12px 12px;
    gap: 10px;
  }

  /* Image pair stacks vertically on top */
  .card__image-pair {
    flex: none;
    width: 100%;
    flex-direction: column;
  }

  .card__image--half {
    width: 100%;
    aspect-ratio: auto;
    min-height: 180px;
    max-height: 220px;
  }

  .card__video-wrap {
    padding: 0;
  }

  /* Content fills remaining space */
  .card__content {
    padding: 20px 16px;
    gap: 16px;
  }

  /* Slightly smaller title */
  .post-title-input {
    font-size: 1.05rem;
  }

  /* Textareas: slightly smaller on mobile */
  .field-textarea {
    font-size: 0.85rem;
    padding: 8px 10px;
  }

  /* Tags wrap nicely */
  .tags-list {
    gap: 6px;
  }

  .tag-chip {
    font-size: 0.78rem;
    padding: 4px 12px;
  }

  /* Save bar stacks if tight */
  .save-bar {
    flex-direction: column;
    gap: 10px;
    align-items: stretch;
  }

  .save-bar__buttons {
    justify-content: stretch;
  }

  .save-btn {
    flex: 1;
    text-align: center;
    padding: 12px 16px;
  }

  .entry-counter {
    text-align: center;
  }

  /* Comment input stacks */
  .comment-input-wrap {
    flex-direction: column;
  }

  .comment-submit-btn {
    align-self: flex-end;
  }
}

/* ── Extra small screens (< 400px) ──────────────────── */
@media (max-width: 400px) {

  .main-area {
    padding: 8px;
    padding-top: 52px;
  }

  .card__image--half {
    min-height: 140px;
    max-height: 180px;
  }

  .card__content {
    padding: 16px 12px;
    gap: 14px;
  }

  .user-header__avatar {
    width: 36px;
    height: 36px;
  }

  .user-header__name {
    font-size: 0.88rem;
  }

  .user-header__time {
    font-size: 0.75rem;
  }
}
