:root {
  --bg: #f5f2eb;
  --surface: #ffffff;
  --border: #e0d9cc;
  --text: #2c2820;
  --muted: #6e675c;
  --accent: #4a6b4e;
  --danger: #9c4a3c;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

/*
 * ホーム画面に追加した iOS のアプリでは 100dvh が見えている高さより大きくなり、中身が短い画面でもスクロールする。
 * 高さは dvh などのビューポート単位ではなく、html を基準にした % で決める。バウンスを止める overscroll-behavior は、スクロールする html に付けないと効かない
 */
html {
  height: 100%;
  -webkit-text-size-adjust: 100%;
  overscroll-behavior-y: none;
}

body {
  height: 100%;
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family:
    ui-sans-serif, system-ui, -apple-system, "Hiragino Kaku Gothic ProN",
    "Hiragino Sans", Meiryo, sans-serif;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

h1,
h2,
p,
ul {
  margin: 0;
}

ul {
  padding: 0;
  list-style: none;
}

a {
  color: inherit;
  text-decoration: none;
}

/* iOS は 16px 未満の入力欄にフォーカスするとズームする */
button,
input,
select,
textarea {
  font: inherit;
  font-size: 16px;
  color: inherit;
}

button {
  cursor: pointer;
}

.muted {
  color: var(--muted);
}

.small {
  font-size: 0.875rem;
}

.xs {
  font-size: 0.75rem;
}

/* 小さい文字のリンクでも指で押せるよう、押せる範囲を上下に広げる */
summary.link {
  padding-block: 0.375rem;
}

.error {
  color: var(--danger);
  font-size: 0.875rem;
}

.page {
  max-width: 28rem;
  margin: 0 auto;
  padding: 1.5rem 1.25rem 4rem;
}

.card {
  margin-bottom: 1.5rem;
  padding: 1.25rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.card h2 {
  margin-bottom: 1rem;
  font-size: 0.875rem;
  font-weight: 500;
}

.section-title {
  margin-bottom: 0.75rem;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--muted);
}

.stack {
  display: grid;
  gap: 1rem;
}

.btn {
  display: block;
  width: 100%;
  padding: 0.75rem;
  border: 0;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font-weight: 500;
  transition: opacity 0.15s;
}

.btn:active {
  opacity: 0.85;
}

.link {
  padding: 0;
  border: 0;
  background: none;
  color: var(--muted);
  font-size: 0.875rem;
}

.field {
  width: 100%;
  padding: 0.625rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  outline: none;
}

.field:focus {
  border-color: var(--accent);
}

/* 入力欄の地は背景と同じ色なので、カードの外に置く欄は背景と区別できるよう白にする */
.search .field,
.login .field {
  background: var(--surface);
}

/* ログイン */

.login {
  display: flex;
  flex-direction: column;
  justify-content: center;
  max-width: 20rem;
  min-height: 100%;
  margin: 0 auto;
  padding: 1.5rem 2rem;
  text-align: center;
}

.login h1 {
  font-size: 1.125rem;
  font-weight: 500;
}

.login form {
  display: grid;
  gap: 0.75rem;
  margin-top: 2rem;
}

.pin {
  text-align: center;
  font-size: 1.25rem;
  letter-spacing: 0.5em;
}

.pin::placeholder {
  letter-spacing: normal;
}

/* ローンチャー */

.launcher {
  padding: 2.5rem 1.5rem 4rem;
}

.launcher header {
  margin-bottom: 2.5rem;
}

/* めったに使わない操作なので、タイルの下に控えめに置く */
.launcher-actions {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 1.5rem;
  margin-top: 3rem;
}

/* form の中のボタンは、form の文字の大きさで作られる行に置かれるので「PINを変える」より下がる。form を外してボタンを直に並べる */
.launcher-actions form {
  display: contents;
}

.launcher h1 {
  margin-top: 0.125rem;
  font-size: 1.125rem;
  font-weight: 500;
  letter-spacing: -0.01em;
}

.tiles {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1.75rem 0.5rem;
}

.tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
}

.tile-icon {
  display: flex;
  width: 60px;
  height: 60px;
  align-items: center;
  justify-content: center;
  border-radius: 14px;
  color: #fff;
  font-family: ui-serif, Georgia, Cambria, "Times New Roman", Times, serif;
  font-size: 1.25rem;
  transition: transform 0.15s;
}

.tile:active .tile-icon {
  transform: scale(0.95);
}

.tile-name,
.tile-label {
  max-width: 76px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tile-name {
  font-size: 11px;
  letter-spacing: 0.025em;
}

.tile-label {
  margin-top: -0.375rem;
  color: var(--muted);
  font-size: 10px;
}

/* アプリ共通ヘッダー */

.app-header {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}

.app-header a {
  min-width: 0;
  overflow: hidden;
  font-size: 0.875rem;
  color: var(--muted);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.app-header h1 {
  font-size: 0.875rem;
  font-weight: 500;
}

/* フォームだけの画面など、PC でも広げずに読みやすい幅にとどめる中身 */
.narrow {
  max-width: 32rem;
  margin-inline: auto;
}

/* マウスで触る PC */

@media (hover: hover) {
  .btn:hover {
    opacity: 0.9;
  }

  .link:hover,
  .app-header a:hover {
    color: var(--text);
  }

  .tile:hover .tile-icon {
    transform: translateY(-2px);
  }
}

/* PC。アプリは各自の CSS で、同じ幅から広い配置に切り替える */

@media (min-width: 50rem) {
  .page {
    padding: 2.5rem 2rem 4rem;
  }

  .app-header {
    margin-bottom: 2rem;
  }

  .launcher {
    max-width: 44rem;
    padding-top: 4rem;
  }

  .launcher header {
    margin-bottom: 3rem;
  }

  .tiles {
    grid-template-columns: repeat(6, 1fr);
    gap: 2.25rem 1rem;
  }

  .tile-icon {
    width: 72px;
    height: 72px;
    border-radius: 16px;
    font-size: 1.5rem;
  }

  .tile-name,
  .tile-label {
    max-width: 96px;
  }

  .tile-name {
    font-size: 12px;
  }

  .tile-label {
    font-size: 11px;
  }
}
