:root {
  color-scheme: light;
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Noto Sans JP", sans-serif;
  color: #17352f;
  background: #eef5f2;
}

* { box-sizing: border-box; }
body { min-width: 320px; margin: 0; background: #eef5f2; }
button, textarea, select { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: wait; opacity: .55; }

.app-shell { max-width: 1440px; min-height: 100dvh; margin: 0 auto; padding: 20px; }
.app-header { display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 4px 4px 18px; }
.eyebrow { margin: 0 0 4px; color: #267766; font-size: .72rem; font-weight: 800; letter-spacing: .09em; }
h1 { margin: 0; font-size: clamp(1.35rem, 2.5vw, 1.8rem); }
.safety-note { max-width: 390px; margin: 0; color: #4a625c; font-size: .88rem; text-align: right; }

.workspace { display: grid; grid-template-columns: minmax(250px, 310px) minmax(0, 1fr); min-height: calc(100dvh - 105px); overflow: hidden; border: 1px solid #d4e3dd; border-radius: 20px; background: #fff; box-shadow: 0 12px 35px rgba(22, 61, 51, .08); }
.conversation-list { background: #f8fbfa; border-right: 1px solid #dce8e3; }
.section-label { display: block; padding: 21px 20px 10px; color: #60766f; font-size: .76rem; font-weight: 700; letter-spacing: .04em; }
.conversation-list ul { margin: 0; padding: 0 10px 14px; list-style: none; }
.conversation-button { width: 100%; display: grid; gap: 4px; border: 0; border-radius: 12px; padding: 15px 12px; background: transparent; color: inherit; text-align: left; }
.conversation-button:hover, .conversation-button[aria-current="true"] { background: #deefe9; }
.conversation-title-line { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-weight: 700; }
.conversation-preview { overflow: hidden; color: #5d716b; font-size: .82rem; text-overflow: ellipsis; white-space: nowrap; }
.status { flex: 0 0 auto; border-radius: 999px; padding: 3px 7px; font-size: .68rem; font-weight: 700; }
.status-open { background: #fff0d7; color: #865400; }
.status-resolved { background: #d7f0e8; color: #0b6c4d; }

.conversation-panel { display: grid; grid-template-rows: auto minmax(180px, 1fr) auto; min-width: 0; background: #fff; }
.conversation-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; border-bottom: 1px solid #e6efeb; padding: 20px 24px 14px; }
.conversation-heading h2 { margin: 0; font-size: 1.12rem; }
.conversation-heading p { margin: 5px 0 0; color: #657a73; font-size: .84rem; }
.local-badge { margin: 0; border: 1px solid #bfdfd4; border-radius: 999px; padding: 5px 8px; color: #087158; font-size: .71rem; font-weight: 700; white-space: nowrap; }
.messages { display: flex; flex-direction: column; gap: 12px; overflow-y: auto; padding: 20px 24px; background: linear-gradient(180deg, #fcfefd, #f7fbf9); }
.message { max-width: min(82%, 560px); border-radius: 15px; padding: 11px 13px; line-height: 1.55; white-space: pre-wrap; }
.message-incoming { align-self: flex-start; background: #fff; box-shadow: 0 1px 4px rgba(24, 60, 50, .12); }
.message-outgoing { align-self: flex-end; background: #cff0e4; }
.message-meta { display: block; margin-bottom: 4px; color: #60766f; font-size: .7rem; font-weight: 700; }

.composer-area { border-top: 1px solid #e3ece8; padding: 16px 24px 20px; }
.draft-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
.draft-toolbar label { color: #50665f; font-size: .84rem; font-weight: 700; }
select { border: 1px solid #b9cec6; border-radius: 8px; padding: 7px 9px; background: #fff; color: #193f36; }
.suggestions { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin-bottom: 12px; }
.suggestion { min-height: 94px; border: 1px solid #c7dbd3; border-radius: 11px; padding: 10px; background: #fff; color: #234b40; text-align: left; font-size: .8rem; line-height: 1.5; }
.suggestion:hover, .suggestion:focus-visible { border-color: #13836b; outline: 2px solid transparent; box-shadow: 0 0 0 2px #d2eee6; }
.suggestion-number { display: block; margin-bottom: 4px; color: #17816b; font-size: .67rem; font-weight: 800; }
textarea { width: 100%; min-height: 92px; resize: vertical; border: 1px solid #afc9bf; border-radius: 11px; padding: 11px; color: #183930; line-height: 1.5; }
.action-row { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-top: 10px; }
.send-state { min-height: 1.2em; margin: 0; color: #526b63; font-size: .81rem; }
.send-state-error { color: #b2292d; }
.primary-button, .secondary-button { border: 0; border-radius: 9px; padding: 10px 15px; font-weight: 800; }
.primary-button { background: #147962; color: #fff; }
.primary-button:hover:not(:disabled) { background: #0e614f; }
.secondary-button { background: #edf4f1; color: #285348; }

.instruction-row { margin-bottom: 12px; }
.instruction-row .section-label { padding: 0 0 6px; }
.instruction-controls { display: flex; gap: 8px; }
.instruction-controls input { flex: 1 1 auto; min-width: 0; border: 1px solid #afc9bf; border-radius: 9px; padding: 9px 11px; color: #183930; }
.instruction-controls button { flex: 0 0 auto; white-space: nowrap; }

.token-gate { max-width: 460px; margin: 60px auto; padding: 28px; border: 1px solid #d4e3dd; border-radius: 16px; background: #fff; }
.token-gate h2 { margin: 0 0 10px; }
.token-gate p { color: #49645b; line-height: 1.6; }
.token-gate form { display: grid; gap: 10px; margin-top: 14px; }
.token-gate input { border: 1px solid #afc9bf; border-radius: 9px; padding: 10px 12px; }
.token-gate label { color: #50665f; font-size: .84rem; font-weight: 700; }

dialog { width: min(440px, calc(100vw - 34px)); border: 0; border-radius: 16px; padding: 0; color: #193b32; box-shadow: 0 18px 54px rgba(14, 50, 41, .28); }
dialog::backdrop { background: rgba(12, 38, 31, .42); }
.dialog-content { padding: 22px; }
.dialog-content h2 { margin: 0 0 9px; font-size: 1.15rem; }
.dialog-content p { margin: 0; color: #49645b; line-height: 1.55; }
.dialog-preview { max-height: 180px; overflow: auto; margin: 14px 0; border-radius: 10px; padding: 11px; background: #f2f7f5; white-space: pre-wrap; word-break: break-word; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 9px; }

@media (max-width: 760px) {
  .app-shell { padding: 0; }
  .app-header { align-items: flex-start; padding: 16px; }
  .safety-note { max-width: 190px; font-size: .76rem; }
  .workspace { display: block; min-height: calc(100dvh - 82px); border-right: 0; border-left: 0; border-radius: 0; }
  .conversation-list { border-right: 0; border-bottom: 1px solid #dce8e3; }
  .conversation-list ul { display: flex; overflow-x: auto; gap: 8px; padding: 0 12px 12px; }
  .conversation-list li { flex: 0 0 170px; }
  .section-label { padding: 13px 14px 8px; }
  .conversation-heading, .messages, .composer-area { padding-right: 15px; padding-left: 15px; }
  .suggestions { grid-template-columns: 1fr; }
  .suggestion { min-height: auto; }
}
