/* UA の配色選択をアプリのテーマに合わせて固定 */
:root {
  color-scheme: light;
}

:root.dark-mode {
  color-scheme: dark;
}

/* ライト表示中はフォームも必ず light、ダークは必ず dark に（※入力系のみに限定。button は含めない） */
html.light-mode input,
html.light-mode select,
html.light-mode textarea {
  color-scheme: light;
}

html.dark-mode input,
html.dark-mode select,
html.dark-mode textarea {
  color-scheme: dark;
}

/* =============================
 *  Global Theme Variables
 * ============================= */
:root {
  --input-bg-color: #ffffff;
  --input-text-color: #000000;
  --input-border-color: #cccccc;
  --section-bg-color: #f9f9f9;
  --section-text-color: #000000;
  --heading-border-color: #444444;
  --survey-bg-color: #f2f2f2;
  --survey-border-color: #cccccc;
  --survey-text-color: #000000;
  --header-bg-color: #bdbcbc;
  --footer-bg-color: #bdbcbc;
  --menu-bg-color: #f5f5f5;
}

.light-mode {
  --background-color: #ffffff;
  --text-color: #000000;

  --input-bg-color: #ffffff;
  --input-text-color: #000000;
  --input-border-color: #666;

  --section-bg-color: #f9f9f9;
  --section-text-color: #333;

  --link-text-color: #333;
  --heading-border-color: #333;

  --survey-bg-color: #f9f9f9;
  --survey-border-color: #ccc;
  --survey-text-color: #000;
}

.dark-mode {
  --background-color: #1a1a1a;
  --text-color: #f0f0f0;

  --input-bg-color: #1e1e1e;
  --input-text-color: #f0f0f0;
  --input-border-color: #666;

  --section-bg-color: #2b2b2b;
  --section-text-color: #f0f0f0;

  --link-text-color: #f0f0f0;
  --heading-border-color: gray;

  --survey-bg-color: #2a2a2a;
  --survey-border-color: #666;
  --survey-text-color: #f0f0f0;
}

/* =============================
   *  Base Layout & Typography
   * ============================= */

html,
body {
  height: 100%;
  margin: 0;
  background-color: var(--background-color);
  color: var(--text-color);
  font-family: Arial, sans-serif;
}

