:root {
  --bg-main: #181922;
  --card-bg: #23233a;
  --title: #fafafa;
  --text-main: #f3f3f3;
  --label: #e0e0e0;
  --primary: #4b98f2;
  --primary-hover: #2661bd;
  --accent: #f6c94a;
  --error: #fc596f;
  --hint-bg: #21223c;
  --hint-border: #313358;
  --input-bg: #24253a;
  --input-fg: #fafafa;
  --input-focus-bg: #3642e2;
  --input-focus-border: #6ca0fa;
  --input-btn-bg: #4b98f2;
  --input-btn-hover-bg: #6ca0fa;
}

body {
  margin: 0;
  padding: 0;
  min-height: 100vh;
  font-family: "SF Pro", "Noto Sans TC", "Arial", "Helvetica", sans-serif;
  background: var(--bg-main);
  color: var(--text-main);
  transition: background 0.2s, color 0.2s;
}

h1 {
  text-align: center;
  margin-top: 2.5rem;
  color: var(--title);
  font-size: 2rem;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.calculator {
  background: var(--card-bg);
  border-radius: 20px;
  max-width: 410px;
  width: 92vw;
  margin: 3rem auto 0 auto;
  padding: 2.2rem 1.7rem 1.2rem 1.7rem;
  box-shadow: 0 3px 20px #0006;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 1.2rem;
}

label {
  display: block;
  font-size: 1.06rem;
  margin-bottom: 0.7em;
  color: var(--label);
  text-align: left;
  font-weight: 500;
  letter-spacing: 0.02em;
  user-select: none;
}

.calculator-column {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-around;
  gap: 0.7em; /* 間距可微調 */
  margin-bottom: 1.1em;
}

input[type="date"] {
  width: 100%;
  max-width: 320px;
  margin: 0 auto;
  margin-top: 0.3em;
  margin-bottom: 0.3em;
  padding: 0.64em 0.85em;
  font-size: 1.1em;
  border-radius: 8px;
  border: 2px solid var(--primary);
  box-sizing: border-box;
  background: #181922;
  color: var(--text-main);
  outline: none;
  transition: border-color 0.2s, background 0.2s;
}

input[type="date"]:focus {
  border-color: var(--accent);
  background: #23233a;
}

input[type="date"]::-webkit-calendar-picker-indicator {
  filter: brightness(0) invert(1) sepia(1) saturate(5) hue-rotate(180deg);
  border-radius: 4px;
  opacity: 1;
  width: 1.9em;
  height: 1.9em;
  cursor: pointer;
}

input[type="date"]:hover::-webkit-calendar-picker-indicator,
input[type="date"]:focus::-webkit-calendar-picker-indicator {
  filter: brightness(0) invert(1) sepia(1) saturate(100) hue-rotate(10deg) brightness(100%);
}

button {
  width: 100%;
  max-width: 320px;
  margin: 0 auto;
  margin-top: 0.3em;
  margin-bottom: 0.3em;
  padding: 0.78em 0;
  font-size: 1.17rem;
  background: var(--primary);
  border-radius: 7px;
  border: none;
  color: #fff;
  font-weight: 600;
  letter-spacing: 0.04em;
  cursor: pointer;
  box-shadow: 0 2px 6px #2224;
  transition: background 0.2s;
}

button:hover, button:active, button:focus {
  background: var(--primary-hover);
}

#result {
  font-size: 1.12em;
  margin-top: 0.6em;
  color: var(--accent);
  font-family: inherit;
  letter-spacing: 0.01em;
  font-weight: 500;
}

#result b {
  color: #fff;
  font-weight: 700;
}

.hint {
  font-size: 1em;
  margin-top: 2em;
  background: var(--hint-bg);
  border-radius: 9px;
  padding: 0.9em 1em 0.7em 1em;
  color: var(--label);
  border: 1.5px solid var(--hint-border);
  box-sizing: border-box;
}

a, a:link { color: var(--primary);}

a:hover, a:active, a:focus { color: #f6c94a; }

/* 錯誤訊息 */
#error {
  color: var(--error);
  font-weight: 600;
  margin-top: 1em;
  font-size: 1.02em;
}

/* === 手機 375px 以下（含） === */
@media (max-width: 375px) {
  h1 {
    font-size: 1.25rem;
    margin-top: 1.5rem;
  }
  .calculator {
    width: 95vw;
    max-width: none;
    padding: 1.3rem 0.6rem 1rem 0.6rem;
    margin-top: 1.7rem;
    border-radius: 16px;
  }
  .calculator-row {
    flex-direction: column;
    align-items: stretch;
    gap: 0.5em;
  }
  input[type="date"], button {
    max-width: 100%;
    width: 100%;
    font-size: 1.06em;
    min-width: 0;
    height: 2.3em;
  }
  .hint {
    padding: 0.8em 0.3em 0.6em 0.3em;
    font-size: 0.95em;
  }
}

/* === 平板 451px ~ 900px === */
@media (min-width: 451px) and (max-width: 900px) {
  .calculator {
    width: 80vw;
    max-width: 540px;
    padding: 1.6rem 1.2rem 1.15rem 1.2rem;
    border-radius: 20px;
  }
  h1 {
    font-size: 1.5rem;
  }
  .hint {
    font-size: 0.98em;
  }
}

/* === 桌機（1024px 以上） === */
@media (min-width: 1024px) {
  .calculator {
    width: 420px;
    max-width: 98vw;
    padding: 2.2rem 2.3rem 1.7rem 2.3rem;
    border-radius: 24px;
  }
  h1 {
    font-size: 2.1rem;
    margin-top: 2.5rem;
  }
  .hint {
    font-size: 1em;
  }
}
