:root {
  --bg: #f4f6f8;
  --panel: #ffffff;
  --text: #1d2733;
  --muted: #5b6773;
  --line: #d9e0e7;
  --shadow: 0 10px 30px rgba(0,0,0,0.08);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Yu Gothic UI", "Yu Gothic", Meiryo, sans-serif;
  background: var(--bg);
  color: var(--text);
}

button, input, select { font: inherit; }
button { cursor: pointer; }

.app-shell {
  width: min(1180px, calc(100% - 24px));
  margin: 0 auto;
  padding: 20px 0 30px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 18px;
  margin-bottom: 18px;
}

.topbar h1 { margin: 0; font-size: clamp(28px, 4vw, 44px); }
.topbar p { margin: 8px 0 0; color: var(--muted); font-size: 18px; }

.status-panel, .category-section, .custom-section, .settings-section {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 20px;
  box-shadow: var(--shadow);
  padding: 22px;
  margin-bottom: 18px;
}

.status-label { color: var(--muted); font-weight: 700; margin-bottom: 8px; }
.message-display {
  min-height: 90px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  border: 3px solid #25364a;
  border-radius: 16px;
  padding: 16px;
  font-size: 34px;
  font-weight: 800;
  background: #fafbfd;
}

.status-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 14px;
}

.primary-btn, .danger-btn, .sub-btn {
  border: none;
  border-radius: 14px;
  padding: 16px 20px;
  font-weight: 800;
}
.primary-btn { background: #1f6feb; color: white; }
.danger-btn { background: #b42318; color: white; }
.sub-btn { background: #243447; color: white; min-width: 110px; }

h2 { margin: 0 0 16px; font-size: 24px; }

.phrase-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.phrase-btn {
  min-height: 112px;
  border: 3px solid #2a3642;
  border-radius: 18px;
  background: white;
  padding: 16px;
  font-size: 28px;
  font-weight: 900;
  line-height: 1.25;
}
.phrase-btn:hover, .phrase-btn:focus-visible { transform: translateY(-1px); box-shadow: 0 8px 18px rgba(0,0,0,.12); }
.phrase-btn:active { transform: translateY(1px); }

.category-basic { background: #eef6ff; }
.category-care { background: #f2fbf3; }
.category-pain { background: #fff3f0; }
.category-feeling { background: #fff9e8; }

.custom-row {
  display: grid;
  grid-template-columns: 1fr 150px;
  gap: 12px;
}
.custom-row input {
  min-height: 64px;
  border: 2px solid #aab5c1;
  border-radius: 14px;
  padding: 0 16px;
  font-size: 24px;
}

.settings-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}
.settings-grid label {
  display: flex;
  flex-direction: column;
  gap: 10px;
  font-weight: 800;
}
select, input[type="range"] { width: 100%; }
select {
  min-height: 48px;
  border: 2px solid #aab5c1;
  border-radius: 10px;
  padding: 0 10px;
}

footer { color: var(--muted); text-align: center; font-size: 14px; }

body.font-normal .phrase-btn { font-size: 24px; min-height: 96px; }
body.font-normal .message-display { font-size: 30px; }
body.font-large .phrase-btn { font-size: 28px; }
body.font-large .message-display { font-size: 34px; }
body.font-xlarge .phrase-btn { font-size: 34px; min-height: 130px; }
body.font-xlarge .message-display { font-size: 42px; }

@media (max-width: 800px) {
  .phrase-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .settings-grid { grid-template-columns: 1fr; }
  .custom-row { grid-template-columns: 1fr; }
  .status-actions { grid-template-columns: 1fr; }
}

@media (max-width: 520px) {
  .app-shell { width: min(100% - 12px, 1180px); padding-top: 10px; }
  .topbar { align-items: flex-start; }
  .topbar p { font-size: 15px; }
  .phrase-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .phrase-btn { min-height: 92px; font-size: 21px; padding: 10px; }
  .status-panel, .category-section, .custom-section, .settings-section { padding: 14px; border-radius: 14px; }
  .message-display { font-size: 26px; }
}

.top-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.hidden { display: none !important; }

.edit-panel {
  background: #fff;
  border: 3px solid #243447;
  border-radius: 20px;
  box-shadow: var(--shadow);
  padding: 22px;
  margin-bottom: 18px;
}

.edit-panel-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 18px;
  margin-bottom: 18px;
}

.edit-panel-head h2 { margin-bottom: 6px; }
.edit-panel-head p { margin: 0; color: var(--muted); line-height: 1.6; }

.ghost-btn {
  border: 2px solid #7b8794;
  background: #fff;
  border-radius: 12px;
  padding: 12px 18px;
  font-weight: 800;
}

.add-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 130px 180px;
  gap: 12px;
  align-items: end;
  padding: 16px;
  background: #f6f8fa;
  border-radius: 14px;
  margin-bottom: 16px;
}

.add-form label {
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-weight: 800;
}

.add-form input,
.edit-row input {
  width: 100%;
  min-height: 48px;
  border: 2px solid #aab5c1;
  border-radius: 10px;
  padding: 0 12px;
}

.add-btn { min-height: 48px; padding: 10px 14px; }

.edit-list {
  display: grid;
  gap: 10px;
}

.edit-row {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) 100px auto;
  gap: 10px;
  align-items: center;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 12px;
}

.edit-number {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: #243447;
  color: #fff;
  font-weight: 900;
}

.edit-row select {
  min-height: 48px;
}

.row-controls {
  display: flex;
  gap: 6px;
}

.mini-btn {
  min-width: 44px;
  min-height: 44px;
  border: 1px solid #9aa5b1;
  border-radius: 10px;
  background: #fff;
  font-weight: 900;
}

.mini-btn:disabled {
  opacity: .35;
  cursor: not-allowed;
}

.delete-mini {
  padding: 0 12px;
  color: #a11;
  border-color: #d9a3a3;
}

@media (max-width: 800px) {
  .topbar { align-items: flex-start; }
  .top-actions { justify-content: flex-start; }
  .add-form { grid-template-columns: 1fr; }
  .edit-row { grid-template-columns: 38px minmax(0, 1fr); }
  .edit-row select { grid-column: 2; }
  .row-controls { grid-column: 2; }
}


.save-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.save-status {
  font-weight: 800;
  color: var(--muted);
}

@media (max-width: 600px) {
  .save-actions { align-items: stretch; flex-direction: column; }
}


.phrase-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

.phrase-image {
  width: 100%;
  max-width: 150px;
  height: 110px;
  object-fit: contain;
  border-radius: 12px;
  background: rgba(255,255,255,.7);
}

.phrase-text {
  display: block;
}

.add-form {
  grid-template-columns: minmax(0, 1fr) 130px minmax(180px, 0.7fr) 180px;
}

.add-form input[type="file"] {
  width: 100%;
  min-height: 48px;
  border: 2px solid #aab5c1;
  border-radius: 10px;
  padding: 8px;
  background: #fff;
}

.edit-row {
  grid-template-columns: 44px minmax(0, 1fr) 100px minmax(180px, 0.7fr) auto;
}

.image-edit-block {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.image-preview {
  width: 72px;
  height: 58px;
  flex: 0 0 72px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #f6f8fa;
  display: grid;
  place-items: center;
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  text-align: center;
}

.image-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.image-edit-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.hidden-file-input {
  display: none;
}

.image-select-btn {
  padding: 0 10px;
  white-space: nowrap;
}

@media (max-width: 950px) {
  .edit-row {
    grid-template-columns: 38px minmax(0, 1fr);
  }
  .edit-row select,
  .image-edit-block,
  .row-controls {
    grid-column: 2;
  }
}

@media (max-width: 800px) {
  .add-form { grid-template-columns: 1fr; }
}

@media (max-width: 520px) {
  .phrase-image {
    height: 90px;
    max-width: 120px;
  }
}


.mode-notice {
  margin: 14px 0 18px;
  padding: 10px 14px;
  border-radius: 12px;
  background: #eef4f8;
  border: 1px solid #c9d8e3;
  color: #334a5f;
  font-weight: 700;
  text-align: center;
}

.admin-toolbar {
  display: flex;
  justify-content: flex-end;
  margin: -6px 0 14px;
}

.settings-mode .mode-notice {
  background: #fff6df;
  border-color: #e5c97a;
  color: #5b4916;
}

.mode-toggle-btn {
  font-weight: 800;
}


.password-setting-row {
  align-items: flex-start;
  gap: 16px;
}

.password-setting-controls {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) minmax(180px, 1fr) auto auto;
  gap: 8px;
  width: 100%;
}

.password-setting-controls input {
  min-height: 44px;
  border: 2px solid #aab5c1;
  border-radius: 10px;
  padding: 8px 10px;
  background: #fff;
}

.setting-help {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: .9rem;
}

@media (max-width: 900px) {
  .password-setting-controls {
    grid-template-columns: 1fr;
  }
}

.app-footer {
  margin: 28px 0 12px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 8px 16px;
  color: var(--muted);
  font-size: 0.85rem;
}

.trial-notice {
  background: #eef7ff;
  border-color: #b7d7ee;
  color: #24516d;
}