.wrapper {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.main-content {
  flex: 1;
  margin-top: 10px;
  padding: 10px 20px;
}

/* Headings */

h1 {
  font-size: 25px;
  font-weight: bold;
}

h2 {
  font-size: 23px;
  font-weight: bold;
}

/* Text & Helpers */

p {
  line-height: 1.7;
}

.ql-size-small {
  font-size: 0.75em;
}

.ql-size-large {
  font-size: 1.5em;
}

.ql-size-huge {
  font-size: 2.5em;
}

/* テキスト行や画像行の中央・右寄せ対応 */
.ql-align-center {
  text-align: center;
}

.ql-align-right {
  text-align: right;
}

.ql-align-justify {
  text-align: justify;
}

/* 画像単独の中央・右寄せ（Quill仕様による） */
.ql-align-center img {
  display: inline-block;
  margin-left: auto;
  margin-right: auto;
  /* 下記はお好みで幅指定 */
  /* max-width: 100%; */
}

.ql-align-right img {
  display: inline-block;
  margin-left: auto;
  margin-right: 0;
}

/* 画像のみの段落でも幅指定で中央に */
.ql-editor img {
  display: block;
  max-width: 100%;
  height: auto;
  margin: 1em auto;
}

label {
  display: block;
}

.small-text {
  font-size: 0.8em;
}

.big-text {
  font-size: 1.2em;
}

.error-message {
  color: red;
  margin-top: 5px;
}

/* Links */

a {
  color: var(--link-text-color);
  text-decoration: none;
}

a:hover {
  color: blue;
}

.no-underline {
  text-decoration: none;
  color: var(--link-text-color);
}

.no-underline:hover {
  color: blue;
}

/* Header-specific link override */
.header-content .no-underline {
  color: black;
}

.dark-mode .header-content .no-underline {
  color: black;
}

.fixed-color {
  color: black;
}

.dark-mode .fixed-color {
  color: black;
}

/* Form Controls */

input,
select,
textarea {
  background-color: var(--input-bg-color);
  color: var(--input-text-color);
  border: 1px solid var(--input-border-color);
  padding: 8px;
  box-sizing: border-box;
}

button {
  padding: 8px;
}

/* =============================
   *  Header / Navigation
   * ============================= */

.header-content {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background-color: var(--header-bg-color);
  color: black;
  padding: 10px;
}

.dashboard-icon a {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.dashboard-text {
  font-size: 11px;
  margin-bottom: 3px;
  line-height: 1;
}

.dashboard-image {
  width: 40px;
  height: auto;
}

#usernameDisplay {
  text-align: center;
  flex-grow: 1;
  margin-left: -50px;
  color: black;
}

.menu-icon {
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.menu-icon span {
  font-size: 11px;
}

.menu-btn {
  margin-top: 3px;
}

.menu-btn .menu-bar {
  width: 25px;
  height: 3px;
  background-color: black;
  margin: 4px 0;
  transition: 0.4s;
}

.menu-content {
  display: none;
  position: absolute;
  right: 9px;
  top: 65px;
  background-color: var(--menu-bg-color);
  z-index: 100;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.08);
  border-radius: 12px;
  min-width: 135px;
  padding: 0 0 0 8px;
}

.menu-content ul {
  list-style: none;
  padding: 0;
}

.menu-content ul li {
  padding: 10px;
  border-bottom: 1px solid #ddd;
  margin-bottom: 10px;
}

.menu-content ul li:last-child {
  border-bottom: none;
  margin-bottom: 0;
}

.menu-content ul li a,
.menu-content ul li button {
  display: block;
  color: black;
  text-decoration: none;
}

.menu-content ul li a:hover {
  background-color: rgba(128, 128, 128, 0.4);
}

/* Dark-mode menu background override */
.dark-mode .menu-content {
  background-color: #3e3d3d;
}

.dark-mode .menu-content ul li a,
.dark-mode .menu-content ul li button {
  color: #ccc;
}

/* =============================
   *  Utility Classes & Lines
   * ============================= */

.responsive-image {
  width: 600px;
  height: auto;
}

.top1 {
  display: block;
  margin-top: 10px;
}

.top3 {
  display: block;
  margin-top: 30px;
}

.bottom1 {
  display: block;
  margin-bottom: 10px;
}

.bottom3 {
  display: block;
  margin-bottom: 30px;
}

.line13,
.line15,
.line55 {
  border-top: 2px solid #d6d4d4;
  height: 1px;
  margin-top: 10px;
}

.line15 {
  margin-bottom: 50px;
}

.line55 {
  margin: 50px 0;
}

/* トースト通知の共通設定 */
#toast {
  position: fixed;
  pointer-events: none;
  top: 20%;
  left: 0;
  right: 0;
  margin: 0 auto;
  width: calc(100% - 40px);
  max-width: 1200px;
  color: #fff;
  padding: 35px 20px;
  border-radius: 4px;
  opacity: 0;
  transition: opacity 0.4s ease-in-out;
  z-index: 9999;
  font-size: 16px;
  text-align: center;
  box-sizing: border-box;
}

/* 表示状態 */
#toast.show {
  pointer-events: auto;
  opacity: 1;
}

/* トーストの閉じるボタン（他の指定に負けないように強度UP） */
#toastCloseButton {
  position: absolute;
  top: 10px;
  right: 10px;
  background: none !important;
  border: none !important;
  color: #fff;
  font-size: 24px;
  cursor: pointer;
  line-height: 1;
  pointer-events: auto;
}

#toastCloseButton:hover {
  color: #aaa;
}

/* ライトモード：背景は黒に近いグレー、文字色は白 */
.light-mode #toast {
  background-color: #222;
  color: #fff;
}

/* ダークモード：背景はやや明るいグレー、文字色は白 */
.dark-mode #toast {
  background-color: #444;
  color: #fff;
}

/* ダークモード時のログアウトボタン背景 */
.dark-mode .menu-content #logoutButton {
  background-color: #555 !important;
  color: #fff !important;
  border: none;
  padding: 10px;
  width: 100%;
  text-align: center;
  border-radius: 4px;
}

/* hover 時の明るめ */
.dark-mode .menu-content #logoutButton:hover {
  background-color: #666 !important;
}

/* Footer */
footer {
  background-color: var(--footer-bg-color);
  text-align: center;
  padding: 15px 0 5px 0;
  margin-top: 50px;
}

