/* 着メロ広場 プレビュー版スタイル（平成風・オリジナルデザイン） */
:root {
  --bg: #e8e2cf;
  --panel: #f6f1de;
  --ink: #2b2b26;
  --accent: #2e4a3a;
  --accent2: #b3543f;
  --border: #8a8267;
}
html[data-theme="light"] { --bg: #f2f2f2; --panel: #ffffff; --ink: #222; --accent: #205c40; --border: #bbb; }
html[data-theme="dark"]  { --bg: #1d1f22; --panel: #2a2d31; --ink: #e8e8e2; --accent: #7fb894; --border: #555; }
html[data-font="small"] { font-size: 14px; }
html[data-font="std"]   { font-size: 16px; }
html[data-font="large"] { font-size: 19px; }

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: "Hiragino Kaku Gothic ProN", "Yu Gothic", "Noto Sans JP", sans-serif;
  background: var(--bg);
  color: var(--ink);
}
.site-header {
  display: flex; flex-wrap: wrap; align-items: center; gap: .5rem 1rem;
  padding: .6rem 1rem; background: var(--accent); color: #fff;
}
html[data-theme="dark"] .site-header { color: #10231a; }
.site-header h1 { font-size: 1.35rem; margin: 0; letter-spacing: .12em; }
.badge-preview { background: #f2c14e; color: #3a2c00; border-radius: 4px; padding: .1rem .5rem; font-size: .78rem; font-weight: bold; }
.header-settings { margin-left: auto; display: flex; gap: .8rem; flex-wrap: wrap; font-size: .82rem; }
.header-settings select { font-size: .85rem; }

main { max-width: 1080px; margin: 0 auto; padding: 1rem; }
.banner { background: #fdf3c9; border: 1px solid #c9a93b; color: #4a3a00; padding: .45rem .8rem; margin: .5rem 1rem 0; border-radius: 4px; font-size: .88rem; }
.preview-note { background: var(--panel); border: 1px dashed var(--border); padding: .6rem .8rem; border-radius: 6px; }

.device-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: .8rem; }
.device-card { background: var(--panel); border: 2px solid var(--border); border-radius: 10px; padding: .8rem; }
.device-card h3 { margin: .1rem 0 .3rem; font-size: 1.05rem; }
.device-card .era { font-size: .78rem; opacity: .8; min-height: 2.2em; }
.device-card button, .menu-btn, .tool-btn {
  font: inherit; cursor: pointer; border-radius: 6px; border: 2px solid var(--accent);
  background: var(--accent); color: #fff; padding: .45rem .9rem;
}
.device-card button { width: 100%; margin-top: .4rem; }
html[data-theme="dark"] .device-card button, html[data-theme="dark"] .tool-btn { color: #10231a; }
.top-menu { display: flex; flex-direction: column; gap: .5rem; margin-top: 1.2rem; max-width: 480px; }
.menu-btn { text-align: left; background: var(--panel); color: var(--ink); border-color: var(--border); }
.menu-btn:disabled { opacity: .65; cursor: not-allowed; }
.badge-notready { background: #999; color: #fff; border-radius: 3px; padding: .05rem .4rem; font-size: .72rem; margin-left: .4rem; }

.compose-toolbar { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; margin-bottom: .6rem; }
.compose-toolbar h2 { margin: 0; font-size: 1.1rem; }
.tool-btn { background: var(--panel); color: var(--ink); border-color: var(--border); }
.tool-btn.primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.title-wrap input { font: inherit; padding: .35rem .5rem; border: 1px solid var(--border); border-radius: 4px; min-width: 12rem; background: var(--panel); color: var(--ink); }

.compose-main { display: flex; gap: 1.2rem; align-items: flex-start; }
.stage-col { flex: 0 1 auto; }
.info-col { flex: 1 1 260px; min-width: 240px; }
@media (max-width: 760px) { .compose-main { flex-direction: column; } }
@media (orientation: landscape) and (max-height: 520px) {
  .compose-main { flex-direction: row; }
  #phone-wrap { max-height: 78vh; overflow: auto; }
}

.play-device-row { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; margin-bottom: .5rem; font-size: .9rem; }
.play-device-row .note { font-size: .78rem; opacity: .75; }

#phone-wrap { display: inline-block; touch-action: none; padding: 6px; }
#phone {
  /* 狭い画面では main の padding(32px)＋ #phone-wrap の padding(12px) を差し引いた幅に収める。
     実寸は app.js が offsetWidth で測って確保領域へ反映するので、ここでの上限とずれない */
  width: 300px; max-width: calc(100vw - 48px);
  margin: 0 auto; border-radius: 28px; padding: 16px 16px 20px;
  background: var(--phone-body, #c0c4cc);
  box-shadow: inset 0 0 0 3px rgba(0,0,0,.18), 0 6px 18px rgba(0,0,0,.25);
  transform-origin: top center;
}
.phone-brand { text-align: center; font-size: .68rem; letter-spacing: .25em; color: var(--phone-brand-ink, rgba(0,0,0,.55)); margin-bottom: 6px; font-weight: bold; }
#lcd {
  background: var(--phone-lcd, #b8c49a); color: #22301c; border-radius: 6px;
  border: 3px solid rgba(0,0,0,.35); padding: 8px 10px;
  font-family: "Courier New", monospace; min-height: 148px;
}
#lcd-top { font-size: .8rem; border-bottom: 1px solid rgba(0,0,0,.3); padding-bottom: 3px; display: flex; justify-content: space-between; }
#lcd-settings { font-size: .8rem; padding: 3px 0; border-bottom: 1px dotted rgba(0,0,0,.3); }
#lcd-notes { font-size: .95rem; line-height: 1.7; word-break: break-all; min-height: 76px; padding-top: 4px; }
#lcd-notes .cursor { animation: blink 1s steps(1) infinite; }
#lcd-notes mark { background: #e2543e; color: #fff; border-radius: 2px; }
#lcd-status { font-size: .75rem; border-top: 1px solid rgba(0,0,0,.3); padding-top: 3px; }
@keyframes blink { 50% { opacity: 0; } }
@media (prefers-reduced-motion: reduce) { #lcd-notes .cursor { animation: none; } }

#softkeys { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin: 10px 0; }
.soft-btn {
  font: inherit; font-size: .8rem; cursor: pointer; border-radius: 14px; padding: .4rem .2rem;
  background: var(--phone-sub, #9aa0a8); border: 2px solid rgba(0,0,0,.25); color: var(--phone-sub-ink, #1c1c1c);
}
.soft-btn:active { filter: brightness(1.25); }

#keypad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.key {
  font: inherit; cursor: pointer; border-radius: 50%; aspect-ratio: 1.35;
  background: #eef0f2; border: 2px solid rgba(0,0,0,.3); color: #1c1c1c;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  user-select: none; -webkit-user-select: none; touch-action: none;
}
.key .num { font-size: 1.05rem; font-weight: bold; line-height: 1; }
.key .sub { font-size: .68rem; opacity: .75; }
.key.pressed { background: #f2c14e; transform: scale(.94); }

.stage-controls { display: flex; flex-wrap: wrap; gap: .5rem 1rem; align-items: center; margin-top: .7rem; font-size: .88rem; }
.color-chip { width: 26px; height: 26px; border-radius: 50%; border: 2px solid rgba(0,0,0,.35); cursor: pointer; margin-right: 4px; vertical-align: middle; }
.color-chip.selected { outline: 3px solid var(--accent2); }
.mini-btn { font: inherit; cursor: pointer; border: 1px solid var(--border); background: var(--panel); color: var(--ink); border-radius: 4px; padding: .15rem .5rem; }
#inp-tempo { width: 4.2rem; font: inherit; padding: .15rem .3rem; }

.spec-box, .help-box, .export-box { background: var(--panel); border: 1px solid var(--border); border-radius: 8px; padding: .7rem .9rem; margin-bottom: .8rem; }
.export-box h3 { margin: .1rem 0 .5rem; }
.export-box label { display: block; margin-bottom: .45rem; font-size: .9rem; }
.export-box select { font: inherit; margin-left: .3rem; max-width: 100%; }
.export-note { font-size: .8rem; margin: .5rem 0 0; white-space: pre-line; }
.export-note:empty { display: none; }

.backup-box { background: var(--panel); border: 1px solid var(--border); border-radius: 8px; padding: .7rem .9rem; margin-bottom: .8rem; }
.backup-box h3 { margin: .1rem 0 .5rem; }
.backup-box .works-tools { margin-bottom: 0; }
.backup-result { font-size: .85rem; margin: .55rem 0 0; white-space: pre-line; }
.backup-result:empty { display: none; }
.works-tools { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; margin-bottom: .8rem; font-size: .88rem; }
.works-tools .note { font-size: .78rem; opacity: .75; }
.work-export { flex-basis: 100%; display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; border-top: 1px dashed var(--border); padding-top: .5rem; font-size: .88rem; }
.work-export select { font: inherit; max-width: 100%; }
.work-export .export-note { flex-basis: 100%; margin-top: .1rem; }
.spec-box h3 { margin: .1rem 0 .4rem; }
.spec-box .spec-note { font-size: .86rem; }
.spec-box .evidence { font-size: .75rem; opacity: .8; }

.works-list { list-style: none; padding: 0; }
.works-list li { background: var(--panel); border: 1px solid var(--border); border-radius: 8px; padding: .6rem .8rem; margin-bottom: .5rem; display: flex; flex-wrap: wrap; gap: .4rem .8rem; align-items: center; }
.works-list .w-title { font-weight: bold; }
.works-list .w-meta { font-size: .8rem; opacity: .8; }
.works-list button { font: inherit; cursor: pointer; border-radius: 5px; border: 1px solid var(--border); background: var(--bg); color: var(--ink); padding: .25rem .7rem; }

.site-footer { padding: 1rem; font-size: .8rem; opacity: .8; max-width: 1080px; margin: 0 auto; }
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%);
  background: #222; color: #fff; padding: .55rem 1.1rem; border-radius: 20px;
  font-size: .9rem; z-index: 50; box-shadow: 0 4px 14px rgba(0,0,0,.3);
}
