* {
  box-sizing: border-box;
}

:root {
  --app-bg: #d8e3e8;
  --header-bg: #f8fafb;
  --tab-bg: #eef4f6;
  --tab-active: #2d6f86;
  --chat-bg: #eaf1f4;
  --left-bubble: #ffffff;
  --right-bubble: #cfeef4;
  --text: #1f2933;
  --muted: #5d6b78;
  --line: #bfccd5;
  --strong-line: #9fb2bf;
  --button: #2d6f86;
  --button-dark: #235b70;
  --danger: #a33b3b;
  --shadow: 0 8px 18px rgba(31, 41, 51, 0.12);
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  overflow: hidden;
  background: var(--app-bg);
  color: var(--text);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.question-page {
  height: 100vh;
  padding: 10px;
}

.growmanual-shell {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  width: min(100%, 1080px);
  height: calc(100vh - 20px);
  margin: 0 auto;
  overflow: hidden;
  border: 1px solid var(--strong-line);
  border-radius: 8px;
  background: var(--header-bg);
  box-shadow: var(--shadow);
}

.growmanual-header {
  display: grid;
  gap: 8px;
  padding: 12px 14px 10px;
  border-bottom: 1px solid var(--line);
  background: var(--header-bg);
}

.growmanual-title {
  margin: 0;
  font-size: 28px;
  font-weight: 800;
  line-height: 1.15;
  letter-spacing: 0;
}

.growmanual-tabs {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 2px;
}

.auth-status-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  justify-content: space-between;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
}

.auth-status-text {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
  overflow-wrap: anywhere;
}

.auth-logout-button {
  min-height: 34px;
  padding: 6px 12px;
  border: 1px solid var(--button);
  border-radius: 6px;
  background: #fff;
  color: var(--button);
  font: inherit;
  font-size: 14px;
  font-weight: 800;
  cursor: pointer;
}

.auth-logout-button:hover,
.auth-logout-button:focus {
  background: #f5fbfd;
  outline: 3px solid rgba(47, 111, 133, 0.22);
  outline-offset: 2px;
}

.auth-page {
  display: grid;
  min-height: 100vh;
  padding: 20px;
  place-items: center;
  background: var(--app-bg);
  color: var(--text);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.auth-panel {
  display: grid;
  gap: 14px;
  width: min(100%, 420px);
  padding: 24px;
  border: 1px solid var(--strong-line);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow);
}

.auth-title {
  margin: 0;
  font-size: 28px;
  font-weight: 850;
  line-height: 1.2;
}

.auth-message,
.auth-helper-message,
.auth-error-message {
  margin: 0;
  font-size: 15px;
  line-height: 1.7;
}

.auth-message,
.auth-helper-message {
  color: var(--muted);
}

.auth-error-message {
  color: var(--danger);
  font-weight: 800;
}

.auth-field {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 800;
}

.auth-field input {
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  border: 1px solid var(--strong-line);
  border-radius: 6px;
  color: var(--text);
  font: inherit;
}

.auth-submit-button {
  min-height: 46px;
  padding: 10px 16px;
  border: 1px solid var(--button);
  border-radius: 6px;
  background: var(--button);
  color: #fff;
  font: inherit;
  font-weight: 800;
  cursor: pointer;
}

.auth-submit-button:hover,
.auth-submit-button:focus {
  background: var(--button-dark);
  outline: 3px solid rgba(47, 111, 133, 0.22);
  outline-offset: 2px;
}

.auth-submit-button:disabled,
.auth-logout-button:disabled {
  cursor: wait;
  opacity: 0.68;
}

.tab-button {
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 104px;
  min-height: 42px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--tab-bg);
  color: var(--text);
  font: inherit;
  font-size: 16px;
  font-weight: 700;
  text-decoration: none;
  white-space: nowrap;
}

.tab-button-active {
  border-color: var(--tab-active);
  background: var(--tab-active);
  color: #fff;
}

.chat-history {
  display: flex;
  flex-direction: column;
  gap: 18px;
  min-height: 0;
  margin: 10px;
  padding: 18px;
  border: 1px solid var(--strong-line);
  border-radius: 8px;
  overflow-y: auto;
  background: var(--chat-bg);
}

.chat-empty-message {
  align-self: center;
  max-width: 560px;
  margin: auto;
  padding: 18px 20px;
  border: 1px dashed var(--strong-line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.6);
  color: var(--muted);
  font-size: 17px;
  line-height: 1.7;
  text-align: center;
}

.chat-row {
  display: flex;
  width: 100%;
}

.chat-row-user {
  justify-content: flex-end;
}

.chat-row-answer {
  justify-content: flex-start;
  align-items: flex-start;
}