footer ul {
  list-style: none;
  padding: 0;
  display: inline-block;
  margin: 0;
}

footer ul li {
  display: inline;
  margin-right: 20px;
}

footer p,
footer p a {
  font-size: 13px;
  margin-top: 10px;
}

footer li,
footer li a {
  font-size: 13px;
}

/* ▼ ダークモード時だけフッター内リンクを黒にする */
.dark-mode footer a,
.dark-mode footer p a {
  color: black;
}

/* =============================
   *  Media Queries
   * ============================= */

@media screen and (min-width: 1024px) {
  .menu-wrapper:hover .menu-content {
    display: block;
  }
}

@media (max-width: 768px) {
  .main-content {
    margin-top: 20px;
    padding: 10px 15px;
  }

  .responsive-image {
    width: 100%;
  }

  .dashboard-image {
    margin-left: -30px;
    margin-bottom: 2px;
    width: 30px;
  }

  #usernameDisplay {
    font-size: 12px;
  }

  h1,
  h2 {
    font-size: 18px;
  }

  #toast {
    left: 10px;
    right: 10px;
    max-width: calc(100% - 20px);
  }

  #toastCloseButton {
    top: -2px;
    right: 3px;
  }

  footer {
    padding: 10px 0 2px 0;
  }

  footer p,
  footer p a {
    font-size: 12px;
    margin-top: 5px;
  }

  footer ul li a {
    font-size: 11px;
  }
}

/* 1) リンク全体はブロックに（縦並び前提） */
.dashboard-icon a {
  display: block !important;
  /* 既存の flex を打ち消し */
  min-height: 0;
  /* 余分な高さを持たせない */
  padding: 0;
  /* 余白は子要素で管理 */
  margin: 0;
}

/* 2) バランステキストは画像の「上」に、左へ12px寄せる */
#headerBalanceText,
.dashboard-icon .dashboard-text {
  display: block;
  margin: 0 0 4px 0;
  /* 下2px/左12px → 好みで微調整（左に寄せたいなら 14〜16px に） */
  line-height: 1.1;
  /* 上部の余白を詰める */
  white-space: nowrap;
  /* 折り返し禁止＝下段落ちしない */
  font-variant-numeric: tabular-nums;
  /* 数字幅を安定させてチラつき防止 */
}

/* 3) 画像はその「下」に、左へ同じ12px寄せる（ガタつき防止） */
.dashboard-image {
  display: block !important;
  /* float/absolute があれば無効化 */
  width: 40px;
  /* 固定サイズで安定 */
  height: auto;
  margin: 0 0 0 6px;
  /* 左12px（見切れる場合は 14〜18px に増やす） */
}

/* （念のため）既存のレイアウト指定を強制的に無効化 */
.dashboard-icon a::after {
  content: none;
  display: none;
}

.menu-wrapper.is-open .menu-content {
  display: block;
}

/* iOS Safari の自動ダーク化・オートフィルで文字が消える対策（入力系のみ・buttonは除外） */
input:not([type]),
input[type="text"],
input[type="email"],
input[type="password"],
input[type="search"],
input[type="tel"],
input[type="url"],
input[type="number"],
input[type="date"],
input[type="time"],
input[type="month"],
input[type="week"],
input[type="datetime-local"],
select,
textarea {
  background-color: var(--input-bg-color) !important;
  color: var(--input-text-color) !important;
  border-color: var(--input-border-color) !important;
  -webkit-text-fill-color: var(--input-text-color);
  /* iOSに効く */
  caret-color: var(--input-text-color);
  /* キャレットも見えるように */
}

input::placeholder,
textarea::placeholder {
  /* 充分に見える濃さに固定（変えたければ調整） */
  color: #777;
  opacity: 1;
}

/* オートフィル時（黄色背景）でも文字色を維持し、背景のベタ塗りを覆う */
input:-webkit-autofill,
textarea:-webkit-autofill,
select:-webkit-autofill {
  -webkit-text-fill-color: var(--input-text-color);
  /* Safariの黄背景を上書きするインセット影（背景色で“塗り替える”） */
  -webkit-box-shadow: 0 0 0 1000px var(--input-bg-color) inset;
  box-shadow: 0 0 0 1000px var(--input-bg-color) inset;
  /* 背景が一瞬だけ変わる挙動の抑制（保険） */
  transition: background-color 99999s ease-in-out 0s;
}