@charset "UTF-8";

:root {
  --c-primary: #ec4899;       /* Pink 500 */
  --c-primary-hover: #db2777;
  --c-bg: #fdf2f8;            /* Pink 50 */
  --c-card-bg: #ffffff;
  --c-text-main: #1f2937;
  --c-text-sub: #6b7280;
  --c-border: #e5e7eb;
  --c-input-bg: #ffffff;
  --c-accent-bg: #fce7f3;
  --c-box-bg: #1f2937;
  --c-box-text: #ffffff;
  --c-error: #ef4444;         /* Error Red */
  --c-error-bg: #fef2f2;
  
  --shadow-card: 0 10px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
  --radius-md: 12px;
  --radius-lg: 24px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --c-primary: #f472b6;
    --c-bg: #0f172a;
    --c-card-bg: #1e293b;
    --c-text-main: #f1f5f9;
    --c-text-sub: #94a3b8;
    --c-border: #334155;
    --c-input-bg: #0f172a;
    --c-accent-bg: #334155;
    --c-box-bg: #0f172a;
    --c-box-text: #f1f5f9;
    --c-error: #f87171;
    --c-error-bg: #450a0a;
    --shadow-card: 0 10px 25px -5px rgba(0, 0, 0, 0.5);
  }
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background-color: var(--c-bg);
  color: var(--c-text-main);
  margin: 0;
  padding: 20px;
  line-height: 1.6;
}

.tool-wrapper {
  max-width: 900px;
  margin: 0 auto;
  background: var(--c-card-bg);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  padding: 40px;
  box-sizing: border-box;
}

/* Header */
.tool-header { margin-bottom: 30px; text-align: center; }
.app-title { font-size: 2.2rem; font-weight: 900; margin: 0; letter-spacing: -0.03em; }
.app-title .accent { color: var(--c-primary); }
.app-desc { margin: 5px 0 0; color: var(--c-text-sub); font-size: 0.9rem; }

/* Preset Grid */
.preset-area { margin-bottom: 30px; }
.preset-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(90px, 1fr));
  gap: 10px;
}
.btn-preset {
  background: var(--c-card-bg);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-md);
  padding: 10px;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  flex-direction: column;
  align-items: center;
  /* スマホでのタップ領域確保 */
  min-height: 60px;
}
.btn-preset:hover {
  border-color: var(--c-primary);
  background: var(--c-accent-bg);
  transform: translateY(-2px);
}
.ratio-text { font-weight: 800; font-size: 1rem; color: var(--c-text-main); }
.ratio-label { font-size: 0.7rem; color: var(--c-text-sub); margin-top: 2px; }
.btn-preset.special { border-style: dashed; }

/* Calc Panel */
.calc-panel {
  display: flex;
  gap: 30px;
  background: var(--c-accent-bg);
  padding: 30px;
  border-radius: var(--radius-md);
  margin-bottom: 30px;
  align-items: stretch;
}

.panel-section { flex: 1; display: flex; flex-direction: column; justify-content: center; }

.section-header {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}
.group-label {
  font-size: 0.9rem;
  font-weight: bold;
  color: var(--c-text-sub);
}

.inputs-row { display: flex; align-items: center; gap: 8px; justify-content: center; }
.input-col { display: flex; flex-direction: column; width: 100%; }
.sub-label { font-size: 0.7rem; color: var(--c-text-sub); font-weight: bold; margin-bottom: 4px; }

input {
  width: 100%;
  padding: 12px;
  font-size: 1.3rem;
  border: 2px solid var(--c-border);
  border-radius: 8px;
  text-align: center;
  background: var(--c-input-bg);
  color: var(--c-text-main);
  font-family: monospace;
  font-weight: bold;
  box-sizing: border-box;
  transition: border-color 0.2s, background-color 0.2s;
}
input:focus { outline: none; border-color: var(--c-primary); }

/* エラー時のスタイル (堅牢性) */
input.input-error {
  border-color: var(--c-error);
  background-color: var(--c-error-bg);
  color: var(--c-error);
}

.separator { font-weight: bold; color: var(--c-text-sub); font-size: 1.2rem; }
.divider { display: flex; align-items: center; justify-content: center; opacity: 0.5; font-size: 1.5rem; }

/* Icons & Buttons */
.btn-icon {
  background: transparent;
  border: 1px solid var(--c-border);
  border-radius: 50%;
  width: 32px; height: 32px;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.2rem;
  color: var(--c-text-sub);
  transition: all 0.2s;
}
.btn-icon:hover { background: var(--c-card-bg); color: var(--c-primary); border-color: var(--c-primary); }

.btn-detect {
  margin-top: 15px;
  background: var(--c-card-bg);
  border: 1px solid var(--c-primary);
  color: var(--c-primary);
  font-weight: bold;
  font-size: 0.85rem;
  padding: 12px; /* タップしやすく */
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s;
  display: flex; align-items: center; justify-content: center; gap: 5px;
}
.btn-detect:hover { background: var(--c-primary); color: #fff; }
.btn-detect:active { transform: scale(0.95); }

/* Preview */
.preview-area {
  border: 1px solid var(--c-border);
  border-radius: var(--radius-md);
  padding: 20px;
  background-image: radial-gradient(var(--c-border) 1px, transparent 1px);
  background-size: 20px 20px;
}
.preview-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; }
.section-title { margin: 0; font-size: 1.1rem; border-left: 4px solid var(--c-primary); padding-left: 10px; }
.current-info { font-weight: bold; font-family: monospace; background: var(--c-card-bg); padding: 4px 10px; border-radius: 4px; border: 1px solid var(--c-border); }

.preview-canvas {
  height: 300px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden; 
}

.preview-box {
  background: var(--c-box-bg);
  color: var(--c-box-text);
  aspect-ratio: 16 / 9;
  height: 60%;
  max-width: 100%;
  max-height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  box-shadow: 0 10px 20px rgba(0,0,0,0.2);
  transition: all 0.5s cubic-bezier(0.25, 0.8, 0.25, 1);
  position: relative;
  overflow: hidden;
}

.box-content { text-align: center; padding: 5px; }
.box-dims { 
  display: block; 
  font-size: 1rem; 
  font-weight: bold; 
  font-family: monospace; 
  white-space: nowrap; 
}

/* Article & Ad */
.article-content { margin-top: 50px; border-top: 1px solid var(--c-border); padding-top: 30px; }
.feature-box { background: var(--c-accent-bg); padding: 20px; border-radius: 8px; border-left: 4px solid var(--c-primary); margin: 20px 0; }
.ad-placeholder { margin: 30px 0; background: var(--c-bg); height: 100px; display: flex; align-items: center; justify-content: center; border-radius: var(--radius-md); border: 1px dashed var(--c-border); }
.ad-label { font-size: 0.7rem; color: var(--c-text-sub); }

/* Mobile Optimization */
@media (max-width: 640px) {
  .tool-wrapper { padding: 20px 15px; }
  .calc-panel { flex-direction: column; gap: 20px; padding: 20px; }
  .divider { transform: rotate(90deg); margin: 10px 0; }
  .inputs-row input { font-size: 1.2rem; }
  
  /* スマホの縦画面でプレビューが高すぎないように調整 */
  .preview-canvas { height: 250px; }
}