.chat-bubble {
  max-width: min(78%, 760px);
  padding: 16px 18px;
  border: 1px solid var(--strong-line);
  border-radius: 12px;
  font-size: 16px;
  line-height: 1.7;
  white-space: pre-wrap;
  box-shadow: 0 2px 6px rgba(31, 41, 51, 0.05);
}

.user-bubble {
  border-color: #8fbfca;
  background: var(--right-bubble);
  font-weight: 700;
}

.answer-bubble {
  border-color: #b9c7cf;
  background: var(--left-bubble);
}

.chat-row-answer .answer-bubble {
  min-width: min(440px, 78%);
}

.answer-card {
  display: grid;
  gap: 14px;
}

.answer-card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.card-summary {
  display: grid;
  gap: 12px;
}

.section-title,
.answer-title {
  margin: 0;
  font-size: 24px;
  line-height: 1.32;
  font-weight: 850;
}

.answer-meta {
  width: fit-content;
  margin: 0;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid transparent;
  font-size: 14px;
  font-weight: 800;
  line-height: 1.5;
}

.answer-meta-place {
  border-color: #9dc9ee;
  background: #e7f3ff;
  color: #1e5f95;
}

.answer-meta-manual {
  border-color: #98d5ad;
  background: #e8f7ed;
  color: #247348;
}

.answer-body,
.empty-message,
.detail-body,
.detail-search-text,
.detail-updated-at,
.similar-card-excerpt {
  margin: 0;
  font-size: 16px;
  line-height: 1.8;
  white-space: pre-wrap;
}

.answer-body {
  display: -webkit-box;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 5;
  color: #26323c;
  font-size: 17px;
  line-height: 1.85;
}

.answer-body-expanded {
  display: block;
  overflow: visible;
  -webkit-line-clamp: unset;
}

.summary-images {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 8px;
}

.summary-image-button {
  display: grid;
  width: 100%;
  min-height: 120px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: #fff;
  cursor: zoom-in;
}

.summary-image {
  display: block;
  width: 100%;
  height: 100%;
  max-height: 240px;
  object-fit: cover;
  background: #fff;
}

.summary-image-status {
  align-self: center;
  padding: 16px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
  text-align: center;
}

.summary-image-button:hover,
.summary-image-button:focus {
  border-color: var(--button);
}

.candidate-bubble {
  display: grid;
  gap: 12px;
}

.favorite-bubble {
  display: grid;
  gap: 12px;
}

.favorite-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  width: 100%;
  padding: 12px;
  border: 1px solid var(--strong-line);
  border-radius: 8px;
  background: #f9fbfc;
  color: var(--text);
  font: inherit;
  text-align: left;
}

.favorite-card:hover,
.favorite-card:focus {
  border-color: var(--button);
  background: #fff;
}

.favorite-card-title {
  overflow-wrap: anywhere;
  font-size: 16px;
  line-height: 1.4;
}

.favorite-card-excerpt,
.favorite-empty-message {
  grid-column: 1 / -1;
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.6;
}

