/* ==================================
  mikoto / mikoto tools common form
================================== */

.mikoto-tool-form {
  width: 100%;
}


/* =========================
  Tool form shell
========================= */

.tool-form-card {
  max-width: 760px;
  margin: 30px auto 20px;
  padding: 18px 22px 20px;
  border-radius: 20px;

  background: rgba(255, 255, 255, 0.82);
  border: 1px solid rgba(120, 80, 60, 0.18);
  border-top: 5px solid var(--mikoto-red);

  box-shadow: 0 10px 28px rgba(80, 30, 20, 0.08);
}

.tool-form-title {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;

  margin: 0 0 10px;

  color: var(--mikoto-red-dark);
  font-size: 1.45rem;
  letter-spacing: 0.08em;
}

.tool-form-title-icon {
  display: inline-block;
  width: 22px;
  height: 22px;
  margin: 0 8px;
  vertical-align: -4px;

  background-image: url("../images/icon_star.webp");
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;

  opacity: 0.82;
}

.tool-form-lead {
  max-width: 640px;
  margin: 0 auto 16px;

  color: rgba(80, 50, 45, 0.72);
  font-size: 0.82rem;
  line-height: 1.7;
  text-align: center;
}


/* =========================
  Tool form inner
  通常フォーム用
========================= */

.tool-form-inner {
  max-width: 620px;
  margin: 0 auto;
  padding: 14px 16px 12px;
  border-radius: 16px;

  background: rgba(253, 251, 251, 0.94);
  border: 1px solid rgba(120, 80, 60, 0.12);
}

.tool-form-row {
  display: grid;
  grid-template-columns: 120px minmax(0, 1fr);
  gap: 12px;
  align-items: center;

  margin-bottom: 12px;
}

.tool-form-row:last-child {
  margin-bottom: 0;
}

.tool-form-label {
  padding-right: 4px;

  color: var(--mikoto-red-dark);
  font-size: 0.9rem;
  font-weight: 800;
  text-align: right;
  white-space: nowrap;
}

.tool-form-control {
  min-width: 0;
}


/* =========================
  Compact tool form
  年干支・月干支・日干支・土用など
========================= */

.tool-form-inner--compact-center {
  width: fit-content;
  max-width: 100%;
  margin: 0 auto;
  padding: 14px 18px 12px;

  display: grid;
  grid-template-columns: 10em 23em;
  column-gap: 18px;
  row-gap: 14px;
  align-items: center;
}

/* .tool-form-row の箱を消して、
   中の label / select / radio を親gridに直接参加させる */
.tool-form-inner--compact-center .tool-form-row {
  display: contents;
}

.tool-form-inner--compact-center .tool-form-label {
  justify-self: end;
  width: auto;
  padding-right: 0;
  margin: 0;

  text-align: right;
  white-space: nowrap;
}

.tool-form-inner--compact-center select {
  justify-self: start;
  width: 13.5em;
  min-width: 0;
  max-width: 13.5em;
}

.tool-form-inner--compact-center .tool-radio-group {
  justify-self: start;
}


/* =========================
  Tool form controls
========================= */

.tool-form-card input[type="number"],
.tool-form-card select {
  height: 34px;
  padding: 5px 10px;
  border-radius: 12px;

  border: 1px solid rgba(120, 80, 60, 0.20);
  background: rgba(255, 253, 251, 0.86);

  color: rgba(65, 43, 38, 0.88);
  font-size: 0.88rem;
  font-weight: 600;

  box-shadow:
    inset 0 1px 2px rgba(80, 30, 20, 0.04),
    0 1px 0 rgba(255, 255, 255, 0.48);

  transition:
    border-color 0.14s ease,
    box-shadow 0.14s ease,
    background 0.14s ease;
}

.tool-form-card input[type="number"]:focus,
.tool-form-card select:focus {
  outline: none;
  border-color: rgba(62, 116, 172, 0.58);
  background: rgba(255, 255, 255, 0.96);

  box-shadow:
    0 0 0 3px rgba(62, 116, 172, 0.12),
    inset 0 1px 2px rgba(80, 30, 20, 0.04);
}

