html, body { max-width: 100%; overflow-x: hidden; }
* { box-sizing: border-box; min-width: 0; }
button {
      box-shadow: 0 1px 2px rgba(74, 41, 21, 0.2);
    }

    body {
      margin: 0;
      padding: 0;
      font-family: "M PLUS Rounded 1c", "Yu Gothic", "Hiragino Sans", "Segoe UI", sans-serif;
      background: linear-gradient(180deg, #fff9f2 0%, #f8ecd9 100%);
      color: #4a2915;
    }

    h1, h2, h3, p, label, input, button, div, span, summary {
      font-family: "M PLUS Rounded 1c", "Yu Gothic", "Hiragino Sans", "Segoe UI", sans-serif;
      letter-spacing: 0.02em;
      -webkit-text-stroke: 0.8px rgba(123, 74, 29, 0.18);
      text-shadow: 0 1px 0 rgba(255,255,255,0.16);
    }

    input, textarea, select {
      font-weight: 400;
    }

    .profile-weight-picker {
      display: grid;
      grid-template-columns: minmax(0, 1fr);
      gap: 8px;
      margin-top: 6px;
      padding: 8px;
      border: 1px solid #e7b27d;
      border-radius: 8px;
      background: #fffaf3;
    }

    .profile-weight-type-options {
      display: grid;
      grid-template-columns: repeat(3, minmax(0, 1fr));
      gap: 4px;
      margin: 0;
      padding: 0;
      border: none;
      border-radius: 0;
      background: transparent;
    }

    .profile-weight-type-option {
      display: flex;
      flex-direction: column;
      align-items: center;
      justify-content: center;
      gap: 2px;
      margin: 0;
      font-size: 0.78rem;
      font-weight: 400;
      line-height: 1.25;
      min-width: 0;
      width: 100%;
      text-align: center;
    }

    .profile-weight-type-name,
    .profile-weight-type-range {
      display: block;
      text-align: center;
      width: 100%;
    }

    .profile-weight-type-range {
      margin-left: 0;
    }

    .profile-weight-picker select,
    .profile-weight-picker select option {
      width: 100%;
      padding: 10px 36px 10px 12px;
      border: 1px solid #e7b27d;
      border-radius: 999px;
      background: #fffaf3;
      color: #7c3f15;
      font-size: 0.9rem;
      font-weight: 400;
      line-height: 1.3;
      appearance: none;
      -webkit-appearance: none;
      -moz-appearance: none;
      background-image:
        linear-gradient(45deg, transparent 50%, #7c3f15 50%),
        linear-gradient(135deg, #7c3f15 50%, transparent 50%);
      background-position: calc(100% - 18px) calc(50% - 3px), calc(100% - 12px) calc(50% - 3px);
      background-size: 6px 6px, 6px 6px;
      background-repeat: no-repeat;
      box-shadow: inset 0 0 0 1px rgba(231, 178, 125, 0.2);
    }

    .profile-weight-select {
      width: 100%;
      padding: 10px 36px 10px 12px;
      border: 1px solid #e7b27d;
      border-radius: 999px;
      background: #fffaf3;
      color: #7c3f15;
      font-size: 0.9rem;
      font-weight: 400;
      line-height: 1.3;
      appearance: none;
      -webkit-appearance: none;
      -moz-appearance: none;
      background-image:
        linear-gradient(45deg, transparent 50%, #7c3f15 50%),
        linear-gradient(135deg, #7c3f15 50%, transparent 50%);
      background-position: calc(100% - 18px) calc(50% - 3px), calc(100% - 12px) calc(50% - 3px);
      background-size: 6px 6px, 6px 6px;
      background-repeat: no-repeat;
      box-shadow: inset 0 0 0 1px rgba(231, 178, 125, 0.2);
    }

    .auth-card .profile-weight-type-option input {
      width: auto !important;
      height: auto;
      margin: 0;
      padding: 0;
      align-self: center;
    }

    .auth-card .profile-medication-toggle {
      display: inline-flex;
      align-items: center;
      justify-content: flex-start;
      gap: 8px;
      margin: 0 0 8px;
      padding: 0;
      width: auto;
      min-height: auto;
      font-size: 0.84rem;
      font-weight: 400;
      line-height: 1.3;
      color: #7c3f15;
    }

    .auth-card .profile-medication-toggle input {
      width: auto;
      height: auto;
      margin: 0;
      accent-color: #e7b27d;
      vertical-align: middle;
    }

    .profile-gender-options {
      display: flex;
      flex-wrap: wrap;
      gap: 8px 12px;
      margin-top: 6px;
    }

    .profile-gender-options label {
      display: inline-flex;
      align-items: center;
      gap: 4px;
      margin: 0;
      font-size: 0.84rem;
      font-weight: 400;
      white-space: nowrap;
    }

    .auth-card .profile-gender-options input {
      width: auto !important;
      margin: 0;
      padding: 0;
    }
    
    .container {
      width: 100%;
      max-width: 480px;
      margin: 0 auto;
      min-height: 100vh;
      position: relative;
      background: linear-gradient(180deg, #fff9f2 0%, #f8ecd9 100%);
      display: flex;
      flex-direction: column;
    }

    .container.diary-mode {
      background: #fbf7ec;
    }

    .container.diary-mode .main {
      background: #fbf7ec;
    }

    .header {
      width: 100%;
      padding: 0;
      margin: 0;
      background: #ff8a00;
      overflow: hidden;
    }

    .global-logout-button {
      display: none;
      position: absolute;
      top: 10px;
      right: 10px;
      z-index: 2;
      padding: 7px 12px;
      border: 1px solid rgba(255, 255, 255, 0.9);
      border-radius: 999px;
      background: rgba(124, 63, 21, 0.82);
      color: #ffffff;
      font-size: 0.78rem;
      font-weight: 800;
      cursor: pointer;
      font-family: inherit;
    }

    .diary-menu-button {
      display: none;
      position: absolute;
      top: 10px;
      right: 10px;
      z-index: 4;
      width: 42px;
      height: 42px;
      padding: 9px 8px;
      border: 1px solid rgba(255, 255, 255, 0.9);
      border-radius: 10px;
      background: rgba(124, 63, 21, 0.82);
      cursor: pointer;
    }

    .diary-menu-button:not([hidden]) { display: flex; flex-direction: column; justify-content: center; gap: 4px; }
    .diary-menu-button span { display: block; height: 2px; border-radius: 2px; background: #ffffff; }

    .diary-menu {
      position: absolute;
      top: 58px;
      right: 10px;
      z-index: 5;
      width: 190px;
      padding: 8px;
      border: 1px solid #e7b27d;
      border-radius: 12px;
      background: #ffffff;
      box-shadow: 0 8px 20px rgba(74, 41, 21, 0.18);
    }

    .diary-menu[hidden] { display: none; }
    .diary-menu button { width: 100%; padding: 10px 12px; border: 0; border-radius: 8px; background: transparent; color: #7c3f15; font: inherit; font-weight: 800; text-align: left; cursor: pointer; }
    .diary-menu button:hover, .diary-menu button:focus-visible { background: #fff1df; outline: none; }

    .header-image {
      display: block;
      width: 100%;
      max-width: 1200px;
      height: auto;
      margin: 0 auto;
      object-fit: contain;
    }

    .main {
      flex: 1;
      padding: 32px 24px;
      overflow-y: auto;
    }

    .greeting {
      text-align: left;
      margin-bottom: 18px;
      padding: 0 0 8px;
    }

    .greeting h2 {
      margin: 0 0 10px;
      font-size: 14pt;
      line-height: 1.15;
      font-weight: 900;
      color: #7b4a1d;
      letter-spacing: 0.02em;
      font-family: "M PLUS Rounded 1c", "Yu Gothic", "Hiragino Sans", sans-serif;
      -webkit-text-stroke: 1px rgba(123, 74, 29, 0.2);
    }

    .date {
      display: flex;
      flex-wrap: wrap;
      align-items: center;
      gap: 6px;
      font-size: 1.1rem;
      color: #8c613d;
      margin: 0;
      font-weight: 500;
      font-family: "M PLUS Rounded 1c", "Yu Gothic", "Hiragino Sans", sans-serif;
    }

    .today-moon-inline {
      display: inline-flex;
      align-items: center;
      gap: 5px;
      color: #8c613d;
      font-size: 1.1rem;
    }

    #todayMoonInfluence {
      font-size: 11pt;
      transform: translateY(2pt);
    }

    .today-moon-phase {
      position: relative;
      flex: 0 0 1.1em;
      width: 1.1em;
      height: 1.1em;
      margin: 0;
      border-radius: 50%;
      background: #f3bd55;
      box-shadow: 0 0 0 2px rgba(243, 189, 85, 0.22), 0 2px 6px rgba(124, 63, 21, 0.14);
      overflow: hidden;
    }

    .today-moon-phase::after {
      content: '';
      position: absolute;
      top: -0.1em;
      width: 1.2em;
      height: 1.2em;
      border-radius: 50%;
      background: #fff9f2;
    }

    .today-moon-phase.moon-new_moon { background: #9c7954; }
    .today-moon-phase.moon-new_moon::after { left: 0.45em; }
    .today-moon-phase.moon-waxing_moon::after { left: 0.45em; }
    .today-moon-phase.moon-full_moon::after { display: none; }
    .today-moon-phase.moon-waning_moon::after { left: -0.65em; }

    .weather-button {
      margin-top: 14px;
      padding: 10px 16px;
      border: 2px solid #e7b27d;
      border-radius: 14px;
      background: #ffffff;
      color: #7c3f15;
      font-size: 0.95rem;
      font-weight: 800;
      cursor: pointer;
      font-family: "M PLUS Rounded 1c", "Yu Gothic", "Hiragino Sans", sans-serif;
    }

    .weather-button:disabled {
      opacity: 0.65;
      cursor: wait;
    }

    .weather-status {
      margin: 10px 0 0;
      color: #8c613d;
      font-size: 0.85rem;
      line-height: 1.5;
      overflow-wrap: anywhere;
      text-align: center;
    }

    .server-status {
      margin: 8px 0 0;
      color: #8c613d;
      font-size: 0.75rem;
      line-height: 1.4;
      overflow-wrap: anywhere;
      text-align: center;
    }

    .weather-forecast {
      display: none;
      box-sizing: border-box;
      width: 100%;
      max-width: 100%;
      margin-top: 12px;
      padding: 5px;
      border: 1px solid #e7b27d;
      border-radius: 12px;
      background: rgba(255, 255, 255, 0.72);
      overflow: hidden;
    }

    .weather-chart {
      width: 100%;
      max-width: 100%;
      height: auto;
      display: block;
      margin: 0 auto;
    }

    .weather-legend {
      display: flex;
      justify-content: center;
      gap: 16px;
      margin: 4px 0 10px;
      color: #7c3f15;
      font-size: 0.75rem;
    }

    .weather-legend span::before {
      content: "";
      display: inline-block;
      width: 18px;
      height: 3px;
      margin: 0 4px 3px 0;
      border-radius: 2px;
      background: #e88b2a;
    }

    .weather-legend .rain-legend::before {
      background: #5b9bd5;
    }

    .weather-advice {
      display: none;
      margin-top: 10px;
      color: #7c3f15;
      text-align: left;
    }

    .weather-advice-title {
      display: inline-block;
      padding: 6px 16px;
      border: 2px solid #e88b2a;
      border-radius: 999px;
      background: #e88b2a;
      color: #ffffff;
      font-size: 0.85rem;
      font-weight: 800;
      line-height: 1.6;
    }

    .weather-advice-text {
      display: block;
      margin-top: 8px;
      padding: 0 4px;
      font-size: 0.85rem;
      line-height: 1.6;
    }

    .weather-metrics {
      display: flex;
      justify-content: center;
      flex-wrap: wrap;
      gap: 12px;
      margin-top: 10px;
      color: #7c3f15;
      font-size: 0.78rem;
      line-height: 1.5;
      text-align: center;
    }

    .weather-metrics span {
      padding: 4px 8px;
      border-radius: 8px;
      background: #fff7e9;
    }

    .section-title {
      font-size: 1.7rem;
      line-height: 1.3;
      font-weight: 900;
      color: #7b4a1d;
      margin: 18px 0 18px;
      text-align: left;
      font-family: "M PLUS Rounded 1c", "Yu Gothic", "Hiragino Sans", sans-serif;
      -webkit-text-stroke: 1px rgba(123, 74, 29, 0.18);
    }

    .form-group {
      margin-bottom: 26px;
    }

    .form-label {
      display: block;
      font-size: 1rem;
      font-weight: 800;
      color: #7c3f15;
      margin-bottom: 10px;
      font-family: "M PLUS Rounded 1c", "Yu Gothic", "Hiragino Sans", sans-serif;
      -webkit-text-stroke: 0.7px rgba(123, 74, 29, 0.12);
    }

    #breed {
      width: 100%;
      padding: 10px 12px;
      border: 2px solid #e7b27d;
      border-radius: 12px;
      font-size: 1rem;
      line-height: 1.3;
      color: #7c3f15;
      background: rgba(255,255,255,0.3);
      font-family: "M PLUS Rounded 1c", "Yu Gothic", "Hiragino Sans", sans-serif;
      font-weight: 700;
      transition: all 0.2s;
      box-shadow: inset 0 0 0 1px rgba(122, 81, 53, 0.06);
      -webkit-text-stroke: 0.4px rgba(75, 42, 20, 0.08);
    }

    #breed:focus {
      outline: none;
      border-color: #ff9500;
      box-shadow: 0 0 0 4px rgba(255, 149, 0, 0.12);
      background: rgba(255,255,255,0.55);
    }

    #breed::placeholder {
      color: #7c3f15;
      opacity: 1;
    }

    .upload-btn-wrapper {
      position: relative;
      display: block;
    }

    /* display:blockがhidden属性の既定スタイルより優先されてしまうため明示的に上書きする */
    .upload-btn-wrapper[hidden] {
      display: none !important;
    }

    #photo {
      display: none;
    }

    .upload-btn {
      width: 100%;
      padding: 18px 16px;
      background: linear-gradient(180deg, #ff9a1b 0%, #f78a00 100%);
      color: #fffaf3;
      border: none;
      border-radius: 22px;
      font-size: 1.35rem;
      line-height: 1.3;
      font-weight: 900;
      cursor: pointer;
      box-shadow: 0 5px 0 rgba(186, 96, 0, 0.85);
      transition: all 0.2s;
      display: flex;
      align-items: center;
      justify-content: center;
      gap: 12px;
      text-shadow: 0 1px 0 rgba(0,0,0,0.08);
      font-family: "M PLUS Rounded 1c", "Yu Gothic", "Hiragino Sans", sans-serif;
      -webkit-text-stroke: 0.8px rgba(123, 74, 29, 0.18);
    }

    .upload-btn:hover {
      transform: translateY(-1px);
      box-shadow: 0 6px 0 rgba(186, 96, 0, 0.88);
    }

    .upload-btn:active {
      transform: translateY(2px);
      box-shadow: 0 3px 0 rgba(186, 96, 0, 0.88);
    }

    .fortune-limit-prompt {
      display: block;
    }

    .fortune-limit-prompt[hidden] {
      display: none !important;
    }

    .fortune-limit-button {
      flex-direction: column;
      gap: 4px;
      font-size: 1rem;
      line-height: 1.5;
      text-align: center;
    }

    .fortune-section-title {
      display: block;
      margin: 0 0 8px;
      padding: 10px 14px;
      border-radius: 22px;
      background: linear-gradient(180deg, #ff9a1b 0%, #f78a00 100%);
      color: #fffaf3;
      font-size: 1rem;
      font-weight: 900;
      line-height: 1.3;
      box-shadow: 0 3px 0 rgba(186, 96, 0, 0.85);
      text-shadow: 0 1px 0 rgba(0,0,0,0.08);
    }

    .fortune-moon-phase-english {
      font-size: 0.78em;
      font-weight: 700;
    }

    .fortune-section-body {
      display: block;
      margin-bottom: 16px;
    }

    .fortune-pet-voice {
      display: flex;
      align-items: center;
      gap: 10px;
      margin: 2px 0 16px;
    }

    .fortune-pet-voice img {
      width: 72px;
      height: 72px;
      flex: 0 0 72px;
      object-fit: contain;
    }

    .fortune-pet-voice-text {
      flex: 1;
    }

    .icon {
      width: 32px;
      height: 32px;
      display: inline-flex;
      align-items: center;
      justify-content: center;
      font-size: 2rem;
      transform: translateY(-2px);
    }

    .content-area {
      margin-top: 32px;
      text-align: center;
    }

    .preview-frame {
      width: 100%;
      min-height: 220px;
      margin: 0 auto 20px;
      background: #ffffff;
      border: 2px solid #e7b27d;
      border-radius: 22px;
      display: flex;
      align-items: center;
      justify-content: center;
      overflow: hidden;
      box-shadow: inset 0 0 0 1px rgba(122, 81, 53, 0.04);
    }

    .mascot {
      width: 100%;
      height: 100%;
      min-height: 220px;
      display: flex;
      align-items: center;
      justify-content: center;
      background: #ffffff;
    }

    .mascot img {
      width: 100%;
      height: 100%;
      max-height: 220px;
      object-fit: contain;
      display: block;
    }

    .waiting-text {
      font-size: 1.1rem;
      font-weight: 700;
      color: #7c3f15;
      margin-bottom: 8px;
      text-align: left;
      font-family: "M PLUS Rounded 1c", "Yu Gothic", "Hiragino Sans", sans-serif;
      -webkit-text-stroke: 0.7px rgba(123, 74, 29, 0.16);
    }

    .waiting-desc {
      font-size: 0.9rem;
      color: #8b6e47;
      line-height: 1.6;
      text-align: left;
      font-family: "M PLUS Rounded 1c", "Yu Gothic", "Hiragino Sans", sans-serif;
      -webkit-text-stroke: 0.5px rgba(123, 74, 29, 0.12);
    }

    .result-section {
      display: none;
      margin-top: 20px;
      width: 100%;
      padding: 20px;
      background: white;
      border-radius: 20px;
      box-shadow: 0 4px 16px rgba(0,0,0,0.08);
    }

    .result-section.visible {
      display: block;
      animation: slideUp 0.3s ease;
    }

    /* 関連項目: 占い上限到達時の結果操作ブロック。
       処理内容: 占い結果がないまま上限に達している場合は、結果本文を隠して操作ボタンだけを表示する。 */
    .result-section.result-section--actions-only > :not(.result-action-block):not(.diary-save-status) {
      display: none;
    }

    .result-section.result-section--actions-only {
      margin-top: 0;
      padding: 0;
      background: transparent;
      border-radius: 0;
      box-shadow: none;
    }

    /* 関連項目: 占い結果の操作ボタン。
       処理内容: 表示状態ごとに選択される結果操作ボタンを同じ縦並びブロックで配置する。 */
    .result-action-block {
      display: grid;
      gap: 8px;
      margin-top: 12px;
    }

    .result-action-block > button {
      margin-top: 0;
    }

    .diary-save-button {
      width: 100%;
      margin-top: 8px;
      padding: 12px 16px;
      border: 0;
      border-radius: 999px;
      background: #e88b2a;
      color: #ffffff;
      font-size: 0.95rem;
      font-weight: 800;
      cursor: pointer;
      font-family: "M PLUS Rounded 1c", "Yu Gothic", "Hiragino Sans", sans-serif;
    }

    .result-logout-button { margin-top: 0; }

    .diary-save-status {
      min-height: 1.4em;
      margin: 8px 0 0;
      color: #7c3f15;
      font-size: 0.8rem;
      text-align: center;
    }

    .result-detail-grid {
      display: grid;
      grid-template-columns: repeat(3, minmax(0, 1fr));
      gap: 12px;
      margin-bottom: 12px;
    }

    .result-lucky-block {
      display: flex;
      flex-direction: column;
      gap: 4px;
      align-items: flex-start;
      padding: 8px 12px;
      text-align: left;
      min-width: 0;
    }

    .result-lucky-block + .result-lucky-block {
      border-left: 1px solid #e7b27d;
      padding-left: 16px;
    }

    .result-lucky-block strong {
      font-size: 0.95rem;
      color: #7c3f15;
      white-space: nowrap;
    }

    .result-lucky-block span {
      font-size: 1rem;
      color: #4a2915;
      min-width: 0;
      overflow-wrap: break-word;
      word-break: break-word;
    }

    .amazon-search-section {
      margin-top: 18px;
      padding-top: 14px;
      border-top: 1px solid #e7b27d;
    }

    .amazon-search-list {
      display: grid;
      gap: 8px;
      margin-top: 10px;
    }

    .amazon-search-link {
      display: block;
      padding: 10px 12px;
      border: 1px solid #e7b27d;
      border-radius: 10px;
      background: #fffaf3;
      color: #7c3f15;
      font-weight: 700;
      text-decoration: none;
    }

    .amazon-search-link:hover,
    .amazon-search-link:focus-visible {
      background: #fff0dc;
      outline: 2px solid #e88b2a;
      outline-offset: 2px;
    }

    .amazon-dummy-products {
      margin-top: 18px;
    }

    .amazon-dummy-products[hidden] {
      display: none !important;
    }

    .amazon-dummy-grid {
      display: grid;
      grid-template-columns: repeat(2, minmax(0, 1fr));
      gap: 10px;
      margin-top: 10px;
    }

    .amazon-dummy-card {
      overflow: hidden;
      border: 1px solid #e7b27d;
      border-radius: 10px;
      background: #ffffff;
    }

    .amazon-dummy-image {
      display: grid;
      aspect-ratio: 1 / 1;
      place-items: center;
      color: #7c3f15;
      font-size: 0.78rem;
      font-weight: 800;
      text-align: center;
    }

    .amazon-dummy-label {
      padding: 8px;
      color: #7c3f15;
      font-size: 0.78rem;
      line-height: 1.35;
    }

    .diary-profile-form {
      display: none;
      margin-top: 12px;
      padding: 14px;
      border: 1px solid #e7b27d;
      border-radius: 14px;
      background: #fffaf3;
      text-align: left;
    }

    .diary-profile-form.visible {
      position: fixed;
      z-index: 1000;
      top: 50%;
      left: 50%;
      display: block;
      width: min(420px, calc(100vw - 32px));
      max-height: calc(100vh - 32px);
      overflow-y: auto;
      transform: translate(-50%, -50%);
      pointer-events: auto;
      box-shadow: 0 0 0 100vmax rgba(74, 41, 21, 0.42), 0 16px 40px rgba(74, 41, 21, 0.24);
    }

    .diary-editor-frame {
      position: fixed;
      top: 50%;
      left: 50%;
      z-index: 10000;
      display: block;
      width: min(420px, calc(100vw - 32px));
      height: min(620px, calc(100vh - 32px));
      border: 1px solid #e7b27d;
      border-radius: 14px;
      background: #fffaf3;
      box-shadow: 0 0 0 100vmax rgba(74, 41, 21, 0.42), 0 16px 40px rgba(74, 41, 21, 0.24);
      transform: translate(-50%, -50%);
    }

    .diary-editor-frame[hidden] {
      display: none;
    }

    .diary-profile-form label {
      display: block;
      margin-top: 8px;
      color: #7c3f15;
      font-size: 0.82rem;
      font-weight: 800;
    }

    .diary-profile-form label:first-child {
      margin-top: 0;
    }

    .diary-profile-form input,
    .diary-profile-form select,
    .diary-profile-form textarea {
      width: 100%;
      margin-top: 4px;
      padding: 8px 10px;
      border: 1px solid #e7b27d;
      border-radius: 8px;
      background: #ffffff;
      color: #7c3f15;
      font: inherit;
    }

    .diary-profile-form textarea {
      min-height: 84px;
      resize: vertical;
    }

    .diary-profile-submit {
      width: 100%;
      margin-top: 12px;
      padding: 9px 12px;
      border: 0;
      border-radius: 999px;
      background: #7c3f15;
      color: #ffffff;
      font-weight: 800;
      cursor: pointer;
      font-family: inherit;
    }

    .diary-profile-cancel,
    .diary-edit-button,
    .diary-delete-button {
      display: inline-block;
      width: calc(33.333% - 7px);
      margin-top: 8px;
      padding: 9px 12px;
      border: 1px solid #e7b27d;
      border-radius: 999px;
      background: #fffaf3;
      color: #7c3f15;
      font-weight: 800;
      cursor: pointer;
      font-family: inherit;
    }

    .diary-entry > .diary-edit-button { background: #f6a12b; color: #ffffff; border-color: #df8614; }
    .diary-entry > .diary-delete-button { margin-left: 8px; }
    .diary-entry > .diary-profile-cancel { margin-left: 8px; color: #8b8882; border-color: #d9d1c8; background: #fffdfa; }

    .diary-delete-button {
      border-color: #d47b70;
      color: #a33f36;
      background: #fff4f2;
    }

    .diary-section {
      display: none;
      margin-top: 24px;
    }

    .diary-section.visible {
      display: block;
    }

    .container.diary-mode .main > .greeting,
    .container.diary-mode .main > .section-title,
    .container.diary-mode .main > .form-group,
    .container.diary-mode .main > .upload-btn-wrapper {
      display: none;
    }

    .container.diary-mode #waitingArea,
    .container.diary-mode #loadingArea,
    .container.diary-mode #resultArea {
      display: none;
    }

    .container.diary-mode .content-area {
      margin-top: 0;
    }

    /* 日記表示中は、content-area内の占い専用要素を残さず非表示にする。 */
    .container.diary-mode .content-area > :not(#diaryEditorHost):not(#diarySection) {
      display: none !important;
    }

    .maintenance-overlay {
      position: fixed;
      inset: 0;
      z-index: 20000;
      display: grid;
      place-items: center;
      background: #f5f4f3;
    }

    .maintenance-overlay[hidden] {
      display: none;
    }

    .maintenance-card {
      background: #ffffff;
      border-radius: 16px;
      padding: 2.5rem 2rem;
      box-shadow: 0 10px 30px rgba(0, 0, 0, 0.08);
      max-width: 560px;
      text-align: center;
    }

    .maintenance-card h1 {
      font-size: clamp(1.8rem, 3vw, 2.5rem);
      margin-bottom: 0.75rem;
    }

    .maintenance-card p {
      font-size: 1.05rem;
      line-height: 1.8;
      margin: 0;
    }

    .diary-editor-host {
      position: fixed;
      inset: 0;
      z-index: 9999;
      background: #fbf7ec;
      pointer-events: auto;
    }

    .diary-editor-host:not(.is-open) {
      display: none;
    }

    .diary-navigation {
      display: flex;
      flex-direction: column;
      align-items: stretch;
      gap: 8px;
      margin-top: 20px;
    }

    .diary-navigation button {
      flex: 1;
      width: 100%;
      margin-top: 8px;
      padding: 12px 16px;
      border: 0;
      border-radius: 999px;
      background: #7c3f15;
      color: #ffffff;
      /* 関連項目: 日記画面のわんず占いに戻るボタン。
         処理内容: 日記を見るボタンと同じ主要操作ボタンのデザインと文字サイズで表示する。 */
      font-size: 0.95rem;
      font-weight: 800;
      cursor: pointer;
      font-family: inherit;
    }

    .fortune-retry-button,
    .open-diary-button {
      width: 100%;
      margin-top: 8px;
      padding: 12px 16px;
      border: 0;
      border-radius: 999px;
      background: #7c3f15;
      color: #ffffff;
      font-size: 0.95rem;
      font-weight: 800;
      cursor: pointer;
      font-family: inherit;
    }

    .fortune-retry-button { font-size: 0.95rem; }

    .open-diary-button { display: none; }

    .app-footer {
      padding: 16px 20px 24px;
      text-align: center;
    }

    .app-footer-links {
      display: flex;
      flex-wrap: wrap;
      justify-content: center;
      gap: 8px 16px;
    }

    .calendar-footer-links {
      display: none;
      flex-wrap: wrap;
      justify-content: center;
      gap: 8px 16px;
      width: 100%;
      padding: 4px 0 8px;
    }

    .container.diary-mode .calendar-footer-links {
      display: flex;
    }

    .container.diary-mode ~ .app-footer {
      display: none;
    }

    .app-footer-contact-link {
      color: #7c3f15;
      font-size: 0.85rem;
      text-decoration: underline;
    }

    .diary-view-button {
      padding: 10px 14px;
      border: 0;
      border-radius: 999px;
      background: #7c3f15;
      color: #ffffff;
      font-weight: 800;
      cursor: pointer;
    }

    .diary-calendar {
      display: none;
      grid-template-columns: repeat(7, 1fr);
      gap: 4px;
      margin-top: 12px;
    }

    .diary-calendar.visible { display: grid; }
    .calendar-toolbar {
      display: none;
      flex-wrap: wrap;
      align-items: center;
      justify-content: space-between;
      gap: 8px;
      margin-top: 12px;
    }

    .calendar-toolbar.visible { display: flex; }
    .calendar-month { margin: 0; color: #7c3f15; font-size: 1.15rem; }
     /* 関連項目: 日記カレンダーの当日表示。
       処理内容: カレンダー移動中も実際の今日の日付と曜日を、月タイトルの上に控えめに中央表示する。 */
     .calendar-today { width: 100%; margin: 0; color: #8c613d; font-size: 0.78rem; font-weight: 700; text-align: center; }
    .calendar-nav { padding: 6px 10px; border: 1px solid #e7b27d; border-radius: 8px; background: #fffaf3; color: #7c3f15; cursor: pointer; }
    .calendar-records-button { width: 100%; padding: 8px 12px; border: 1px solid #e7b27d; border-radius: 999px; background: #fffaf3; color: #7c3f15; font-weight: 800; cursor: pointer; }
    .calendar-weekday { padding: 4px 2px; color: #8c613d; font-size: 0.7rem; text-align: center; }
    .calendar-cell { min-height: 34px; padding: 5px 2px; border-radius: 7px; background: #fffaf3; color: #7c3f15; font-size: 0.75rem; text-align: center; }
    .calendar-cell.has-entry { background: #e88b2a; color: #ffffff; font-weight: 800; cursor: pointer; }
    .calendar-cell.special-day { background: #d94b4b; color: #ffffff; box-shadow: inset 0 0 0 2px #a92f2f; }
    /* healthCheck.read() の注意フラグが有効な日記を青色で表示する。 */
    .calendar-cell.caution-day { background: #2f80ed; color: #ffffff; box-shadow: inset 0 0 0 2px #245b96; }

    .special-day-toggle { display: flex; align-items: center; gap: 6px; margin: 12px 0; color: #7c3f15; font-weight: 800; }

    .diary-entry {
      margin-top: 12px;
      padding: 18px;
      border: 2px solid #f0c98d;
      border-radius: 18px;
      background: linear-gradient(180deg, #fffaf3 0%, #ffffff 74%);
      color: #7c3f15;
      font-size: calc(0.9rem - 1pt);
      line-height: 1.6;
      text-align: left;
      box-shadow: 0 3px 12px rgba(124, 63, 21, 0.08);
    }

    .diary-entry-title {
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 10px;
      margin: -2px 0 16px;
      padding: 0 0 12px;
      border-bottom: 1px solid #f0dfc8;
      color: #4a2915;
      font-size: 1.25rem;
      font-weight: 800;
    }

    .diary-entry-calendar-icon {
      position: relative;
      display: inline-block;
      flex: 0 0 auto;
      width: 30px;
      height: 28px;
      border: 3px solid #e88b2a;
      border-radius: 5px;
      background: #fffaf3;
    }

    .diary-entry-calendar-icon::before {
      position: absolute;
      top: -8px;
      left: 4px;
      width: 4px;
      height: 10px;
      border-radius: 3px;
      background: #e88b2a;
      box-shadow: 14px 0 #e88b2a;
      content: '';
    }

    .diary-entry-calendar-icon::after {
      position: absolute;
      top: 8px;
      left: 3px;
      width: 4px;
      height: 4px;
      border-radius: 1px;
      background: #e88b2a;
      box-shadow: 7px 0 #e88b2a, 14px 0 #e88b2a, 0 7px #e88b2a, 7px 7px #e88b2a, 14px 7px #e88b2a;
      content: '';
    }
    .diary-entry-saved-time { margin-left: auto; }

    .diary-entry-title span { color: #a95d19; font-size: 1rem; font-weight: 700; white-space: nowrap; }
    .diary-card-section-heading { margin: 18px 0 8px; font-size: 1.05rem; font-weight: 900; }
    .diary-card-section-heading.basic { margin-top: 0; color: #d77c18; }
    .diary-card-section-heading.today { color: #658637; }
    .diary-card-section-heading.lucky { color: #e38b24; }
    .diary-card-section-heading.health { color: #d96459; }

    .diary-today-grid {
      display: grid;
      grid-template-columns: 1fr;
      gap: 12px;
      align-items: start;
    }

    .diary-today-details {
      min-width: 0;
      display: flex;
      flex-wrap: wrap;
      gap: 8px 14px;
    }
    .diary-today-details .diary-summary-pill {
      display: inline-block;
      margin: 0;
      padding: 6px 12px;
      border-radius: 999px;
      background: #f8fbef;
    }
    .diary-today-grid.long-memo { grid-template-columns: 1fr; }
    .diary-today-grid.long-memo .diary-today-details { display: flex; flex-wrap: wrap; gap: 8px 14px; }
    .diary-today-grid.long-memo .diary-memo-card { grid-column: auto; }
    .diary-memo-card {
      width: 100%;
      min-height: 56px;
      height: auto;
      padding: 10px;
      border: 1px solid #e4dfc9;
      border-radius: 10px;
      background: #f8fbef;
      color: #516b2f;
      box-sizing: border-box;
    }

    .diary-memo-card strong { display: block; margin-bottom: 10px; }
    .diary-memo-card p { margin: 0; color: #4a2915; white-space: pre-wrap; overflow-wrap: anywhere; }
    .diary-lucky-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
    .diary-lucky-block {
      display: flex;
      min-width: 0;
      min-height: 68px;
      flex-direction: column;
      align-items: flex-start;
      justify-content: flex-start;
      gap: 6px;
      padding: 10px 12px;
      border: 1px solid #f0d4a7;
      border-radius: 10px;
      background: #fffaf3;
      text-align: left;
    }
    .diary-lucky-block strong { color: #d77c18; font-size: 0.78rem; }
    .diary-lucky-block span { color: #4a2915; overflow-wrap: anywhere; }

    .diary-thumbnail {
      display: block;
      flex: 0 0 140px;
      width: 140px;
      height: 140px;
      border-radius: 10px;
      background: #ffffff;
      object-fit: cover;
    }

    .diary-profile-row {
      display: flex;
      align-items: flex-start;
      gap: 12px;
      margin-bottom: 10px;
    }

    .diary-profile-summary {
      min-width: 0;
      flex: 1;
      transform: translateX(-7px);
    }

    .diary-profile-summary p {
      display: flex;
      gap: 8px;
      margin: 0 0 6px;
      overflow-wrap: anywhere;
    }

    .diary-profile-summary strong,
    .diary-summary-row strong {
      display: inline-block;
      min-width: 86px;
      padding: 3px 8px;
      border-radius: 8px;
      background: #fff0dc;
      color: #a84b12;
      text-align: center;
    }

    .diary-entry p {
      margin: 3px 0;
    }

    .diary-location-summary {
      margin: -4px 0 14px !important;
      text-align: left;
    }

    .diary-location-summary strong { margin-right: 8px; color: #7c3f15; }

    .diary-summary-row {
      display: flex;
      align-items: center;
      gap: 10px;
      min-height: 38px;
      padding: 4px 0;
      border-bottom: 1px dashed #eadfce;
    }

    .diary-today-details .diary-summary-row { border-bottom: 2px solid #658637; }
    .diary-today-details .diary-summary-row:nth-child(1),
    .diary-today-details .diary-summary-row:nth-child(2) { border-bottom: 1px solid #e4dfc9; }
    .diary-today-details .diary-summary-row strong {
      flex: 0 0 66px;
      min-width: 66px;
      padding: 3px 4px;
      font-size: 0.78rem;
    }
    .diary-today-details .diary-summary-row:nth-child(2) strong,
    .diary-today-details .diary-summary-row:nth-child(3) strong {
      flex-basis: 61px;
      min-width: 61px;
    }

    @media (max-width: 620px) {
      .container { width: 100%; max-width: 100%; }
      .main { width: 100%; min-width: 0; padding: 16px 10px; }
      .result-section, .diary-section, .diary-entry { width: 100%; max-width: 100%; }
      .header-image { max-width: 100%; height: auto; }
      .weather-forecast, .amazon-search-section { max-width: 100%; overflow: hidden; }
      .auth-gate { padding: 12px; }
      .auth-card { width: 100%; max-width: none; max-height: calc(100dvh - 24px); overflow-y: auto; padding: 16px; border-radius: 16px; }
      .auth-logo { max-height: 120px; object-fit: contain; }
      .auth-card input, .auth-card select { font-size: 1rem; }
      .content-area { width: 100%; min-width: 0; }
      .main { padding: 20px 12px; }
      .diary-entry { max-width: 100%; padding: 12px; font-size: 0.85rem; overflow-wrap: anywhere; }
      .diary-entry-title { gap: 6px; margin-bottom: 12px; font-size: 1.05rem; }
      .diary-entry-title span { font-size: 0.85rem; }
      .diary-entry-calendar-icon { width: 26px; height: 24px; border-width: 2px; }
      .diary-entry-calendar-icon::before { top: -7px; left: 4px; width: 3px; height: 8px; box-shadow: 12px 0 #e88b2a; }
      .diary-entry-calendar-icon::after { top: 7px; left: 4px; width: 3px; height: 3px; box-shadow: 6px 0 #e88b2a, 12px 0 #e88b2a, 0 6px #e88b2a, 6px 6px #e88b2a, 12px 6px #e88b2a; }
      .diary-profile-row { gap: 8px; }
      .diary-thumbnail { flex-basis: 110px; width: 110px; height: 110px; }
      .diary-profile-summary { transform: translateX(0); }
      .diary-profile-summary strong, .diary-summary-row strong { min-width: 5.2em; padding: 3px 5px; }
      .diary-today-details .diary-summary-pill {
        display: inline-block;
        background: #f8fbef;
        border-radius: 999px;
        margin: 0;
        padding: 6px 12px;
      }
      .diary-today-grid { grid-template-columns: 1fr; gap: 8px; }
      .diary-today-details { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); align-items: center; gap: 8px; min-width: 0; }
      .diary-today-details p { min-width: 0; margin: 0; white-space: nowrap; }
      .diary-today-grid.long-memo { grid-template-columns: 1fr; }
      .diary-today-grid.long-memo .diary-today-details { gap: 4px; }
      .diary-today-details .diary-summary-row { gap: 4px; min-height: 34px; }
      .diary-today-details .diary-summary-row strong { flex-basis: 4.4em; min-width: 4.4em; padding: 3px 2px; font-size: 0.72rem; }
      .diary-memo-card { padding: 9px 8px; font-size: 0.78rem; }
      .diary-lucky-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 4px; }
      .diary-lucky-block { min-height: 0; padding: 8px 5px; gap: 4px; font-size: 0.78rem; }
      .diary-lucky-block strong { font-size: 0.7rem; }
      .diary-health-table th, .diary-health-table td { padding: 6px 8px; }
      .diary-health-table th { width: 7em; }
      .diary-entry > .diary-edit-button,
      .diary-entry > .diary-delete-button,
      .diary-entry > .diary-profile-cancel { display: inline-block; width: calc(33.333% - 7px); margin-left: 0; padding: 9px 4px; font-size: 0.78rem; }
      .diary-entry > .diary-delete-button,
      .diary-entry > .diary-profile-cancel { margin-left: 6px; }
    }

    .diary-summary-row:nth-of-type(5) strong { background: #f1f5df; color: #658637; }
    .diary-summary-row:nth-of-type(6) strong { background: #eaf5fb; color: #5292b5; }
    .diary-health-summary {
      margin-top: 0 !important;
      padding: 12px;
      border: 1px solid #f1d8d0;
      border-radius: 10px;
      background: #fff8f5;
    }

    .diary-health-table {
      width: 100%;
      margin-top: 0;
      border: 1px solid #f1d8d0;
      border-radius: 10px;
      border-collapse: separate;
      border-spacing: 0;
      overflow: hidden;
      background: #fffdfb;
    }

    .diary-health-table th,
    .diary-health-table td {
      padding: 7px 10px;
      border-bottom: 1px solid #f1e2dc;
      text-align: left;
      vertical-align: middle;
    }

    .diary-health-table th {
      width: 7em;
      min-width: 0;
      background: #fff0eb;
      color: #a84b39;
      font-weight: 800;
      white-space: normal;
    }

    .diary-health-table td.meal-value {
      white-space: pre-line;
    }

    .diary-health-table td.snack-value {
      white-space: pre-line;
    }

    .diary-health-table td.stool-value {
      white-space: pre-line;
    }

    .diary-health-table td.urine-value {
      white-space: pre-line;
    }

    .diary-health-table tr.urine-row td {
      white-space: pre-line;
    }

    .diary-health-table tr.stool-row td {
      white-space: pre-line;
    }

    .diary-health-table tr.meal-row td,
    .diary-health-table tr.snack-row td,
    .diary-health-table tr.medication-row td {
      white-space: pre-line;
    }

    .diary-health-table tr.meal-row th,
    .diary-health-table tr.health-status-row th,
    .diary-health-table tr.medication-row th,
    .diary-health-table tr.snack-row th,
    .diary-health-table tr.walk-row th,
    .diary-health-table tr.stool-row th,
    .diary-health-table tr.urine-row th,
    .diary-health-table tr.care-row th {
      font-weight: 800;
    }

    .diary-health-table tr.health-status-row th {
      color: #5b3b7a;
      background: #e8d9f5;
    }

    .diary-health-table tr.health-status-row td {
      color: #5b3b7a;
      background: #fbf8fe;
    }

    .diary-health-table tr.meal-row th {
      color: #a84b12;
      background: #ffe2bd;
    }

    .diary-health-table tr.meal-row td {
      color: #a84b12;
      background: #fffaf3;
    }

    .diary-health-table tr.medication-row th {
      color: #8a3153;
      background: #ffd5fd;
    }

    .diary-health-table tr.medication-row td {
      color: #8a3153;
      background: #fff9fb;
    }

    .diary-health-table tr.snack-row th {
      color: #9c2722;
      background: #ffd9d6;
    }

    .diary-health-table tr.snack-row td {
      color: #9c2722;
      background: #fffafa;
    }

    .diary-health-table tr.stool-row th {
      color: #7c4f1d;
      background: #ebdac2;
    }

    .diary-health-table tr.stool-row td {
      color: #7c4f1d;
      background: #fffaf3;
    }

    .diary-health-table tr.walk-row th {
      color: #2d5f90;
      background: #d6e7fb;
    }

    .diary-health-table tr.walk-row td {
      color: #1f4f8a;
      background: #eef6ff;
    }

    .diary-health-table tr.urine-row th {
      color: #14506f;
      background: #d9eff8;
    }

    .diary-health-table tr.urine-row td {
      color: #1f5b7a;
      background: #f5fbff;
    }

    .diary-health-table tr.care-row th {
      color: #356b32;
      background: #dff1db;
    }

    .diary-health-table tr.care-row td {
      color: #356b32;
      background: #f8fcf7;
    }

    .diary-health-table tr:last-child th,
    .diary-health-table tr:last-child td { border-bottom: 0; }

    .auth-gate {
      position: fixed;
      inset: 0;
      z-index: 10;
      display: flex;
      align-items: flex-start;
      justify-content: center;
      padding: 24px;
      overflow-y: auto;
      background: rgba(255, 249, 242, 0.96);
    }

    .auth-gate[hidden] {
      display: none;
    }

    .auth-card {
      width: min(100%, 380px);
      padding: 24px;
      border: 2px solid #e7b27d;
      border-radius: 20px;
      background: #ffffff;
      color: #7c3f15;
      text-align: left;
      margin: auto 0;
    }

    .auth-logo { display: block; width: 100%; height: auto; margin-bottom: 12px; border-radius: 12px; }
    .auth-card p { font-size: 0.85rem; line-height: 1.6; }
    .auth-card label { display: block; margin-top: 10px; font-size: 0.82rem; font-weight: 400; }
    .auth-card input { width: 100%; margin-top: 4px; padding: 10px; border: 1px solid #e7b27d; border-radius: 8px; font: inherit; }
    .auth-card input,
    .auth-card select,
    .auth-card textarea { font-size: 1rem; }
    .password-row { display: flex; gap: 6px; align-items: center; margin-top: 4px; }
    .password-row input { margin-top: 0; }
    .password-toggle { width: auto !important; margin: 0 !important; padding: 8px 10px !important; border-radius: 8px !important; white-space: nowrap; }
    .auth-card button { width: 100%; margin-top: 10px; padding: 10px; border: 0; border-radius: 999px; background: #e88b2a; color: #fff; font-weight: 800; cursor: pointer; }
    .auth-card button.secondary { background: #7c3f15; }
    .auth-error { min-height: 1.5em; color: #b33a25; font-size: 0.8rem; }
    .auth-form { display: none; }
    .auth-form.visible { display: block; }
    .profile-medication-row label[hidden] { display: none; }
    .profile-medication-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: end; margin-top: 10px; }
    .profile-medication-row label { flex: 1 1 150px; }
    .profile-medication-row label { margin-top: 0; }
    .profile-medication-row label,
    .medication-frequency-row label,
    .medication-date-timing-row label { white-space: nowrap; }
    .profile-medication-name-field { flex: 1 0 100% !important; }
    .profile-medication-name-field input { display: block; width: 100%; }
    .profile-medication-meta { display: flex; flex: 1 0 100%; flex-direction: column; gap: 8px; align-items: stretch; }
    .profile-medication-primary-row { display: flex; flex-wrap: wrap; gap: 12px; width: 100%; align-items: flex-end; }
    .profile-medication-secondary-row { display: flex; flex-wrap: wrap; gap: 8px; width: 100%; align-items: flex-end; overflow-x: visible; }
    .profile-medication-meta label { display: flex; flex: 0 1 auto; flex-direction: column; gap: 4px; min-width: 80px; }
    .profile-medication-meta select { width: auto; min-width: 80px; max-width: 100%; margin-top: 0; box-sizing: border-box; }
    .profile-medication-secondary-row > [data-profile-medication-timing-field] { flex: 0 1 72px; min-width: 64px; }
    .profile-medication-secondary-row > [data-profile-medication-timing-field] select { min-width: 64px; }
    .profile-medication-secondary-row > [data-profile-medication-frequency-field],
    .profile-medication-secondary-row > [data-profile-medication-monthly-day-field],
    .profile-medication-secondary-row > [data-profile-medication-custom-days-field],
    .profile-medication-secondary-row > [data-profile-medication-prn-max-field],
    .profile-medication-secondary-row > [data-profile-medication-prn-interval-field] { flex: 0 1 120px; min-width: 90px; }
    .profile-medication-secondary-row > [data-profile-medication-custom-days-field] { flex: 0 1 72px; min-width: 64px; }
    .profile-medication-secondary-row > [data-profile-medication-custom-days-field] select { width: 72px; min-width: 0; }
    .profile-medication-meta fieldset { display: flex; flex: 1 1 100%; flex-wrap: nowrap; gap: 4px; align-items: center; min-width: 0; margin: 0; padding: 4px 6px; }
    .profile-medication-meta fieldset[hidden] { display: none; }
    .profile-medication-meta fieldset legend { flex: 0 0 auto; margin: 0 4px 0 0; }
    .profile-medication-meta fieldset label { flex: 0 0 auto; min-width: 0; display: inline-flex; flex-direction: row; gap: 2px; align-items: center; }
    .profile-medication-kind-topical .profile-medication-meta { flex-direction: row; justify-content: flex-start; align-items: flex-end; }
    .profile-medication-kind-topical .profile-medication-primary-row { display: contents; }
    .profile-medication-kind-topical .profile-medication-secondary-row { display: contents; }
    .profile-medication-kind-topical .profile-medication-secondary-row > [data-profile-medication-area-field] { flex: 0 1 110px; min-width: 80px; }
    .profile-medication-actions { display: flex; flex: 1 0 100%; justify-content: flex-end; gap: 6px; align-items: center; }
    .profile-medication-row button { width: 104px; margin: 0; padding: 8px 12px; white-space: nowrap; }
    .profile-medication-remove-button { color: #a33f36 !important; background: #fff0f0 !important; border: 1px solid #e7a5a5 !important; }
    .profile-medication-add-button { color: #7c3f15 !important; background: #fffaf3 !important; border: 1px solid #e7b27d !important; }
    .medication-monthly-dose {
      display: flex;
      flex-wrap: wrap;
      gap: 8px;
    }
    .medication-monthly-dose-row {
      display: flex;
      align-items: center;
      gap: 8px;
      width: calc(50% - 4px);
      box-sizing: border-box;
      min-width: 0;
      white-space: nowrap;
    }
    .medication-monthly-dose-row > .check-label {
      display: flex;
      align-items: center;
      flex: 0 1 auto;
      gap: 4px;
      min-width: 0;
      overflow: hidden;
      white-space: nowrap;
    }
    .medication-monthly-dose-row > .health-field {
      display: flex;
      align-items: center;
      flex: 1 1 auto;
      gap: 4px;
      min-width: 0;
      margin: 0;
      white-space: nowrap;
    }
    .medication-monthly-dose-row > .medication-monthly-time {
      flex: 1 1 75px;
      width: auto;
      min-width: 75px;
      max-width: 100%;
      box-sizing: border-box;
      padding: 4px 6px;
      font-size: 0.82rem;
    }
    .medication-profile-timing { margin: 0; font-size: 0.84rem; font-weight: 800; }
    .medication-profile-timing select { margin-top: 4px; }
    .medication-frequency-row,
    .medication-date-timing-row { display: flex; gap: 8px; align-items: end; }
    .medication-primary-row,
    .medication-secondary-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: flex-end; width: 100%; }
    .medication-primary-row > .health-field,
    .medication-secondary-row > .health-field { flex: 1 1 140px; min-width: 120px; margin: 0; }
    .medication-entry { width: 100%; max-width: 100%; min-width: 0; box-sizing: border-box; overflow: hidden; }
    .medication-entry .medication-primary-row,
    .medication-entry .medication-secondary-row { width: 100%; max-width: 100%; min-width: 0; }
    .medication-entry .medication-primary-row > .health-field,
    .medication-entry .medication-secondary-row > .health-field { flex: 1 1 0; min-width: 0; max-width: 100%; }
    .medication-entry .health-field input,
    .medication-entry .health-field select { width: 100%; max-width: 100%; min-width: 0; box-sizing: border-box; }
    .health-check .medication-entry,
    .health-check .medication-entry > .medication-primary-row,
    .health-check .medication-entry > .medication-secondary-row { width: 100%; max-width: 100%; min-width: 0; }
    .health-check .medication-entry .health-field { flex: 1 1 0; min-width: 0; max-width: 100%; }
    .health-check .medication-entry .medication-prn-settings .health-field { flex: 1 1 0; min-width: 0; }
    .diary-medication-entry { width: 100%; max-width: 100%; min-width: 0; box-sizing: border-box; overflow: hidden; }
    .diary-medication-entry .medication-primary-row,
    .diary-medication-entry .medication-secondary-row { display: flex; flex-wrap: wrap; gap: 8px; width: 100%; max-width: 100%; min-width: 0; }
    .diary-medication-entry .health-field { flex: 1 1 0; min-width: 0; max-width: 100%; }
    .diary-medication-entry .health-field input,
    .diary-medication-entry .health-field select { width: 100%; max-width: 100%; min-width: 0; box-sizing: border-box; }
    .diary-medication-form-container,
    .diary-medication-form-container .diary-medication-entry { width: 100% !important; max-width: 100% !important; min-width: 0 !important; box-sizing: border-box !important; }
    .diary-medication-form-container [hidden] { display: none !important; }
    .diary-medication-form-container .health-field[hidden],
    .diary-medication-form-container fieldset[hidden] { display: none !important; }
    .diary-medication-form-container select,
    .diary-medication-form-container input { width: auto !important; max-width: 100% !important; min-width: 0 !important; box-sizing: border-box !important; flex: 0 1 auto !important; }
    .diary-medication-form-container .medication-primary-row,
    .diary-medication-form-container .medication-secondary-row { display: flex !important; flex-direction: row !important; flex-wrap: wrap !important; gap: 8px !important; align-items: flex-end !important; width: 100% !important; max-width: 100% !important; min-width: 0 !important; }
    .diary-medication-form-container .medication-entry .health-field { display: inline-flex !important; flex: 0 1 auto !important; flex-direction: column !important; width: auto !important; min-width: 0 !important; max-width: 100% !important; margin: 0 !important; }
    .diary-medication-form-container .medication-entry .health-field select,
    .diary-medication-form-container .medication-entry .health-field input { flex: 0 1 auto !important; width: auto !important; max-width: 100% !important; }
    .diary-medication-form-container .medication-entry [data-medication-name-field],
    .diary-medication-form-container .medication-entry [data-profile-medication-select-field] { flex: 1 1 100% !important; width: 100% !important; }
    .diary-medication-form-container .medication-entry [data-medication-name-field] { display: flex !important; flex: 1 1 100% !important; width: 100% !important; }
    .diary-medication-form-container .medication-entry [data-medication-name-field] input,
    .diary-medication-form-container .medication-entry [data-profile-medication-select-field] select { width: auto !important; flex: 1 1 auto !important; }
    .diary-medication-form-container .medication-entry [data-medication-name-field] input { width: 100% !important; max-width: 100% !important; min-width: 0 !important; }
    .diary-medication-entry > .diary-medication-name-field { display: flex !important; flex: 0 1 100% !important; align-self: stretch !important; width: 100% !important; max-width: 100% !important; min-width: 0 !important; box-sizing: border-box !important; overflow: hidden; }
    .diary-medication-entry > .diary-medication-name-field input { display: block; flex: 1 1 auto !important; width: 100% !important; max-width: 100% !important; min-width: 0 !important; box-sizing: border-box !important; }
    .diary-medication-entry > .diary-profile-medication-select-field { display: flex !important; flex: 0 1 100% !important; align-self: stretch !important; width: 100% !important; max-width: 100% !important; min-width: 0 !important; box-sizing: border-box !important; }
    .diary-medication-entry > .diary-profile-medication-select-field select { display: block; flex: 1 1 auto !important; width: 100% !important; max-width: 100% !important; min-width: 0 !important; box-sizing: border-box !important; }
    .diary-medication-form-container .diary-medication-entry > .diary-profile-medication-select-field[data-profile-medication-select-field] { width: 100% !important; flex: 0 1 100% !important; }
    .diary-medication-form-container .diary-medication-entry > .diary-profile-medication-select-field[data-profile-medication-select-field] select { width: 100% !important; flex: 1 1 auto !important; }
    .diary-medication-entry .medication-slots { display: grid; grid-template-columns: minmax(0, 1fr); gap: 4px; width: 100%; max-width: 100%; }
    .diary-medication-entry .medication-slots .medication-slot { display: grid; grid-template-columns: 18px 64px minmax(75px, 1fr); align-items: center; gap: 6px; width: 100%; min-width: 0; }
    .diary-medication-entry .medication-slots .medication-slot > input { grid-column: 1; width: 18px; }
    .diary-medication-entry .medication-slots .medication-slot > select { grid-column: 3; width: 100% !important; min-width: 0; }
    .diary-medication-entry .medication-weekdays { display: grid; grid-template-columns: auto repeat(7, minmax(0, 1fr)); flex-wrap: nowrap; gap: 2px; width: 100%; max-width: 100%; min-width: 0; padding: 4px; align-items: center; }
    .diary-medication-entry .medication-weekdays legend { grid-column: 1; margin: 0 2px 0 0; font-size: 0.72rem; }
    .diary-medication-entry .medication-weekdays .check-label { grid-column: auto; justify-content: center; gap: 1px; min-width: 0; font-size: 0.72rem; white-space: nowrap; }
    .diary-medication-entry .medication-weekdays .check-label input { width: 14px; height: 14px; }
    .medication-frequency-row > .health-field,
    .medication-date-timing-row > .health-field { flex: 1 1 0; min-width: 0; margin: 0; }
    .medication-custom-days-notice { margin: -2px 0 4px; color: #8a6a4a; font-size: 0.78rem; font-weight: 500; }
    .medication-prn-settings { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 8px; }
    .medication-prn-settings .health-field { display: flex; flex: 1 1 calc(50% - 4px); flex-direction: column; min-width: 140px; margin: 0; white-space: nowrap; }
    .medication-prn-settings .health-field input { width: 100%; box-sizing: border-box; margin-top: 4px; }
    .medication-prn-times { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
    .medication-prn-time-row { display: flex; align-items: center; gap: 6px; min-width: 0; }
    .medication-prn-time-row .check-label { flex: 0 1 auto; min-width: 0; white-space: nowrap; }
    .medication-prn-time-row select { flex: 1 1 75px; min-width: 0; max-width: 100%; padding: 4px 6px; font-size: 0.82rem; box-sizing: border-box; }
    .medication-weekdays { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; flex: 1 1 100%; min-width: 0; margin: 0; padding: 6px 8px; border: 1px solid #e7b27d; border-radius: 8px; }
    .medication-weekdays legend { width: auto; flex: 0 0 auto; margin: 0 4px 0 0; padding: 0; font-size: 0.84rem; font-weight: 800; white-space: nowrap; }
    .medication-weekdays .check-label { flex: 0 0 auto; white-space: nowrap; }
    .favorite-food-group { margin: 14px 0 0; padding: 10px; border: 1px solid #e7b27d; border-radius: 10px; }
    .favorite-food-group legend { padding: 0 4px; font-size: 0.82rem; font-weight: 800; }
    .favorite-food-row { display: flex; gap: 6px; align-items: center; margin-top: 6px; }
    .favorite-food-row input { margin-top: 0; }
    .favorite-remove-button { width: auto !important; flex: 0 0 auto; margin-top: 0 !important; padding: 8px 10px !important; border-radius: 8px !important; background: #fff4f2 !important; color: #a33f36 !important; border: 1px solid #d47b70 !important; font-size: 0.75rem; }
    .favorite-add-button { margin-top: 8px !important; padding: 8px 10px !important; border-radius: 8px !important; background: #fffaf3 !important; color: #7c3f15 !important; border: 1px solid #e7b27d !important; font-size: 0.78rem; }

    @keyframes slideUp {
      from {
        opacity: 0;
        transform: translateY(20px);
      }
      to {
        opacity: 1;
        transform: translateY(0);
      }
    }

    .result-image {
      width: 100%;
      height: 240px;
      object-fit: contain;
      background: #ffffff;
      border-radius: 12px;
      margin-bottom: 0;
      display: block;
    }

    .result-detail {
      text-align: left;
      padding: 12px;
      background: #fffbf7;
      border-radius: 12px;
      margin-bottom: 8px;
      font-size: 0.95rem;
      line-height: 1.6;
    }

    .result-detail strong {
      color: #ff9500;
      display: block;
      margin-bottom: 4px;
    }

    .result-label {
      font-size: 0.8rem;
      color: #8b6e47;
      margin-bottom: 16px;
      padding: 12px;
      background: #fbf3e6;
      border-radius: 8px;
      display: inline-block;
    }

    .loading {
      display: none;
      position: relative;
      text-align: left;
      padding: 0;
    }

    .loading-preview {
      position: relative;
      width: 100%;
      height: 240px;
      margin-bottom: 0;
      overflow: hidden;
      border: 2px solid #e7b27d;
      border-radius: 22px;
      background: #ffffff;
    }

    .loading-image {
      width: 100%;
      height: 100%;
      object-fit: contain;
      background: #ffffff;
      display: block;
    }

    .paw-trail {
      position: relative;
      width: 100%;
      height: 58px;
      pointer-events: none;
      overflow: hidden;
    }

    .paw {
      position: absolute;
      left: -28px;
      bottom: 8px;
      color: #e88b2a;
      font-size: 1.55rem;
      opacity: 0;
      animation: pawStepWalk 14.4s linear infinite;
    }

    .paw:nth-child(1) {
      bottom: 24px;
      animation-delay: 0s;
    }

    .paw:nth-child(2) {
      bottom: 8px;
      animation-delay: 0.36s;
    }

    @keyframes pawStepWalk {
      0%, 2% { left: 0%; opacity: 0.9; transform: rotate(90deg); }
      4% { left: 0%; opacity: 0; transform: rotate(90deg); }
      5%, 7% { left: 10%; opacity: 0.9; transform: rotate(90deg); }
      8% { left: 10%; opacity: 0; transform: rotate(90deg); }
      10%, 12% { left: 20%; opacity: 0.9; transform: rotate(90deg); }
      14% { left: 20%; opacity: 0; transform: rotate(90deg); }
      15%, 17% { left: 30%; opacity: 0.9; transform: rotate(90deg); }
      19% { left: 30%; opacity: 0; transform: rotate(90deg); }
      20%, 22% { left: 40%; opacity: 0.9; transform: rotate(90deg); }
      24% { left: 40%; opacity: 0; transform: rotate(90deg); }
      25%, 27% { left: 50%; opacity: 0.9; transform: rotate(90deg); }
      29% { left: 50%; opacity: 0; transform: rotate(90deg); }
      30%, 32% { left: 60%; opacity: 0.9; transform: rotate(90deg); }
      34% { left: 60%; opacity: 0; transform: rotate(90deg); }
      35%, 37% { left: 70%; opacity: 0.9; transform: rotate(90deg); }
      39% { left: 70%; opacity: 0; transform: rotate(90deg); }
      40%, 42% { left: 80%; opacity: 0.9; transform: rotate(90deg); }
      44% { left: 80%; opacity: 0; transform: rotate(90deg); }
      45%, 47% { left: 90%; opacity: 0.9; transform: rotate(90deg); }
      49% { left: 90%; opacity: 0; transform: rotate(90deg); }
      50%, 52% { left: calc(100% - 28px); opacity: 0.9; transform: rotate(90deg); }
      54% { left: calc(100% - 28px); opacity: 0; transform: rotate(-90deg); }
      55%, 57% { left: 90%; opacity: 0.9; transform: rotate(-90deg); }
      59% { left: 90%; opacity: 0; transform: rotate(-90deg); }
      60%, 62% { left: 80%; opacity: 0.9; transform: rotate(-90deg); }
      64% { left: 80%; opacity: 0; transform: rotate(-90deg); }
      65%, 67% { left: 70%; opacity: 0.9; transform: rotate(-90deg); }
      69% { left: 70%; opacity: 0; transform: rotate(-90deg); }
      70%, 72% { left: 60%; opacity: 0.9; transform: rotate(-90deg); }
      74% { left: 60%; opacity: 0; transform: rotate(-90deg); }
      75%, 77% { left: 50%; opacity: 0.9; transform: rotate(-90deg); }
      79% { left: 50%; opacity: 0; transform: rotate(-90deg); }
      80%, 82% { left: 40%; opacity: 0.9; transform: rotate(-90deg); }
      84% { left: 40%; opacity: 0; transform: rotate(-90deg); }
      85%, 87% { left: 30%; opacity: 0.9; transform: rotate(-90deg); }
      89% { left: 30%; opacity: 0; transform: rotate(-90deg); }
      90%, 92% { left: 20%; opacity: 0.9; transform: rotate(-90deg); }
      94% { left: 20%; opacity: 0; transform: rotate(-90deg); }
      95%, 97% { left: 10%; opacity: 0.9; transform: rotate(-90deg); }
      99% { left: 10%; opacity: 0; transform: rotate(-90deg); }
      100% { left: 0%; opacity: 0; transform: rotate(-90deg); }
    }

    .loading-text {
      margin: 8px 0 0 4px;
      color: #7c3f15;
      font-size: 0.95rem;
    }