.favorite-card-excerpt {
  display: -webkit-box;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.favorite-card-actions {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.favorite-card-category {
  width: fit-content;
  padding: 3px 9px;
  border: 1px solid transparent;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 800;
  line-height: 1.5;
  white-space: nowrap;
}

.candidate-card {
  display: grid;
  gap: 10px;
  min-height: 122px;
  padding: 14px;
  border: 1px solid var(--strong-line);
  border-radius: 8px;
  background: #f9fbfc;
  cursor: pointer;
}

.candidate-card:hover,
.candidate-card:focus-within {
  border-color: var(--button);
  background: #fff;
}

.read-more-button,
.favorite-button,
.question-button,
.secondary-button {
  border: 1px solid var(--button);
  border-radius: 6px;
  background: var(--button);
  color: #fff;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.read-more-button {
  justify-self: end;
  min-height: 34px;
  padding: 6px 12px;
  background: #fff;
  color: var(--button);
  font-size: 14px;
}

.favorite-button {
  min-height: 34px;
  padding: 6px 12px;
  background: #fff;
  color: var(--button);
  font-size: 14px;
}

.favorite-button-active {
  border-color: #c58a1f;
  background: #fff7e6;
  color: #8a5d13;
}

.secondary-button {
  min-height: 36px;
  padding: 7px 12px;
  background: #fff;
  color: var(--button);
}

.secondary-button:last-child {
  border-color: var(--danger);
  color: var(--danger);
}

.read-more-button:hover,
.favorite-button:hover,
.question-button:hover {
  background: var(--button-dark);
  color: #fff;
}

.secondary-button:hover {
  background: #f5fbfd;
}

.read-more-button:focus,
.question-button:focus,
.secondary-button:focus,
.question-input:focus,
.detail-field input:focus,
.detail-field select:focus,
.detail-field textarea:focus {
  outline: 3px solid rgba(47, 111, 133, 0.22);
  outline-offset: 2px;
}

.detail-panel {
  display: grid;
  gap: 10px;
  padding: 14px 0 0;
  border-top: 1px solid var(--line);
}

.detail-images {
  display: grid;
  gap: 8px;
}

.detail-label {
  color: var(--muted);
}

.detail-image {
  max-width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
}

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

.detail-edit-form {
  display: grid;
  gap: 10px;
}

.detail-field {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
}

.detail-field input,
.detail-field select,
.detail-field textarea {
  width: 100%;
  min-height: 40px;
  padding: 9px 10px;
  border: 1px solid var(--strong-line);
  border-radius: 6px;
  color: var(--text);
  font: inherit;
}

.detail-field textarea {
  resize: vertical;
}

.question-form {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  padding: 12px 14px 14px;
  border-top: 1px solid var(--line);
  background: var(--header-bg);
  box-shadow: 0 -4px 12px rgba(31, 41, 51, 0.08);
}

.question-input-area {
  min-width: 0;
}

.question-input {
  width: 100%;
  min-height: 50px;
  max-height: 120px;
  padding: 12px 14px;
  border: 2px solid var(--strong-line);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  font: inherit;
  font-size: 17px;
  line-height: 1.45;
  resize: none;
}

.realtime-suggestions {
  z-index: 12;
  display: none;
  margin-top: 8px;
  max-height: min(340px, 45vh);
  overflow-y: auto;
  border: 1px solid var(--strong-line);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 12px 26px rgba(31, 41, 51, 0.16);
}

.realtime-suggestions-open {
  display: grid;
}

.suggestion-card {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 4px 10px;
  width: 100%;
  padding: 11px 12px;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: #fff;
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.suggestion-card:last-child {
  border-bottom: 0;
}

.suggestion-card:hover,
.suggestion-card-active {
  background: #eef7fa;
}

.suggestion-title {
  min-width: 0;
  overflow: hidden;
  font-size: 16px;
  font-weight: 850;
  line-height: 1.35;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.suggestion-category {
  align-self: start;
  padding: 2px 8px;
  border: 1px solid transparent;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
  line-height: 1.5;
  white-space: nowrap;
}

.suggestion-category-place {
  border-color: #9dc9ee;
  background: #e7f3ff;
  color: #1e5f95;
}

.suggestion-category-manual {
  border-color: #98d5ad;
  background: #e8f7ed;
  color: #247348;
}

.suggestion-body {
  grid-column: 1 / -1;
  overflow: hidden;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.question-button {
  align-self: start;
  min-width: 104px;
  min-height: 50px;
  padding: 10px 18px;
  font-size: 17px;
}

.delete-dialog-overlay {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(15, 23, 32, 0.48);
}

.delete-dialog {
  width: min(100%, 420px);
  display: grid;
  gap: 14px;
  padding: 24px;
  border: 1px solid var(--strong-line);
  border-radius: 10px;
  background: #fff;
  color: var(--text);
  box-shadow: 0 18px 44px rgba(31, 41, 51, 0.25);
}

.delete-dialog-title {
  margin: 0;
  font-size: 22px;
  line-height: 1.4;
}

.delete-dialog-description {
  margin: 0;
  color: var(--muted);
  font-size: 16px;
  line-height: 1.7;
}

.delete-dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 4px;
}

.dialog-button {
  min-width: 112px;
  min-height: 42px;
  padding: 9px 14px;
  border: 1px solid var(--strong-line);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  font: inherit;
  font-weight: 800;
  cursor: pointer;
}

.delete-dialog-cancel:hover {
  background: #f4f8fa;
}

.delete-dialog-delete {
  border-color: var(--danger);
  background: var(--danger);
  color: #fff;
}

.delete-dialog-delete:hover {
  background: #842f2f;
}

.dialog-button:focus {
  outline: 3px solid rgba(47, 111, 133, 0.25);
  outline-offset: 2px;
}

.delete-dialog-delete:focus {
  outline-color: rgba(163, 59, 59, 0.28);
}

.toast-message {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 30;
  max-width: min(360px, calc(100vw - 40px));
  margin: 0;
  padding: 13px 16px;
  border: 1px solid #98d5ad;
  border-radius: 8px;
  background: #e8f7ed;
  color: #247348;
  font-size: 16px;
  font-weight: 800;
  line-height: 1.5;
  box-shadow: 0 12px 26px rgba(31, 41, 51, 0.18);
}

.image-modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  padding: 56px 20px 20px;
  background: rgba(8, 13, 18, 0.78);
}

.image-modal-image {
  display: block;
  max-width: min(100%, 1120px);
  max-height: calc(100vh - 88px);
  border-radius: 8px;
  object-fit: contain;
  background: #fff;
  box-shadow: 0 18px 44px rgba(0, 0, 0, 0.34);
}

.image-modal-close {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 41;
  width: 44px;
  height: 44px;
  border: 1px solid rgba(255, 255, 255, 0.5);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.94);
  color: var(--text);
  font-size: 28px;
  line-height: 1;
  cursor: pointer;
}

.image-modal-close:hover,
.image-modal-close:focus {
  background: #fff;
  outline: 3px solid rgba(255, 255, 255, 0.32);
  outline-offset: 2px;
}

@media (max-width: 720px) {
  html,
  body {
    width: 100%;
    overflow-x: hidden;
  }

  .question-page {
    padding: 0;
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
  }

  .growmanual-shell {
    width: 100%;
    max-width: 100vw;
    height: 100vh;
    height: 100dvh;
    grid-template-rows: auto minmax(0, 1fr) auto;
    border-width: 0;
    border-radius: 0;
    box-shadow: none;
  }

  .growmanual-header {
    gap: 5px;
    padding: 7px 8px 6px;
  }

  .growmanual-title {
    font-size: 21px;
    line-height: 1.1;
  }

  .growmanual-tabs {
    gap: 4px;
    overflow-x: auto;
    padding-bottom: 0;
  }

  .auth-status-bar {
    align-items: stretch;
    padding: 8px;
  }

  .auth-status-text {
    width: 100%;
    font-size: 13px;
  }

  .auth-logout-button {
    width: 100%;
    min-height: 38px;
  }

  .auth-page {
    min-height: 100vh;
    min-height: 100dvh;
    padding: 14px;
  }

  .auth-panel {
    padding: 20px;
  }

  .tab-button {
    flex: 0 0 auto;
    min-width: 58px;
    min-height: 36px;
    padding: 6px 4px;
    font-size: 12px;
  }

  .chat-history {
    gap: 16px;
    min-height: 0;
    margin: 0;
    padding: 14px 10px 18px;
    overflow-x: hidden;
  }

  .chat-bubble {
    max-width: 90%;
    padding: 12px;
    font-size: 16px;
  }

  .chat-row-answer .answer-bubble {
    width: 100%;
    min-width: 0;
    max-width: 100%;
  }

  .answer-card,
  .candidate-bubble {
    gap: 16px;
  }

  .answer-card-actions {
    justify-content: stretch;
  }

  .answer-card-actions button {
    flex: 1 1 130px;
  }

  .favorite-card {
    grid-template-columns: 1fr;
    min-height: 58px;
  }

  .favorite-card-actions {
    flex-direction: column;
  }

  .favorite-card-actions button {
    width: 100%;
  }

  .candidate-card {
    width: 100%;
    min-height: 136px;
  }

  .chat-empty-message {
    margin: auto 4px;
    font-size: 15px;
  }

  .card-summary {
    width: 100%;
  }

  .answer-title {
    font-size: 21px;
    line-height: 1.35;
  }

  .answer-body,
  .detail-body {
    font-size: 17px;
  }

  .detail-actions {
    justify-content: stretch;
  }

  .detail-actions button {
    flex: 1 1 120px;
  }

  .question-form {
    grid-template-columns: 1fr auto;
    position: sticky;
    bottom: 0;
    z-index: 10;
    gap: 8px;
    padding: 9px 8px calc(9px + env(safe-area-inset-bottom));
    max-width: 100vw;
    overflow: visible;
  }

  .question-input {
    min-height: 52px;
    max-height: 104px;
    padding: 12px;
    font-size: 16px;
    border-radius: 10px;
  }

  .realtime-suggestions {
    position: absolute;
    left: 8px;
    right: 92px;
    bottom: calc(100% + 6px);
    margin-top: 6px;
    max-height: min(280px, 42vh);
    border-radius: 10px;
  }

  .suggestion-card {
    padding: 12px;
  }

  .summary-images {
    grid-template-columns: 1fr;
  }

  .summary-image-button {
    min-height: 180px;
  }

  .summary-image {
    max-height: 280px;
  }

  .question-button {
    min-width: 78px;
    min-height: 52px;
    padding-inline: 12px;
    border-radius: 10px;
    font-size: 16px;
  }

  .delete-dialog-overlay {
    padding: 14px;
  }

  .delete-dialog {
    padding: 20px;
  }

  .delete-dialog-actions {
    display: grid;
    grid-template-columns: 1fr;
  }

  .dialog-button {
    width: 100%;
  }

  .toast-message {
    right: 12px;
    bottom: 12px;
    max-width: calc(100vw - 24px);
  }

  .image-modal-overlay {
    padding: 60px 12px 12px;
  }

  .image-modal-image {
    max-height: calc(100vh - 84px);
  }

  .image-modal-close {
    top: 10px;
    right: 10px;
  }
}