.tool-year-input {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.tool-year-input input[type="number"] {
  width: 6.2em;
  text-align: center;
}

.tool-year-input span {
  color: #6f665f;
  font-weight: 700;
}

.tool-timezone-row {
  display: grid;
  grid-template-columns: 3.2em minmax(0, 1fr);
  gap: 8px;
  align-items: center;

  max-width: 420px;
}

.tool-timezone-row label {
  margin: 0;

  color: var(--mikoto-red-dark);
  font-size: 0.88rem;
  font-weight: 700;
}

.tool-timezone-row select {
  width: 100%;
  min-width: 0;
}


/* =========================
  Radio controls
========================= */

.tool-radio-group {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 18px;
  align-items: center;
  justify-content: flex-start;
}

.tool-radio-item {
  display: inline-flex;
  align-items: center;
  gap: 5px;

  color: #4e3329;
  font-size: 0.95rem;
  cursor: pointer;
}

.tool-radio-item input {
  accent-color: #8a4f3b;
}


/* =========================
  Choice box
  簡易大運チェッカー等で使用する場合用
========================= */

.tool-choice-box {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 12px 18px;
  align-items: center;

  width: fit-content;
  max-width: 100%;
  padding: 8px 14px;
  border-radius: 10px;

  background: rgba(255, 255, 255, 0.72);
  border: 1px solid rgba(120, 80, 60, 0.18);
}

.tool-choice-box label {
  display: inline-flex;
  align-items: center;
  gap: 6px;

  margin: 0;

  color: #572321;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
}

.tool-choice-box input[type="radio"] {
  width: auto;
}


/* =========================
  Tool form notes
========================= */

.tool-form-notes {
  max-width: 580px;
  margin: 16px auto 0;
  padding: 10px 14px;

  background: rgba(255, 250, 245, 0.46);
}

.tool-form-note {
  color: rgba(22, 12, 11, 0.65);
  font-size: 0.83rem;
  line-height: 1.65;
  text-align: left;
}

.tool-form-notes .tool-form-note {
  max-width: none;
  margin: 0;
  padding: 0;

  background: transparent;
}

.tool-form-notes .tool-form-note + .tool-form-note {
  margin-top: 6px;
}


/* =========================
  Tool submit
========================= */

.tool-submit-area {
  display: flex;
  justify-content: center;

  margin-top: 14px;
}

.tool-submit-button {
  width: min(100%, 420px);
  padding: 13px 24px;
  border: none;
  border-radius: 999px;

  background:
    linear-gradient(
      135deg,
      rgb(180, 42, 35),
      rgb(205, 72, 55)
    );

  color: #fff;
  font-weight: 800;
  cursor: pointer;

  box-shadow: 0 10px 10px rgba(120, 30, 25, 0.24);

  transition:
    transform 0.12s ease,
    box-shadow 0.12s ease,
    filter 0.12s ease;
}

.tool-submit-button:hover {
  transform: translateY(-1px);
  filter: brightness(1.04);
  box-shadow: 0 10px 10px rgba(120, 30, 25, 0.30);
}

.tool-submit-button-main {
  display: block;

  font-size: 1.05rem;
  letter-spacing: 0.06em;
}


/* =========================
  Tool result card
========================= */

.tool-result-card {
  max-width: 920px;
  margin: 20px auto;
  padding: 16px 18px;
  border-radius: 16px;

  background: rgba(255, 255, 255, 0.65);
  border: 1px solid rgba(120, 80, 60, 0.12);
  border-top: 5px solid rgba(62, 116, 172, 0.95);

  box-shadow: 0 8px 20px rgba(80, 30, 20, 0.05);
}

.tool-result-card > h2 {
  margin: 20px 30px;

  color: var(--mikoto-red-dark);
  font-size: 1.18rem;
}

.tool-result-card > .muted {
  margin: 0 23px;

  font-size: 0.84rem;
  line-height: 1.5;
}

.tool-result-card .tool-table-scroll {
  max-width: 95%;
  margin: 20px auto 0;
  border-radius: 12px;

  background: rgba(255, 253, 251, 0.28);
  border: 1px solid rgba(120, 80, 60, 0.10);

  overflow-x: auto;
}

.tool-result-note {
  max-width: 600px;
  margin: 12px 30px 0;
  padding: 5px 3px;

  color: rgba(39, 20, 16, 0.65);
  font-size: 0.81rem;
  line-height: 1.55;
  text-align: left;

  background: rgba(255, 250, 245, 0.46);
}


/* =========================
  Tool result table common
========================= */

.tool-result-table {
  min-width: 720px;
  border-collapse: separate;
  border-spacing: 0;

  background: rgba(255, 253, 251, 0.86);

  color: #4e3329;
  font-size: 0.82rem;
}

.tool-result-table th,
.tool-result-table td {
  padding: 7px 9px;

  border-right: 1px solid rgba(234, 223, 216, 0.78);
  border-bottom: 1px solid rgba(234, 223, 216, 0.78);

  text-align: center;
  vertical-align: middle;
}

.tool-result-table th:last-child,
.tool-result-table td:last-child {
  border-right: none;
}

.tool-result-table tbody tr:last-child th,
.tool-result-table tbody tr:last-child td {
  border-bottom: none;
}

.tool-result-table thead th {
  background: rgba(180, 42, 35, 0.08);

  color: rgb(110, 30, 25);
  font-weight: 800;
  white-space: nowrap;
}

.tool-result-table tbody tr:hover {
  background: rgba(255, 252, 247, 0.65);
}

.tool-result-table .solar-term-cell {
  width: 6em;

  background: rgba(180, 42, 35, 0.055);

  color: var(--mikoto-red-dark);
  font-weight: 800;
  letter-spacing: 0.06em;
  white-space: nowrap;
}

.tool-result-table .reading-cell {
  width: 7em;

  color: rgba(80, 50, 45, 0.78);
  font-weight: 600;
  white-space: nowrap;
}

.tool-result-table .meaning-cell {
  min-width: 20em;

  color: #4f3b32;
  line-height: 1.6;
  text-align: left;
}

.tool-result-table .date-cell {
  width: 10em;

  color: #51463e;
  font-size: 0.8rem;
  white-space: nowrap;
}

.tool-result-table .longitude-cell {
  width: 8em;

  color: #5a4134;
  font-size: 0.8rem;
  font-weight: 700;
  white-space: nowrap;
}


/* =========================
  Simple result tables
  年干支・月干支・日干支・土用など
========================= */

.ganzhi-result-table,
.doyo-result-table {
  min-width: 640px;
}

.ganzhi-result-table th,
.ganzhi-result-table td,
.doyo-result-table th,
.doyo-result-table td {
  white-space: nowrap;
}


/* =========================
  Shichijuni-ko: result table
========================= */

.shichijuni-ko-result-table {
  min-width: 100%;
  font-size: 0.82rem;
}

.shichijuni-ko-result-table th,
.shichijuni-ko-result-table td {
  padding: 6px 8px;
}

.shichijuni-ko-result-table .solar-term-cell {
  width: 5.5em;

  background: rgba(180, 42, 35, 0.055);

  color: var(--mikoto-red-dark);
  font-weight: 800;
  letter-spacing: 0.06em;
}

.shichijuni-ko-result-table .ko-name-cell {
  color: #4f3b32;
  font-weight: 700;
  white-space: nowrap;
}

.shichijuni-ko-result-table .ko-position {
  color: rgba(80, 50, 45, 0.62);
  font-size: 0.76rem;
}

.shichijuni-ko-result-table .date-cell {
  color: #51463e;
  font-size: 0.8rem;
  white-space: nowrap;
}

.shichijuni-ko-result-table .longitude-cell {
  color: #5a4134;
  font-size: 0.8rem;
  font-weight: 700;
  white-space: nowrap;
}

/* 二十四節気の切れ目 */
.shichijuni-ko-result-table tr.is-solar-term-start th,
.shichijuni-ko-result-table tr.is-solar-term-start td {
  border-top: 2px solid rgba(180, 42, 35, 0.22);
}

.shichijuni-ko-result-table tbody tr:first-child th,
.shichijuni-ko-result-table tbody tr:first-child td {
  border-top: none;
}


/* =========================
  Tool source note
========================= */

.tool-source-note {
  max-width: 83%;
  margin: 12px 28px 0;

  color: rgba(67, 29, 22, 0.62);
  font-size: 0.82rem;
  line-height: 1.6;
}


/* =========================
  Tool table note
  必要なページだけで使用
========================= */

.tool-table-note {
  max-width: 680px;
  margin: 12px auto 0;
  padding: 5px 3px;

  color: rgba(48, 28, 24, 0.65);
  font-size: 0.83rem;
  line-height: 1.55;
  text-align: left;

  background: rgba(255, 250, 245, 0.46);
}


/* =========================
  Tools common mobile
========================= */

@media (max-width: 767px) {
  .tool-form-card {
    width: calc(100% - 20px);
    max-width: calc(100% - 20px);
    margin: 20px auto;
    padding: 22px 16px 26px;
    box-sizing: border-box;
  }

  .tool-form-title {
    gap: 8px;
    font-size: 1.18rem;
    line-height: 1.45;
    letter-spacing: 0.06em;
  }

  .tool-form-title-icon {
    width: 18px;
    height: 18px;
    margin: 0 4px;
  }

  .tool-form-lead {
    font-size: 0.86rem;
    line-height: 1.75;
    text-align: left;
  }

  .tool-form-inner {
    width: 100%;
    max-width: 100%;
    padding: 14px 12px 12px;
    box-sizing: border-box;
  }

  .tool-form-row {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 7px;

    width: 100%;
    max-width: 100%;
    margin-bottom: 16px;
    box-sizing: border-box;
  }

  .tool-form-label {
    width: 100%;
    min-width: 0;
    max-width: 100%;
    padding-right: 0;

    text-align: left;
    white-space: normal;
  }

  .tool-form-control {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    box-sizing: border-box;
  }

  .tool-form-card input[type="number"],
  .tool-form-card select {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    box-sizing: border-box;
  }

  .tool-year-input,
  .tool-timezone-row {
    width: 100%;
    max-width: 100%;
  }

  .tool-timezone-row {
    grid-template-columns: 1fr;
    gap: 6px;
  }

  .tool-choice-box {
    width: 100%;
    box-sizing: border-box;
    justify-content: flex-start;
  }

  .tool-submit-area {
    margin-top: 18px;
  }

  .tool-submit-button {
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
  }

  .tool-result-card {
    width: calc(100% - 20px);
    max-width: calc(100% - 20px);
    margin: 18px auto;
    padding: 14px 12px;
    box-sizing: border-box;
  }

  .tool-result-card > h2 {
    margin: 14px 8px;
    font-size: 1.02rem;
    line-height: 1.55;
  }

  .tool-result-card > .muted {
    margin: 0 8px;
    font-size: 0.8rem;
  }

  .tool-result-card .tool-table-scroll {
    max-width: 100%;
    margin: 16px auto 0;
  }

  .tool-result-table {
    font-size: 0.8rem;
  }

  .tool-result-table th,
  .tool-result-table td {
    padding: 7px 8px;
  }

  .tool-source-note {
    max-width: 100%;
    margin: 10px 6px 0;
    font-size: 0.78rem;
  }

  .tool-table-note {
    max-width: 100%;
    margin: 10px 0 0;

    font-size: 0.78rem;
    line-height: 1.65;
  }

  .tool-result-note {
    max-width: 100%;
    margin: 10px 8px 0;

    font-size: 0.78rem;
    line-height: 1.65;
  }

  .tool-form-notes {
    max-width: 100%;
    margin: 14px 0 0;
    padding: 9px 11px;
  }

  .tool-form-notes .tool-form-note {
    font-size: 0.78rem;
    line-height: 1.65;
  }


  /* compact form mobile override */
  .tool-form-inner--compact-center {
    width: 100%;
    max-width: 100%;
    padding: 14px 12px 12px;

    display: grid;
    grid-template-columns: 5.5em minmax(0, 1fr);
    column-gap: 10px;
    row-gap: 12px;
  }

  .tool-form-inner--compact-center .tool-form-row {
    display: contents;
  }

  .tool-form-inner--compact-center .tool-form-label {
    justify-self: end;
    width: auto;
    max-width: none;
    padding-right: 0;

    text-align: right;
    white-space: nowrap;
  }

  .tool-form-inner--compact-center select {
    justify-self: start;
    width: 100%;
    max-width: 13.5em;
  }

  .tool-form-inner--compact-center .tool-radio-group {
    justify-self: start;
    gap: 8px 12px;
  }
}